<reponame>1duo/autokeras
from abc import abstractmethod

from sklearn.metrics import accuracy_score


class Metric:

    @classmethod
    @abstractmethod
    def higher_better(cls):
        pass

    @classmethod
    @abstractmethod
    def compute(cls, prediction, target):
        pass


class Accuracy(Metric):
    @classmethod
    def higher_better(cls):
        return True

    @classmethod
    def compute(cls, prediction, target):
        return accuracy_score(prediction, target)

StarcoderdataPython