import numpy as np
from sklearn.linear_model import LogisticRegression
X = np.array([-2, -1, 0, 0.9, 2, 3]).reshape(6, 1)
y = np.array([-1, 0, 1, 1, 3, 4])
lr = LogisticRegression(solver="lbfgs",
multi_class="auto",max_iter=8000)
# lr = LogisticRegression()
lr.fit(X, y)
print(lr.predict(X))
score = lr.score(X, y)
print("Score: %s" % score)
注意:y中的值需要为整数(虽然这很傻逼,但是就是有这个要求)