import matplotlib.pyplot as plt precision = [0.5, 0.50684932, 0.51388889, 0.52112676, 0.52857143, 0.53623188, 0.54411765, 0.55223881, 0.56060606, 0.56923077, 0.578125, 0.58730159, 0.59677419, 0.60655738, 0.61666667, 0.62711864, 0.63793103, 0.64912281, 0.66071429, 0.67272727, 0.68518519, 0.69811321, 0.71153846, 0.7254902, 0.74, 0.75510204, 0.77083333, 0.78723404, 0.80434783, 0.82222222, 0.84090909, 0.86046512, 0.88095238, 0.87804878, 0.9 , 0.92307692, 0.94736842, 0.94594595, 0.94444444, 0.94285714, 0.94117647, 0.93939394, 0.9375, 0.93548387, 0.96666667, 0.96551724, 0.96428571, 0.96296296, 0.96153846, 0.96, 0.95833333, 0.95652174, 0.95454545, 0.95238095, 0.95, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] recall =[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.97297297, 0.97297297, 0.97297297, 0.97297297, 0.94594595, 0.91891892, 0.89189189, 0.86486486, 0.83783784, 0.81081081, 0.78378378, 0.78378378, 0.75675676, 0.72972973, 0.7027027, 0.67567568, 0.64864865, 0.62162162, 0.59459459, 0.56756757, 0.54054054, 0.51351351, 0.51351351, 0.48648649, 0.45945946, 0.43243243, 0.40540541, 0.37837838, 0.35135135, 0.32432432, 0.2972973, 0.27027027, 0.24324324, 0.21621622, 0.18918919, 0.16216216, 0.13513514, 0.10810811, 0.08108108, 0.05405405, 0] thresholds = [0.05392042, 0.05747761, 0.08795847, 0.09711715, 0.10836032, 0.1201096, 0.12746203 ,0.14044166 ,0.14357233, 0.1931704, 0.19408794, 0.22400858, 0.22726139 ,0.23303272 ,0.25124016, 0.26014023, 0.26981908, 0.27072288, 0.27109875 ,0.28445365 ,0.28548161, 0.28880253, 0.30126451, 0.30273324, 0.3068595 ,0.31269419 ,0.33400304, 0.35578062, 0.37101008, 0.38200717, 0.38539771 ,0.38972295 ,0.39294773, 0.40920107, 0.4121291, 0.4369997, 0.44255718 ,0.44256915 ,0.46214362, 0.46447274, 0.46686736, 0.46977465, 0.47523671 ,0.47777227 ,0.48489664, 0.48920359, 0.52904117, 0.53225221, 0.53416311 ,0.54550706 ,0.55801574, 0.57259243, 0.57398918, 0.5908601, 0.60177331 ,0.60481593 ,0.61276247 ,0.62152893, 0.62966217, 0.64346738, 0.64541498 ,0.64878433 ,0.65476345, 0.65665078, 0.67432673, 0.67492593, 0.68424871 ,0.68872306 ,0.70297847 ,0.70474923,0.72355252, 0.7291418, 0.79367824, 1.0] print(len(precision), len(recall), len(thresholds)) plt.figure(figsize=(10, 8)) plt.plot(recall, precision, label='Precision-Recall curve') plt.xlabel('Recall') plt.ylabel('Precision') plt.title('Precision-Recall Curve') plt.legend(loc='best') plt.grid(True) # 显示图例 plt.legend() # 显示图表 plt.show()