class_docstr: Fit and predict one or more estimators on one or more datasets.
class_docstr_tok: ["Fit","and","predict","one","or","more","estimators","on","one","or","more","datasets","."]
docstr: Fit and predict.
docstr_tok: ["Fit","and","predict","."]
code: def fit_predict(
      self,
      overwrite_predictions=False,
      predict_on_train=False,
      save_fitted_strategies=True,
      overwrite_fitted_strategies=False,
      verbose=False,
  ):
      """Fit and predict."""
      # check that for fitted strategies overwrite option is only set when
      # save option is set
      if overwrite_fitted_strategies and not save_fitted_strategies:
          raise ValueError(
              f"Can only overwrite fitted strategies "
              f"if fitted strategies are saved, but found: "
              f"overwrite_fitted_strategies="
              f"{overwrite_fitted_strategies} and "
              f"save_fitted_strategies="
              f"{save_fitted_strategies}"
          )
  
      # fitting and prediction
      for (
          task,
          dataset,
          data,
          strategy,
          cv_fold,
          train_idx,
          test_idx,
      ) in self._iter():
          # check which results already exist
          train_pred_exist = self.results.check_predictions_exist(
              strategy.name,
              dataset.name,
              cv_fold,
              train_or_test="train",
          )
          test_pred_exist = self.results.check_predictions_exist(
              strategy.name, dataset.name, cv_fold, train_or_test="test"
          )
          fitted_strategy_exists = (
              self.results.check_fitted_strategy_exists(
                  strategy.name, dataset.name, cv_fold
              )
          )
  
          # skip if overwrite is set to False for both predictions and
          # strategies and all results exist
          if (
              not overwrite_predictions
              and test_pred_exist
              and (train_pred_exist or not predict_on_train)
              and not overwrite_fitted_strategies
              and (fitted_strategy_exists or not save_fitted_strategies)
          ):
              log.warn(
                  f"Skipping strategy: {strategy.name} on CV-fold: "
                  f"{cv_fold} of dataset: {dataset.name}"
              )
              continue
  
          # split data into training and test sets
          train = data.iloc[train_idx]
          test = data.iloc[test_idx]
  
          # fit strategy
          self._print_progress(
              dataset.name,
              strategy.name,
              cv_fold,
              "train",
              "fit",
              verbose,
          )
          fit_estimator_start_time = pd.Timestamp.now()
          strategy.fit(task, train)
          fit_estimator_end_time = pd.Timestamp.now()
  
          # save fitted strategy if save fitted strategies is set to True
          # and overwrite is set to True or the
          # fitted strategy does not already exist
          if save_fitted_strategies and (
              overwrite_fitted_strategies or not fitted_strategy_exists
          ):
              self.results.save_fitted_strategy(
                  strategy, dataset_name=dataset.name, cv_fold=cv_fold
              )
  
          # optionally, predict on training set if predict on train is set
          # to True and and overwrite is set to True
          # or the predicted values do not already exist
          if predict_on_train and (
              overwrite_predictions or not train_pred_exist
          ):
              y_true = train.loc[:, task.target]
              predict_estimator_start_time = pd.Timestamp.now()
              y_pred = strategy.predict(train)
              predict_estimator_end_time = pd.Timestamp.now()
  
              y_proba = self._predict_proba_one(
                  strategy, task, train, y_true, y_pred
              )
              self.results.save_predictions(
                  strategy_name=strategy.name,
                  dataset_name=dataset.name,
                  index=train_idx,
                  y_true=y_true,
                  y_pred=y_pred,
                  y_proba=y_proba,
                  cv_fold=cv_fold,
                  fit_estimator_start_time=fit_estimator_start_time,
                  fit_estimator_end_time=fit_estimator_end_time,
                  predict_estimator_start_time=predict_estimator_start_time,
                  predict_estimator_end_time=predict_estimator_end_time,
                  train_or_test="train",
              )
  
          # predict on test set if overwrite predictions is set to True or
          # predictions do not already exist
          if overwrite_predictions or not test_pred_exist:
              y_true = test.loc[:, task.target]
              predict_estimator_start_time = pd.Timestamp.now()
              y_pred = strategy.predict(test)
              predict_estimator_end_time = pd.Timestamp.now()
  
              y_proba = self._predict_proba_one(
                  strategy, task, test, y_true, y_pred
              )
              self.results.save_predictions(
                  dataset_name=dataset.name,
                  strategy_name=strategy.name,
                  index=test_idx,
                  y_true=y_true,
                  y_pred=y_pred,
                  y_proba=y_proba,
                  cv_fold=cv_fold,
                  fit_estimator_start_time=fit_estimator_start_time,
                  fit_estimator_end_time=fit_estimator_end_time,
                  predict_estimator_start_time=predict_estimator_start_time,
                  predict_estimator_end_time=predict_estimator_end_time,
                  train_or_test="test",
              )
  
      # save results as master file
      self.results.save()
  
file_path: sktime/sktime/benchmarking/orchestration.py
imports: import logging
  import pandas
  from sklearn.base import clone
  from sktime.benchmarking.tasks import TSCTask, TSRTask
label_desc: Use image node_id 5 for calling the Orchestrator obj's underlying member method code with example usage: obj.fit_predict(overwrite_predictions, predict_on_train, save_fitted_strategies, overwrite_fitted_strategies, verbose) without return types