code: def _clone_model(self):
      model = clone(self.original_model)
  
      # equivalence between `retrain_from_scratch` and `warm_start`
      if not self.retrain_from_scratch:
          if hasattr(model, "warm_start"):
              model.warm_start = True
              logger.warning(
                  "`retrain_from_scratch=False` sets automatically the parameter `warm_start=True` "
                  "for the given classifier. Please consult the documentation to ensure that the "
                  "`warm_start=True` is applicable in the current context (i.e., for tree-based "
                  "models such as RandomForest, setting `warm_start=True` is not applicable since the "
                  "fit function expects the same dataset and an update/increase in the number of "
                  "estimators - previous fitted estimators will be kept frozen while the new ones "
                  "will be fitted)."
              )
          else:
              logger.warning(
                  "Current classifier does not support `warm_start`. The model will be retrained "
                  "from scratch every iteration."
              )
      else:
          if hasattr(model, "warm_start"):
              model.warm_start = False
              logger.warning(
                  "`retrain_from_scratch=True` sets automatically the parameter `warm_start=False`."
              )
  
      # oob checks
      if self.use_oob:
          if not isinstance(model, RandomForestClassifier):
              raise ValueError(
                  "OOB supported only for RandomForestClassifier. "
                  f"Received a model of type {model.__class__.__name__}"
              )
  
          if self.use_calibration:
              self.use_calibration = False
              logger.warning(
                  "Calibration cannot be used when `use_oob=True`. Setting `use_calibration=False`."
              )
  
          model.oob_score = True
          model.bootstrap = True
          logger.warning(
              "`use_oob=True` sets automatically the classifier parameters `boostrap=True` and `oob_score=True`. "
              "`train_size` and `n_folds` are ignored when `use_oob=True`."
          )
      else:
          if isinstance(model, RandomForestClassifier):
              model.oob_score = False
              logger.warning(
                  "`use_oob=False` sets automatically the classifier parameters `oob_score=False`."
              )
  
      # preds_type checks
      if self.preds_type == "probs":
          # calibrate the model if user specified.
          if self.use_calibration:
              model = CalibratedClassifierCV(
                  base_estimator=model, **self.calibration_kwargs
              )
              logger.warning(
                  "Using calibration to obtain the prediction probabilities."
              )
  
          # check if it has predict proba. Cannot be checked via `hasattr` due to the same issue in SVC (see below)
          has_predict_proba = self._has_predict_proba(model)
  
          # if the binarize_preds=True, we don't really need the probabilities as in test_probs will be rounded
          # to the closest integer (i.e., to 0 or 1) according to the predicted probability. Thus, we can define
          # a hard label predict_proba based on the predict method
          if self.binarize_preds and (not has_predict_proba):
              if not hasattr(model, "predict"):
                  raise AttributeError(
                      "Trying to use a model which does not support `predict`."
                  )
  
              def predict_proba(self, X):
                  return np.eye(2)[self.predict(X).astype(np.int32)]
  
              # add predict_proba method. Overwriting predict_proba is not possible for SVC due
              # to @available_if(_check_proba)
              # Check link: https://github.com/scikit-learn/scikit-learn/blob/7e1e6d09b/sklearn/svm/_base.py#L807
              setattr(
                  model,
                  "aux_predict_proba",
                  partial(predict_proba, model),
              )
          elif has_predict_proba:
              setattr(model, "aux_predict_proba", model.predict_proba)
  
          # at this point the model does not have any predict_proba, thus the test can not be performed.
          if not hasattr(model, "aux_predict_proba"):
              raise AttributeError(
                  "Trying to use a model which does not support `predict_proba` with "
                  "`preds_type='probs'`. Set (`use_calibration=True`, `calibration_kwargs`) or "
                  "(`binarize_preds=True`)."
              )
  
      else:
          if self.use_calibration:
              logger.warning(
                  "No calibration is performed when `preds_type='scores'`."
              )
  
          if self.binarize_preds:
              raise ValueError(
                  "`binarize_preds` must be `False` when `preds_type='scores'`."
              )
  
          if not hasattr(model, "decision_function"):
              raise AttributeError(
                  "Trying to use a model which does not support `decision_function` with "
                  "`preds_type='scores'`."
              )
  
          # need to put the scores in the format expected by test function, which requires to duplicate the
          # scores along axis=1
          def predict_proba(self, X):
              scores = self.decision_function(X).reshape(-1, 1)
              return np.tile(scores, reps=2)
  
          # add predict_proba method
          setattr(
              model, "aux_predict_proba", partial(predict_proba, model)
          )
  
      return model
  
file_path: alibi-detect/alibi_detect/cd/sklearn/classifier.py
imports: import logging
  import numpy
  from functools import partial
  from typing import Callable, Dict, Optional, Tuple, Union
  from sklearn.base import clone, ClassifierMixin
  from sklearn.calibration import CalibratedClassifierCV
  from sklearn.exceptions import NotFittedError
  from sklearn.ensemble import RandomForestClassifier
  from alibi_detect.cd.base import BaseClassifierDrift
  from alibi_detect.utils.warnings import deprecated_alias
  from alibi_detect.utils.frameworks import Framework
label_desc: Use image node_id 3 for calling the ClassifierDriftSklearn obj's underlying member method code with example usage: obj._clone_model() and returns: model, np, np