shenweichen / DeepCTR

Easy-to-use,Modular and Extendible package of deep-learning based CTR models .
https://deepctr-doc.readthedocs.io/en/latest/index.html
Apache License 2.0
7.54k stars 2.21k forks source link

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

Open CFZhai opened 11 months ago

CFZhai commented 11 months ago

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

CFZhai commented 11 months ago

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_