给我一个python logistic回归代码示例
时间: 2023-03-14 12:29:45 浏览: 94
Python语言描述机器学习之Logistic回归算法
import numpy as np
from sklearn.linear_model import LogisticRegression
# training data
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 0, 0, 1])
# create and train model
model = LogisticRegression()
model.fit(X, y)
# predict
predictions = model.predict(X)
# results
print(predictions)
#[0 0 0 1]
阅读全文