import numpy as np
from sklearn.linear_model import LogisticRegression
X = np.array([
[60],
[20],
[30],
[80],
[59],
[90]
])
y = np.array([1, 0, 0, 1, 0, 1])
df = LogisticRegression()
df.fit(X, y)
X_test = np.array([
[62],
[87],
[39],
[45]
])
y_predict = df.predict(X_test)
print(y_predict)
完整代码
import numpy as np
from sklearn.linear_model import LogisticRegression
X = np.array([
[60],
[20],
[30],
[80],
[59],
[90]
])
y = np.array([1, 0, 0, 1, 0, 1])
df = LogisticRegression()
df.fit(X, y)
X_test = np.array([
[62],
[87],
[39],
[45]
])
y_predict = df.predict(X_test)
print(y_predict)