다중선형회귀 실습 예제

🥑 피어슨 계수

r이 -1.0과 -0.7 사이이면, 강한 음적 선형관계, r이 -0.7과 -0.3 사이이면, 뚜렷한 음적 선형관계, r이 -0.3과 -0.1 사이이면, 약한 음적 선형관계, r이 -0.1과 +0.1 사이이면, 거의 무시될 수 있는 선형관계, r이 +0.1과 +0.3 사이이면, 약한 양적 선형관계, r이 +0.3과 +0.7 사이이면, 뚜렷한 양적 선형관계, r이 +0.7과 +1.0 사이이면, 강한 양적 선형관계

df=pd.read_csv('data/cars.csv', index_col='Unnamed: 0')
df.head(5)

Untitled

df.corr()

Untitled

🥑 보스톤 데이터로 다중회귀 실습해보기

from sklearn.datasets import load_boston
boston=load_boston()
print(boston['DESCR'])
.. _boston_dataset:

Boston house prices dataset
---------------------------

**Data Set Characteristics:**

    :Number of Instances: 506

    :Number of Attributes: 13 numeric/categorical predictive. Median Value (attribute 14) is usually the target.

    :Attribute Information (in order):
        - CRIM     per capita crime rate by town
        - ZN       proportion of residential land zoned for lots over 25,000 sq.ft.
        - INDUS    proportion of non-retail business acres per town
        - CHAS     Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)
        - NOX      nitric oxides concentration (parts per 10 million)
        - RM       average number of rooms per dwelling
        - AGE      proportion of owner-occupied units built prior to 1940
        - DIS      weighted distances to five Boston employment centres
.
.

print(boston['DESCR']) 를 통해 boston 데이터를 간략하게 살펴볼 수 있음

컬럼(feature)값에 대한 설명을 볼 수 있음

CRIM: 범죄율 INDUS: 비소매상업지역 면적 비율 NOX: 일산화질소 농도 RM: 주택당 방 수 LSTAT: 인구 중 하위 계층 비율 B: 인구 중 흑인 비율 PTRATIO: 학생/교사 비율 ZN: 25,000 평방피트를 초과 거주지역 비율 CHAS: 찰스강의 경계에 위치한 경우는 1, 아니면 0 AGE: 1940년 이전에 건축된 주택의 비율 RAD: 방사형 고속도로까지의 거리 DIS: 직업센터의 거리 TAX: 재산세율