In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to use 4 samples to draw the ROC curve. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
ROC curve, as an important curve to evaluate the sensitivity of machine learning model, is widely used in classification task evaluation mechanism.
But many friends still have a vague understanding of the ROC curve, thinking that the x-axis is FPR, the y-axis is TPR, and the group curve is somewhat mysterious.
Today, we use four samples and use logical regression to calculate the FRP and TPR values of the corresponding classification thresholds from 0.2 to 0.8 respectively from 0.2 to 0.8 respectively.
In this way, you will get 6 (FRP,TPR) points and form a curve, which is not a ROC curve.
# there is a supervisory task, and the actual values of the four samples:
Target = np.array ([1pc0pl 1p0pl])
Calculation formula:
Def TPR (TP,FN):
Return TP / (TP + FN)
Def FPR (FP,TN):
Return FP / (FP + TN)
By using logical regression Logistic regression, the probability distributions of four samples are obtained as follows: [0.8, 0.6, 0.4, 0.2]
When the classification threshold parameter alpha is 0.0:
Y0 = np.array ([1pm 1pm 1pm 1])
P00 = [TPR (2jin0), FPR (2jin0)]
P00
Results:
[1.0, 1.0]
When the classification threshold parameter alpha is 0.2:
# similarly, if the classification threshold alpha = 0.2,
#
Y02 = np.array ([1pm 1pm 1pm 1])
P02 = [TPR (2jin0), FPR (2jin0)]
P02
Results:
[1.0, 1.0]
When the classification threshold parameter alpha is 0.4:
Target = np.array ([1pc0pl 1p0pl])
Y04 = np.array ([1pm 1pm 1pm 0])
P04 = [TPR (2jin0), FPR (1pjin1)]
P04
Results:
[1.0, 0.5]
When the classification threshold parameter alpha is 0.6:
# similarly, if the classification threshold alpha = 0.6
#
Target = np.array ([1pc0pl 1p0pl])
Y06 = np.array ([1, 1, 1, 1, 0, 0])
P06 = [TPR (1), FPR (1)]
P06
Results:
[0.5, 0.5]
When the classification threshold parameter alpha is 0.8:
# similarly, if the classification threshold alpha = 0.8
#
Target = np.array ([1pc0pl 1p0pl])
Y08 = np.array ([1pc0p0p0p0p0pl])
P08 = [TPR (1), FPR (0)]
P08
Results:
[0.5, 0.0]
When the classification threshold parameter alpha is 1.0:
# similarly, if the classification threshold alpha = 1.0,
#
Target = np.array ([1pc0pl 1p0pl])
Y10 = np.array ([01990p0p0p0p0p0])
P10 = [TPR (0Jing 2), FPR (0Jing 2)]
P10
Results:
[0.0, 0.0]
Draw the above 6 points to get the ROC curve:
Npxy = np.array (xy)
Fpr = npxy [:, 1]
Tpr = npxy [:, 0]
Plt.scatter (fpr,tpr)
Plt.plot (fpr,tpr)
Plt.grid ()
Alphas = [0.010, 0.2, 0.4, 0.6, 0.8, 1.0]
For alpha,x,y in zip (alphas,fpr,tpr):
Plt.annotate ("alpha=%s"% (alpha,), xy= (xQuery), xytext= (- 20,10), textcoords='offset points')
The above is the editor for you to share how to use 4 samples to draw the ROC curve, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.