class_docstr: Integration with the Nixtla StatsForecast library for
  time series forecasting with classical methods.
class_docstr_tok: ["Integration","with","the","Nixtla","StatsForecast","library","for","time","series","forecasting","with","classical","methods","."]
docstr: Makes forecasts with the StatsForecast Handler.
  
  StatsForecast is setup to predict for all groups, so it won't handle
  a dataframe that's been filtered to one group very well. Instead, we make
  the prediction for all groups then take care of the filtering after the
  forecasting. Prediction is nearly instant.
docstr_tok: ["Makes","forecasts","with","the","StatsForecast","Handler",".","StatsForecast","is","setup","to","predict","for","all","groups",",","so","it","wo","n't","handle","a","dataframe","that","'s","been","filtered","to","one","group","very","well",".","Instead",",","we","make","the","prediction","for","all","groups","then","take","care","of","the","filtering","after","the","forecasting",".","Prediction","is","nearly","instant","."]
code: def predict(self, df, args={}):
      """Makes forecasts with the StatsForecast Handler.
  
      StatsForecast is setup to predict for all groups, so it won't handle
      a dataframe that's been filtered to one group very well. Instead, we make
      the prediction for all groups then take care of the filtering after the
      forecasting. Prediction is nearly instant.
      """
      # Load model arguments
      model_args = self.model_storage.json_get("model_args")
      training_df = dill.loads(
          self.model_storage.file_get("training_df")
      )
      fitted_models = dill.loads(
          self.model_storage.file_get("fitted_models")
      )
  
      prediction_df = transform_to_nixtla_df(df, model_args)
      groups_to_keep = prediction_df["unique_id"].unique()
  
      sf = StatsForecast(
          models=[], freq=model_args["frequency"], df=training_df
      )
      sf.fitted_ = fitted_models
      model_name = str(fitted_models[0][0])
      forecast_df = sf.predict(model_args["horizon"])
      forecast_df.index = forecast_df.index.astype(str)
  
      if (
          model_args["hierarchy"]
          and HierarchicalReconciliation is not None
      ):
          hier_df = dill.loads(self.model_storage.file_get("hier_df"))
          hier_dict = dill.loads(
              self.model_storage.file_get("hier_dict")
          )
          reconciled_df = reconcile_forecasts(
              training_df, forecast_df, hier_df, hier_dict
          )
          results_df = reconciled_df[
              reconciled_df.index.isin(groups_to_keep)
          ]
  
      else:
          results_df = forecast_df[
              forecast_df.index.isin(groups_to_keep)
          ]
  
      result = get_results_from_nixtla_df(results_df, model_args)
      result = result.rename(columns={model_name: model_args["target"]})
      return result
  
file_path: mindsdb/mindsdb/integrations/handlers/statsforecast_handler/statsforecast_handler.py
imports: import pandas
  import dill
  from mindsdb.integrations.libs.base import BaseMLEngine
  from mindsdb.integrations.utilities.time_series_utils import transform_to_nixtla_df, get_results_from_nixtla_df, infer_frequency, get_best_model_from_results_df, get_model_accuracy_dict, reconcile_forecasts, get_hierarchy_from_df
  from sklearn.metrics import r2_score
  from statsforecast import StatsForecast
  from statsforecast.models import AutoARIMA, AutoCES, AutoETS, AutoTheta
label_desc: Use image node_id 2 for calling the StatsForecastHandler obj's underlying member method code with example usage: obj.predict(df, args) and returns: result