F1 score on Lesson 1

I’m trying to do a modified version of the ml1 bulldozer set, only I have uneven data. Instead of using rmse, it would be great to use an F1 score. How would I go about doing something like that?


I ended up solving the problem. sklearn.metrics has f1 score built in. I created a method similar to print_score that does a f1 score instead. Attaching in case someone else needs it.

def print_f1_score(m):
res = [metrics.f1_score(m.predict(X_train), y_train), metrics.f1_score(m.predict(X_valid), y_valid),
            m.score(X_train, y_train), m.score(X_valid, y_valid)]
if hasattr(m, 'oob_score_'): res.append(m.oob_score_)
1 Like

How to find classification report like F1 score and precision recall in this after confusion matrix