class_docstr: Context which fits an estimator if it's not fitted.
class_docstr_tok: ["Context","which","fits","an","estimator","if","it","'s","not","fitted","."]
code: def __init__(
      self,
      estimator,
      X_train: pd.DataFrame,
      y_train: pd.DataFrame,
      groups=None,
      **fit_kwargs,
  ):
      logger = get_logger()
      self.estimator = deepcopy(estimator)
      if not is_fitted(self.estimator):
          if not is_fitted(self.estimator):
              logger.info(
                  f"fit_if_not_fitted: {estimator} is not fitted, fitting"
              )
              try:
                  self.estimator.fit(
                      X_train, y_train, groups=groups, **fit_kwargs
                  )
              except Exception:
                  self.estimator.fit(X_train, y_train, **fit_kwargs)
  
file_path: pycaret/pycaret/internal/validation.py
imports: from copy import deepcopy
  import pandas
  from sklearn.pipeline import Pipeline
  from sklearn.utils.validation import check_is_fitted
  from pycaret.internal.logging import get_logger
label_desc: Use image node_id 1 to create a new fit_if_not_fitted object from inherited base classes: object with example: obj = fit_if_not_fitted(estimator, X_train, y_train, groups)