ich probiere gerade ein paar Dinge aus... ist natürlich nicht fein geschrieben, aber es geht mir um das Verständnis.
Wieso bekomme ich so viele Koeffizienten raus? Ich hätte jetzt einen erwartet.
Wieso bekomme ich so viele Konstanten (intercept) raus? Ich hätte jetzt einen erwartet.
Code: Alles auswählen
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn import preprocessing
import pandas
import scipy.spatial
import scipy.stats
import scipy
import random
import numpy
path = "..."
Examples = pandas.read_excel(io=path, sheet_name=0, header=None, skiprows=2)
Examples = Examples.values
print(Examples)
>>> [Out]
[[ 2. 2.1 ]
[ 3. 4.9 ]
[ 4. 1.4 ]
[ 3.4 2.1 ]
[ 5. 1.9 ]
[ 6.7 2.8 ]
[55. 70. ]
[63. 64.3 ]
[65. 54.5 ]
[54. 80. ]
[42. 65. ]
[55. 65. ]
[38. 45. ]
[ 2.44 5. ]
[43. 32. ]
[70. 50. ]]
train_x = Examples[0:13,0].reshape(-1,1)
train_y = Examples[0:13,1].reshape(-1,1)
test_x = Examples[13:16,0].reshape(-1,1)
test_y = Examples[13:16,1].reshape(-1,1)
#Encoden
lab_enc = preprocessing.LabelEncoder()
training_y_encoded = lab_enc.fit_transform(train_y.ravel())
#Model
clf = LogisticRegression()
clf.fit(train_x, training_y_encoded)
#Koeffizienten
coef = clf.coef_
print(coef)
>>> [Out]
[[-0.30020469]
[-0.20023317]
[-0.34766145]
[-0.11155487]
[-0.41948743]
[-0.02386848]
[-0.00537448]
[-0.0065249 ]
[ 0.00056065]
[-0.01138778]
[-0.01202993]]
print('intercept:', clf.intercept_.reshape(-1,1))
>> [Out]
[[-0.21955754]
[-0.4051622 ]
[ 0.35798376]
[-0.59208539]
[-0.02204233]
[-1.06375401]
[-1.35218985]
[-1.33102731]
[-1.15507754]
[-1.24631744]
[-1.23570657]]