DeepCTR icon indicating copy to clipboard operation
DeepCTR copied to clipboard

How to self define metric instead of using one of the pre-defined metrics

Open CFZhai opened this issue 1 year ago • 1 comments

How to self define metric instead of using one of the pre-defined metrics

CFZhai avatar Oct 21 '23 21:10 CFZhai

or how to add a sklearn metric into

def _get_metrics(self, metrics, set_eps=False):
    metrics_ = {}
    if metrics:
        for metric in metrics:
            if metric == "binary_crossentropy" or metric == "logloss":
                if set_eps:
                    metrics_[metric] = self._log_loss
                else:
                    metrics_[metric] = log_loss
            if metric == "auc":
                metrics_[metric] = roc_auc_score
            if metric == "mse":
                metrics_[metric] = mean_squared_error
            if metric == "accuracy" or metric == "acc":
                metrics_[metric] = self._accuracy_score
            self.metrics_names.append(metric)
    return metrics_

CFZhai avatar Oct 21 '23 21:10 CFZhai