from sklearn.datasets import load_breast_cancer from sklearn.linear_model import LogisticRegression from sklearn.metrics import classification_report, roc_auc_score from sklearn.model_selection import train_test_split seed = 188 X, y = load_breast_cancer(return_X_y=True) x_train, x_test, y_train, y_test = train_test_split(X, y, random_state=seed, test_size=0.125) clf = LogisticRegression(penalty='l2', C=1.0, random_state=seed, solver='lbfgs', max_iter=500, multi_class='ovr') clf.fit(x_train, y_train) y_predict = clf.predict(x_test) auc = roc_auc_score(y_predict, y_test) print(classification_report(y_test, y_predict)) print('coef_:\n', clf.coef_[0], '\n', 'interpect_:', clf.intercept_) print('auc score:', auc)
机器学习2
最新推荐文章于 2024-07-18 14:59:12 发布