pycaret.classification.add_metric#

pycaret.classification.add_metric(id: str, name: str, score_func: type, target: str = 'pred', greater_is_better: bool = True, multiclass: bool = True, **kwargs) Series[source]#

Adds a custom metric to be used in the experiment.

Example

>>> from pycaret.datasets import get_data
>>> juice = get_data('juice')
>>> from pycaret.classification import *
>>> exp_name = setup(data = juice,  target = 'Purchase')
>>> from sklearn.metrics import log_loss
>>> add_metric('logloss', 'Log Loss', log_loss, greater_is_better = False)
id: str

Unique id for the metric.

name: str

Display name of the metric.

score_func: type

Score function (or loss function) with signature score_func(y, y_pred, **kwargs).

target: str, default = ‘pred’

The target of the score function.

  • ‘pred’ for the prediction table

  • ‘pred_proba’ for pred_proba

  • ‘threshold’ for decision_function or predict_proba

greater_is_better: bool, default = True

Whether score_func is higher the better or not.

multiclass: bool, default = True

Whether the metric supports multiclass target.

**kwargs:

Arguments to be passed to score function.

Returns:

pandas.Series