"Sklearn 단순회귀분석"의 두 판 사이의 차이

15번째 줄: 15번째 줄:
reg = linear_model.LinearRegression()
reg = linear_model.LinearRegression()
reg.fit(X,Y)
reg.fit(X,Y)
print( "R²=", reg.score(X,Y) )
print( "coefficient=", reg.coef_ )
print( "coefficient=", reg.coef_ )
print( "intercept=", reg.intercept_ )
print( "intercept=", reg.intercept_ )
print( "R²=", reg.score(X,Y) )
</source>
</source>
:→ 회귀식 <math>y=61.27218654x-39.06195591884392</math>
:→ 회귀식 <math>y=61.27218654x-39.06195591884392</math>

2020년 4월 3일 (금) 00:10 판

1 개요

sklearn 단순선형회귀분석
import pandas as pd
df = pd.DataFrame({
'height': [1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83],
'mass': [52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46],
})

X = df.loc[:,['height']]
Y = df['mass']

from sklearn import linear_model
reg = linear_model.LinearRegression()
reg.fit(X,Y)
print( "coefficient=", reg.coef_ )
print( "intercept=", reg.intercept_ )
print( "R²=", reg.score(X,Y) )
→ 회귀식 [math]\displaystyle{ y=61.27218654x-39.06195591884392 }[/math]
→ 결정계수 [math]\displaystyle{ R^2=0.9891969224457968 }[/math]

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}