docstr: This function trains and evaluates the performance of a given model.
  Metrics evaluated can be accessed using the ``get_metrics`` function.
  Custom metrics can be added or removed using the ``add_metric`` and
  ``remove_metric`` function. All the available models can be accessed
  using the ``models`` function.
  
  
  Example
  -------
  >>> from pycaret.datasets import get_data
  >>> jewellery = get_data('jewellery')
  >>> from pycaret.clustering import *
  >>> exp_name = setup(data = jewellery)
  >>> kmeans = create_model('kmeans')
  
  
  model: str or scikit-learn compatible object
      ID of an model available in the model library or pass an untrained
      model object consistent with scikit-learn API. Models available
      in the model library (ID - Name):
  
      * 'kmeans' - K-Means Clustering
      * 'ap' - Affinity Propagation
      * 'meanshift' - Mean shift Clustering
      * 'sc' - Spectral Clustering
      * 'hclust' - Agglomerative Clustering
      * 'dbscan' - Density-Based Spatial Clustering
      * 'optics' - OPTICS Clustering
      * 'birch' - Birch Clustering
      * 'kmodes' - K-Modes Clustering
  
  
  num_clusters: int, default = 4
      The number of clusters to form.
  
  
  ground_truth: str, default = None
      ground_truth to be provided to evaluate metrics that require true labels.
      When None, such metrics are returned as 0.0. All metrics evaluated can
      be accessed using ``get_metrics`` function.
  
  
  round: int, default = 4
      Number of decimal places the metrics in the score grid will be rounded to.
  
  
  fit_kwargs: dict, default = {} (empty dict)
      Dictionary of arguments passed to the fit method of the model.
  
  
  verbose: bool, default = True
      Status update is not printed when verbose is set to False.
  
  
  engine: Optional[str] = None
      The execution engine to use for the model, e.g. for K-Means Clustering ("kmeans"), users can
      switch between "sklearn" and "sklearnex" by specifying
      `engine="sklearnex"`.
  
  
  experiment_custom_tags: dict, default = None
      Dictionary of tag_name: String -> value: (String, but will be string-ified
      if not) passed to the mlflow.set_tags to add new custom tags for the experiment.
  
  
  **kwargs:
      Additional keyword arguments to pass to the estimator.
  
  
  Returns:
      Trained Model
  
  
  Warnings
  --------
  - ``num_clusters`` param not required for Affinity Propagation ('ap'),
  Mean shift ('meanshift'), Density-Based Spatial Clustering ('dbscan')
  and OPTICS Clustering ('optics').
  
  - When fit doesn't converge in Affinity Propagation ('ap') model, all
  datapoints are labelled as -1.
  
  - Noisy samples are given the label -1, when using Density-Based Spatial
  ('dbscan') or OPTICS Clustering ('optics').
  
  - OPTICS ('optics') clustering may take longer training times on large
  datasets.
