Question: In python using Numpy only this is a sample output I guess to calculate F1 using this formula, where P and R and Precision and

In python using Numpy only
this is a sample output


I guess to calculate F1 using this formula, where P and R and Precision and Recall.

def calculate_f1(actuals, predictions): (3 pts) This function calculates the F1 for a binary classifiers predictions. It receives two 1-D numpy arrays actuals and predictions, and returns one number which is the recall. (range 0-1) NOTE: use ZEROS to indicate negative Labels/predictions. Parameters: actuals: 1-D numpy array with ACTUAL Labels (either 0 = negative, or 1 = positive) predictions: 1-D numpy array with PREDICTED labels (either 0 = negative, or 1 = positive) return None In [10]: test_actual = np.array([1, 1, -1, -1, 1]) In [11]: test_predictions np.array([1, 1, 1, 1, 1]) In [14]: thw.calculateF1(test_actual, test_predictions) Out[14]: 0.7499999999999999 Balanced F1 measure F1 2 * P* R P + R
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
