2017-03-06 121 views
1

代碼:Python和SPSS給予不同的輸出Logistic迴歸

from sklearn.linear_model import LogisticRegression 
l = LogisticRegression() 
b = l.fit(XT,Y) 
    print "coeff ",b.coef_ 
    print "intercept ",b.intercept_ 

這裏的

XT = 
[[23] 
[24] 
[26] 
[21] 
[29] 
[31] 
[27] 
[24] 
[22] 
[23]] 
Y = [1 0 1 0 0 1 1 0 1 0] 

結果數據集:

coeff [[ 0.00850441]] 
intercept [-0.15184511 

現在我加入了相同的數據在spss.Analyse - >迴歸 - >二元邏輯迴歸。我設置了相應的Y - >依賴和XT - >協變量。結果並不是很接近。我在Python或SPSS中丟失了什麼? Result of binary logistic regression on SPSS Python-Sklearn

回答

2

解決它自己。我試着改變LinearRegression中的C值(C = 100)。那就是訣竅。 C = 1000得到最接近SPSS和教科書結果的結果。希望這可以幫助任何在Python中面臨LogisticRegression問題的人。

+0

所以我又有了一個問題。爲什麼默認的C值沒有給出SPSS或教科書中的結果?我錯過了什麼嗎? –