docstr: This function assigns cluster labels to the dataset for a given model.
  
  
  Example
  -------
  >>> from pycaret.datasets import get_data
  >>> jewellery = get_data('jewellery')
  >>> from pycaret.clustering import *
  >>> exp_name = setup(data = jewellery)
  >>> kmeans = create_model('kmeans')
  >>> kmeans_df = assign_model(kmeans)
  
  
  
  model: scikit-learn compatible object
      Trained model object
  
  
  transformation: bool, default = False
      Whether to apply cluster labels on the transformed dataset.
  
  
  verbose: bool, default = True
      Status update is not printed when verbose is set to False.
  
  
  Returns:
      pandas.DataFrame
docstr_tok: ["This","function","assigns","cluster","labels","to","the","dataset","for","a","given","model",".","Example","--","--","--","-",">",">",">","from","pycaret.datasets","import","get_data",">",">",">","jewellery","=","get_data","(","'jewellery","'",")",">",">",">","from","pycaret.clustering","import","*",">",">",">","exp_name","=","setup","(","data","=","jewellery",")",">",">",">","kmeans","=","create_model","(","'kmeans","'",")",">",">",">","kmeans_df","=","assign_model","(","kmeans",")","model",":","scikit-learn","compatible","object","Trained","model","object","transformation",":","bool",",","default","=","False","Whether","to","apply","cluster","labels","on","the","transformed","dataset",".","verbose",":","bool",",","default","=","True","Status","update","is","not","printed","when","verbose","is","set","to","False",".","Returns",":","pandas.DataFrame"]
code: def assign_model(
      self,
      model,
      transformation: bool = False,
      score: bool = True,
      verbose: bool = True,
  ) -> pd.DataFrame:
      """
      This function assigns cluster labels to the dataset for a given model.
  
  
      Example
      -------
      >>> from pycaret.datasets import get_data
      >>> jewellery = get_data('jewellery')
      >>> from pycaret.clustering import *
      >>> exp_name = setup(data = jewellery)
      >>> kmeans = create_model('kmeans')
      >>> kmeans_df = assign_model(kmeans)
  
  
  
      model: scikit-learn compatible object
          Trained model object
  
  
      transformation: bool, default = False
          Whether to apply cluster labels on the transformed dataset.
  
  
      verbose: bool, default = True
          Status update is not printed when verbose is set to False.
  
  
      Returns:
          pandas.DataFrame
  
      """
  
      function_params_str = ", ".join(
          [f"{k}={v}" for k, v in locals().items()]
      )
  
      self.logger.info("Initializing assign_model()")
      self.logger.info(f"assign_model({function_params_str})")
  
      self.logger.info("Checking exceptions")
  
      # checking transformation parameter
      if type(transformation) is not bool:
          raise TypeError(
              "Transformation parameter can only take argument as True or False."
          )
  
      # checking verbose parameter
      if type(verbose) is not bool:
          raise TypeError(
              "Verbose parameter can only take argument as True or False."
          )
  
      """
          error handling ends here
          """
  
      if is_sklearn_pipeline(model):
          model = model.steps[-1][1]
  
      self.logger.info("Determining Trained Model")
  
      name = self._get_model_name(model)
  
      self.logger.info(f"Trained Model : {name}")
  
      self.logger.info("Copying data")
      # copy data_
      if transformation:
          data = self.X_transformed.copy()
          self.logger.info(
              "Transformation parameter set to True. Assigned clusters are attached on transformed dataset."
          )
      else:
          data = self.X.copy()
  
      # calculation labels and attaching to dataframe
  
      if self._ml_usecase == MLUsecase.CLUSTERING:
          labels = [f"Cluster {i}" for i in model.labels_]
          data["Cluster"] = labels
      else:
          data["Anomaly"] = model.labels_
          if score:
              data["Anomaly_Score"] = model.decision_scores_
  
      self.logger.info(data.shape)
      self.logger.info(
          "assign_model() successfully completed......................................"
      )
  
      return data
  
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 6 for calling the _UnsupervisedExperiment obj's underlying member method code with example usage: obj.assign_model(model, transformation, score, verbose) and returns: data