output F1-score instead of Accuracy

I have the code below outputting the accuracy. How can I output the F1-score instead?

 clf.fit(data_train,target_train)  
preds = clf.predict(data_test)  
# accuracy for the current fold only     
r2score = clf.score(data_test,target_test)

Topic f1score classifier accuracy

Category Data Science


You can use sklearn f1 score metric.

from sklearn.metrics import f1_score
f1_score(y_true, y_pred)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.