Uploaded by Shen Zhang

ELEC 5307 Lab Week 2 Supplementary

advertisement
ELEC 5307 Lab Week 1
Supplementary
Key Points
• Syntex rules
• Built-in datatypes
• Flow control
• Function
• Class
• Code style
HINT
https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html
EXAMPLE
• Step 1: order the scores descending (because you want the recall to increase with
each step instead of decrease):
y_scores = [0.8, 0.4, 0.35, 0.1]
y_true = [1, 0, 1, 0]
• Step 2: calculate the precision and recall-(recall at n-1) for each threshhold. Note
that the the point at the threshold is included, e.g. for threshold=0.35 the points
that will be classified as 1 (positive) are [1, 0, 1]:
precision = [1, 1/2, 2/3, 2/4]
recall = [1/2, 1/2, 1, 1]
recall-(recall at n-1) = [1/2-0, 1/2-1/2, 1-1/2, 1-1] = [1/2, 0, 1/2, 0]
• Step 3: build the sum for each index of precision and recall-(recall at n-1):
1*1/2+1/2*0+2/3*1/2+2/4*0 = 1/2+2/6 = 5/6 = 0.83...
Download