docstr_tok: ["This","function","trains","and","evaluates","the","performance","of","a","given","model",".","Metrics","evaluated","can","be","accessed","using","the","``","get_metrics","``","function",".","Custom","metrics","can","be","added","or","removed","using","the","``","add_metric","``","and","``","remove_metric","``","function",".","All","the","available","models","can","be","accessed","using","the","``","models","``","function",".","Example","--","--","--","-",">",">",">","from","pycaret.datasets","import","get_data",">",">",">","jewellery","=","get_data","(","'jewellery","'",")",">",">",">","from","pycaret.clustering","import","*",">",">",">","exp_name","=","setup","(","data","=","jewellery",")",">",">",">","kmeans","=","create_model","(","'kmeans","'",")","model",":","str","or","scikit-learn","compatible","object","ID","of","an","model","available","in","the","model","library","or","pass","an","untrained","model","object","consistent","with","scikit-learn","API",".","Models","available","in","the","model","library","(","ID","-","Name",")",":","*","'kmeans","'","-","K-Means","Clustering","*","'ap","'","-","Affinity","Propagation","*","'meanshift","'","-","Mean","shift","Clustering","*","'sc","'","-","Spectral","Clustering","*","'hclust","'","-","Agglomerative","Clustering","*","'dbscan","'","-","Density-Based","Spatial","Clustering","*","'optics","'","-","OPTICS","Clustering","*","'birch","'","-","Birch","Clustering","*","'kmodes","'","-","K-Modes","Clustering","num_clusters",":","int",",","default","=","4","The","number","of","clusters","to","form",".","ground_truth",":","str",",","default","=","None","ground_truth","to","be","provided","to","evaluate","metrics","that","require","true","labels",".","When","None",",","such","metrics","are","returned","as","0.0",".","All","metrics","evaluated","can","be","accessed","using","``","get_metrics","``","function",".","round",":","int",",","default","=","4","Number","of","decimal","places","the","metrics","in","the","score","grid","will","be","rounded","to",".","fit_kwargs",":","dict",",","default","=","{","}","(","empty","dict",")","Dictionary","of","arguments","passed","to","the","fit","method","of","the","model",".","verbose",":","bool",",","default","=","True","Status","update","is","not","printed","when","verbose","is","set","to","False",".","engine",":","Optional","[","str","]","=","None","The","execution","engine","to","use","for","the","model",",","e.g",".","for","K-Means","Clustering","(","``","kmeans","''",")",",","users","can","switch","between","``","sklearn","''","and","``","sklearnex","''","by","specifying","`","engine=","''","sklearnex","''","`",".","experiment_custom_tags",":","dict",",","default","=","None","Dictionary","of","tag_name",":","String","-",">","value",":","(","String",",","but","will","be","string-ified","if","not",")","passed","to","the","mlflow.set_tags","to","add","new","custom","tags","for","the","experiment",".","*","*","kwargs",":","Additional","keyword","arguments","to","pass","to","the","estimator",".","Returns",":","Trained","Model","Warnings","--","--","--","--","-","``","num_clusters","``","param","not","required","for","Affinity","Propagation","(","'ap","'",")",",","Mean","shift","(","'meanshift","'",")",",","Density-Based","Spatial","Clustering","(","'dbscan","'",")","and","OPTICS","Clustering","(","'optics","'",")",".","-","When","fit","does","n't","converge","in","Affinity","Propagation","(","'ap","'",")","model",",","all","datapoints","are","labelled","as","-1",".","-","Noisy","samples","are","given","the","label","-1",",","when","using","Density-Based","Spatial","(","'dbscan","'",")","or","OPTICS","Clustering","(","'optics","'",")",".","-","OPTICS","(","'optics","'",")","clustering","may","take","longer","training","times","on","large","datasets","."]
code: def create_model(
      self,
      estimator,
      num_clusters: int = 4,
      fraction: float = 0.05,
      ground_truth: Optional[str] = None,
      round: int = 4,
      fit_kwargs: Optional[dict] = None,
      experiment_custom_tags: Optional[Dict[str, Any]] = None,
      engine: Optional[str] = None,
      verbose: bool = True,
      **kwargs,
  ) -> Any:
      """
      This function trains and evaluates the performance of a given model.
      Metrics evaluated can be accessed using the ``get_metrics`` function.
      Custom metrics can be added or removed using the ``add_metric`` and
      ``remove_metric`` function. All the available models can be accessed
      using the ``models`` function.
  
  
      Example
      -------
      >>> from pycaret.datasets import get_data
      >>> jewellery = get_data('jewellery')
      >>> from pycaret.clustering import *
      >>> exp_name = setup(data = jewellery)
      >>> kmeans = create_model('kmeans')
  
  
      model: str or scikit-learn compatible object
          ID of an model available in the model library or pass an untrained
          model object consistent with scikit-learn API. Models available
          in the model library (ID - Name):
  
          * 'kmeans' - K-Means Clustering
          * 'ap' - Affinity Propagation
          * 'meanshift' - Mean shift Clustering
          * 'sc' - Spectral Clustering
          * 'hclust' - Agglomerative Clustering
          * 'dbscan' - Density-Based Spatial Clustering
          * 'optics' - OPTICS Clustering
          * 'birch' - Birch Clustering
          * 'kmodes' - K-Modes Clustering
  
  
      num_clusters: int, default = 4
          The number of clusters to form.
  
  
      ground_truth: str, default = None
          ground_truth to be provided to evaluate metrics that require true labels.
          When None, such metrics are returned as 0.0. All metrics evaluated can
          be accessed using ``get_metrics`` function.
  
  
      round: int, default = 4
          Number of decimal places the metrics in the score grid will be rounded to.
  
  
      fit_kwargs: dict, default = {} (empty dict)
          Dictionary of arguments passed to the fit method of the model.
  
  
      verbose: bool, default = True
          Status update is not printed when verbose is set to False.
  
  
      engine: Optional[str] = None
          The execution engine to use for the model, e.g. for K-Means Clustering ("kmeans"), users can
          switch between "sklearn" and "sklearnex" by specifying
          `engine="sklearnex"`.
  
  
      experiment_custom_tags: dict, default = None
          Dictionary of tag_name: String -> value: (String, but will be string-ified
          if not) passed to the mlflow.set_tags to add new custom tags for the experiment.
  
  
      **kwargs:
          Additional keyword arguments to pass to the estimator.
  
  
      Returns:
          Trained Model
  
  
      Warnings
      --------
      - ``num_clusters`` param not required for Affinity Propagation ('ap'),
      Mean shift ('meanshift'), Density-Based Spatial Clustering ('dbscan')
      and OPTICS Clustering ('optics').
  
      - When fit doesn't converge in Affinity Propagation ('ap') model, all
      datapoints are labelled as -1.
  
      - Noisy samples are given the label -1, when using Density-Based Spatial
      ('dbscan') or OPTICS Clustering ('optics').
  
      - OPTICS ('optics') clustering may take longer training times on large
      datasets.
  
  
      """
  
      # TODO improve error message
      assert not any(
          x
          in (
              "system",
              "add_to_model_list",
              "raise_num_clusters",
              "X_data",
              "metrics",
          )
          for x in kwargs
      )
      if engine is not None:
          # Save current engines, then set to user specified options
          initial_default_model_engines = self.exp_model_engines.copy()
          self._set_engine(
              estimator=estimator, engine=engine, severity="error"
          )
  
      try:
          return_values = self._create_model(
              estimator=estimator,
              num_clusters=num_clusters,
              fraction=fraction,
              ground_truth=ground_truth,
              round=round,
              fit_kwargs=fit_kwargs,
              experiment_custom_tags=experiment_custom_tags,
              verbose=verbose,
              **kwargs,
          )
      finally:
          if engine is not None:
              # Reset the models back to the default engines
              self._set_exp_model_engines(
                  container_default_engines=get_container_default_engines(),
                  engine=initial_default_model_engines,
              )
  
      return return_values
  
