docstr: Adds a custom metric to be used in all functions.
  
  
  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)``.
  
  
  greater_is_better: bool, default = True
      Whether score_func is a score function (default), meaning high is good,
      or a loss function, meaning low is good. In the latter case, the
      scorer object will sign-flip the outcome of the score_func.
  
  
  multiclass: bool, default = True
      Whether the metric supports multiclass problems.
  
  
  **kwargs:
      Arguments to be passed to score function.
  
  Returns:
      pandas.Series
docstr_tok: ["Adds","a","custom","metric","to","be","used","in","all","functions",".","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",")","``",".","greater_is_better",":","bool",",","default","=","True","Whether","score_func","is","a","score","function","(","default",")",",","meaning","high","is","good",",","or","a","loss","function",",","meaning","low","is","good",".","In","the","latter","case",",","the","scorer","object","will","sign-flip","the","outcome","of","the","score_func",".","multiclass",":","bool",",","default","=","True","Whether","the","metric","supports","multiclass","problems",".","*","*","kwargs",":","Arguments","to","be","passed","to","score","function",".","Returns",":","pandas.Series"]
code: def add_metric(
      self,
      id: str,
      name: str,
      score_func: type,
      greater_is_better: bool = True,
      needs_ground_truth: bool = False,
      **kwargs,
  ) -> pd.Series:
      """
      Adds a custom metric to be used in all functions.
  
  
      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)``.
  
  
      greater_is_better: bool, default = True
          Whether score_func is a score function (default), meaning high is good,
          or a loss function, meaning low is good. In the latter case, the
          scorer object will sign-flip the outcome of the score_func.
  
  
      multiclass: bool, default = True
          Whether the metric supports multiclass problems.
  
  
      **kwargs:
          Arguments to be passed to score function.
  
      Returns:
          pandas.Series
  
      """
  
      if not self._setup_ran:
          raise ValueError("setup() needs to be ran first.")
  
      if id in self._all_metrics:
          raise ValueError("id already present in metrics dataframe.")
  
      new_metric = (
          pycaret.containers.metrics.clustering.ClusterMetricContainer(
              id=id,
              name=name,
              score_func=score_func,
              args=kwargs,
              display_name=name,
              greater_is_better=greater_is_better,
              needs_ground_truth=needs_ground_truth,
              is_custom=True,
          )
      )
  
      self._all_metrics[id] = new_metric
  
      new_metric = new_metric.get_dict()
  
      new_metric = pd.Series(
          new_metric, name=id.replace(" ", "_")
      ).drop("ID")
  
      return new_metric
  
imports: from typing import Any, List, Optional, Tuple, Union
  import numpy
  import pandas
  import pycaret.internal.patches.sklearn
  import pycaret.internal.patches.yellowbrick
  import pycaret.internal.persistence
  import pycaret.internal.preprocess
  from pycaret.containers.metrics.clustering import get_all_metric_containers
  from pycaret.containers.models.clustering import get_all_model_containers
  from pycaret.internal.logging import get_logger
  from pycaret.internal.pycaret_experiment.unsupervised_experiment import _UnsupervisedExperiment
  from pycaret.utils.generic import MLUsecase
label_desc: Use image node_id 8 for calling the ClusteringExperiment obj's underlying member method code with example usage: obj.add_metric(id, name, score_func, greater_is_better, needs_ground_truth) and returns: new_metric