code_7.py 349 字节
Newer Older
ToTensor's avatar
ToTensor 已提交
1 2 3 4 5
from sklearn.linear_model import Logistic Regression # 导入逻辑回归模型
lr = Logistic Regression(penalty='l2', C = 0.1) # 设定L2正则化和C参数
lr.fit(X_train_sepal, y_train_sepal) # 训练机器
score = lr.score(X_test_sepal, y_test_sepal) # 验证集分数评估
print("SKlearn逻辑回归测试准确率 {:.2f}%".format(score*100))