imports: import datetime
  import gc
  import logging
  import time
  import traceback
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import pandas
  from joblib.memory import Memory
  from sklearn.base import clone
  from pycaret.containers.metrics.clustering import get_all_metric_containers
  from pycaret.containers.models.clustering import ALL_ALLOWED_ENGINES, get_container_default_engines
  from pycaret.internal.display import CommonDisplay
  from pycaret.internal.logging import get_logger, redirect_output
  from pycaret.internal.pipeline import Pipeline
  from pycaret.internal.pipeline import estimator_pipeline, get_pipeline_fit_kwargs
  from pycaret.internal.preprocess.preprocessor import Preprocessor
  from pycaret.internal.pycaret_experiment.tabular_experiment import _TabularExperiment
  from pycaret.internal.validation import is_sklearn_pipeline
  from pycaret.loggers.base_logger import BaseLogger
  from pycaret.utils.constants import DATAFRAME_LIKE, SEQUENCE_LIKE
  from pycaret.utils.generic import MLUsecase, highlight_setup
label_desc: Use image node_id 9 for calling the _UnsupervisedExperiment obj's underlying member method code with example usage: obj.create_model(estimator, num_clusters, fraction, ground_truth, round, fit_kwargs, experiment_custom_tags, engine, verbose) and returns: return_values