绘制预测曲线
predictiveness-curve的Python项目详细描述
预测性曲线
什么是预测曲线?
预测曲线是同时显示两个图形的一种方法。在这两个数字中,X轴是风险百分位数,一个图的y轴是风险的值,另一个图的y轴是真正分数。这使得我们能够直观地看到风险模型是否适合医学领域,以及应该使用哪个风险值作为模型的基础。有关详细信息,请参见Am. J. Epidemiol. 2008; 167:362–368。
安装
此模块实现绘制Predictiveness Curve
的函数。
安装时使用:
pip install predictiveness-curve
示例
frompredictiveness_curveimportplot_predictiveness_curvefromsklearn.datasetsimportload_breast_cancerfromsklearn.ensembleimportRandomForestClassifierfromsklearn.model_selectionimporttrain_test_splitdata=load_breast_cancer()y=data.targetX=data.datatraining_X,test_X,training_y,test_y=train_test_split(X,y,test_size=0.5,random_state=42)clsf=RandomForestClassifier(n_estimators=100,random_state=42)clsf.fit(training_X,training_y)probabilities=clsf.predict_proba(test_X)[:,1]plot_predictiveness_curve(probabilities,test_y)