2.1. Exercises
Letβs Calculate

For the next few questions, use the confusion matrix above and assume that Forward is the positive label.
True or False: Measurements
Using Sklearn to Obtain Different Measurements
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line wonβt execute and you can test your code after each step.
Letβs calculate some measurements from our basketball dataset from the previous question.
Tasks:
- Import the precision, recall, f1 and classification report libraries.
- Predict the values on
X_validusing thepipe_unbalancedand the.predict()function and save the result in an object namedpredicted_y. - Using sklearn tools, calculate precision, recall and f1 scores and save them in the respective names
precision,recall, andf1. Make sure you are comparing the truey_validlabels to the predicted labels. You will need to assign a positive label to the βForwardβ(F) position. This can be specified in thepos_labelof each function. Round each calculation to 3 decimal places. - Print a classification report of all the measurements comparing
y_validandpredicted_yand assigning thetarget_namesargument to["F", "G"]. You can use thedigitsfunction to round all the calculations to 3 decimal places.