F1 score on Lesson 1

(Matthew Knippen) #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?


(Matthew Knippen) #2

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_)