简体   繁体   English

在 sklearn 中使用 cross_val_score 生成负预测值用于模型性能评估

[英]Generate negative predictive value using cross_val_score in sklearn for model performance evaluation

As part of evaluating a model's metrics, I would like to use cross_val_score in sklearn to generate negative predictive value for the model.作为评估模型指标的一部分,我想在 sklearn 中使用 cross_val_score 来为模型生成负预测值。

In example below, I set the 'scoring' parameter within cross_val_score to calculate and print 'precision' (mean and standard deviations from 10-fold cross-validation) for positive predictive value of the model:在下面的示例中,我在 cross_val_score 中设置了“评分”参数来计算和打印模型的阳性预测值的“精度”(10 倍交叉验证的平均值和标准偏差):

from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
log=LogisticRegression()    
log_prec = cross_val_score(log, x, y, cv=10, scoring='precision')
print("PPV(mean, std): ", np.round(log_prec.mean(), 2), np.round(log_prec.std(), 2))

For a binary classification problem you can invert the label definition. 对于二进制分类问题,您可以反转标签定义。 Then the PPV will correspond to the NPV in you original problem 那么PPV将与您原始问题中的NPV相对应

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用joblib重用sklearn中由cross_val_score拟合的模型 - Reusing model fitted by cross_val_score in sklearn using joblib 如何使用 cross_val_score() 保留 kfold 的评估分数 - How to Retain The Evaluation Score of kfold using cross_val_score() 使用sklearn cross_val_score和kfolds来拟合并帮助预测模型 - Using sklearn cross_val_score and kfolds to fit and help predict model 如何使用cross_val_score()Sklearn? - How to use cross_val_score() Sklearn? 在sklearn / keras中使用cross_val_score时的负损失函数。 不使用k折时有效 - Negative Loss function when using cross_val_score in sklearn/keras. Works when not using k fold Sklearn cross_val_score 给出的数字与 model.score 明显不同? - Sklearn cross_val_score gives significantly differnt number than model.score? 无法在 sklearn cross_val_score 上评估 f1-score - Cannot evaluate f1-score on sklearn cross_val_score 支持的目标类型是: ('binary', 'multiclass') error with "cross_val_score" function from sklearn.model_selection - Supported target types are: ('binary', 'multiclass') error with “cross_val_score” function from sklearn.model_selection 在 sklearn.cross_validation 中使用 train_test_split 和 cross_val_score 的区别 - Difference between using train_test_split and cross_val_score in sklearn.cross_validation 在 cross_val_score 中使用 TimeSeriesSplit - Using TimeSeriesSplit within cross_val_score
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM