Statsmodels 로지스틱회귀분석

(Statsmodels 로지스틱 회귀분석에서 넘어옴)

1 개요[ | ]

Statsmodels 로지스틱회귀분석

2 예시 1: 공부시간과 합격확률[ | ]

import pandas as pd
df = pd.DataFrame({
'hours': [0.50,0.75,1.00,1.25,1.50,1.75,1.75,2.00,2.25,2.50,2.75,3.00,3.25,3.50,4.00,4.25,4.50,4.75,5.00,5.50],
'pass': [0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1],
})

X = df[['hours']]
Y = df['pass']

import statsmodels.api as sm
X = sm.add_constant(X)
model = sm.Logit(Y,X)
results = model.fit()

print( results.summary() )
→ 회귀식 [math]\displaystyle{ y = \dfrac{1}{1 + \exp(-(1.5046 x_1 - 4.0777))} }[/math]

3 예시 2: 스페셜 판매확률[ | ]

import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/jmnote/zdata/master/logistic-regression/special-sales.csv')
print( df )

Y = df['special_sales']
X = df[['busy_day','high_temperature']]

import statsmodels.api as sm
X = sm.add_constant(X)
model = sm.Logit(Y,X)
results = model.fit()

print( results.summary() )
→ 회귀식 [math]\displaystyle{ y = \dfrac{1}{1 + \exp(-(2.4426 x_1 + 0.5445 x_2 - 15.2035))} }[/math]

4 같이 보기[ | ]

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