Back to questions
JuniorTheoryCommon
What does this program print?
import numpy as np
from sklearn.linear_model import LogisticRegression
X = np.array([[0.0], [2.0], [4.0], [6.0], [8.0], [10.0]])
y = np.array([0, 0, 0, 1, 1, 1])
model = LogisticRegression()
model.fit(X, y)
proba = model.predict_proba(np.array([[9.0]]))
print(round(proba[0, 0], 2), model.predict(np.array([[9.0]]))[0])0.02 1
- Expecting
0.98: the columns ofpredict_probafollowmodel.classes_, so column0holds the probability of class0; class1is in column1. - Expecting
predictto return a probability: it returns a label, here1, because the probability of class1is above 0.5.
- How do you get the probability of class
1for every row ofX_test? - What does
model.classes_hold, and how does it set the column order?