通过交叉验证拟合逻辑回归模型

时间:2019-05-21 14:42:54

标签: python pandas scikit-learn logistic-regression cross-validation

我想通过交叉验证评估Logistic回归。 我是这样做的:

from sklearn.preprocessing import StandardScaler
from sklearn import preprocessing
from sklearn.metrics import classification_report
from sklearn.model_selection import cross_val_predict
X = preprocessing.normalize(X)
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=0)
model = LogisticRegression(class_weight= 'balanced')
print(cross_val_score(model, X, y, cv=5, scoring='roc_auc').mean())
model.fit(X_train, y_train)
predicted = cross_val_predict(model, X, y, cv=5)
report = classification_report(y, predicted)
print(report)

如何通过交叉验证对我的逻辑回归模型进行分类报告。

0 个答案:

没有答案