Skip to content

Commit

Permalink
added sklearn zero one loss
Browse files Browse the repository at this point in the history
  • Loading branch information
Jad-yehya committed Jun 24, 2024
1 parent 87f3ef3 commit d45d390
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

with safe_import_context() as import_ctx:
import numpy as np
from sklearn.metrics import precision_score, recall_score, f1_score
from sklearn.metrics import (
precision_score, recall_score, f1_score, zero_one_loss
)


class Objective(BaseObjective):
Expand Down Expand Up @@ -48,7 +50,8 @@ def get_f1(self, y_hat):
return f1_score(self.y_test, y_hat, zero_division=0)

def get_zoloss(self, y_hat):
return np.sum(y_hat != self.y_test) / len(self.y_test)
# return np.sum(y_hat != self.y_test) / len(self.y_test)
return zero_one_loss(self.y_test, y_hat)

def get_objective(self):
return dict(
Expand Down

0 comments on commit d45d390

Please sign in to comment.