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: Create the StatsForecast Handler.
  
  Requires specifying the target column to predict and time series arguments for
  prediction horizon, time column (order by) and grouping column(s).
  
  Saves args, models params, and the formatted training df to disk. The training df
  is used later in the predict() method.
docstr_tok: ["Create","the","StatsForecast","Handler",".","Requires","specifying","the","target","column","to","predict","and","time","series","arguments","for","prediction","horizon",",","time","column","(","order","by",")","and","grouping","column","(","s",")",".","Saves","args",",","models","params",",","and","the","formatted","training","df","to","disk",".","The","training","df","is","used","later","in","the","predict","(",")","method","."]
code: def create(self, target, df, args={}):
      """Create the StatsForecast Handler.
  
      Requires specifying the target column to predict and time series arguments for
      prediction horizon, time column (order by) and grouping column(s).
  
      Saves args, models params, and the formatted training df to disk. The training df
      is used later in the predict() method.
      """
      time_settings = args["timeseries_settings"]
      using_args = args["using"]
      assert time_settings[
          "is_timeseries"
      ], "Specify time series settings in your query"
      ###### store model args and time series settings in the model folder
      model_args = {}
      model_args["target"] = target
      model_args["horizon"] = time_settings["horizon"]
      model_args["order_by"] = time_settings["order_by"]
      if "group_by" not in time_settings:
          # add group column
          group_col = "__group_by"
          time_settings["group_by"] = [group_col]
  
      model_args["group_by"] = time_settings["group_by"]
      model_args["frequency"] = (
          using_args["frequency"]
          if "frequency" in using_args
          else infer_frequency(df, time_settings["order_by"])
      )
      model_args["hierarchy"] = (
          using_args["hierarchy"]
          if "hierarchy" in using_args
          else False
      )
      if (
          model_args["hierarchy"]
          and HierarchicalReconciliation is not None
      ):
          training_df, hier_df, hier_dict = get_hierarchy_from_df(
              df, model_args
          )
          self.model_storage.file_set(
              "hier_dict", dill.dumps(hier_dict)
          )
          self.model_storage.file_set("hier_df", dill.dumps(hier_df))
      else:
          training_df = transform_to_nixtla_df(df, model_args)
  
      model_args["model_name"] = (
          DEFAULT_MODEL_NAME
          if "model_name" not in using_args
          else using_args["model_name"]
      )
  
      results_df = get_insample_cv_results(model_args, training_df)
      model_args["accuracies"] = get_model_accuracy_dict(
          results_df, r2_score
      )
      model = choose_model(model_args, results_df)
      sf = StatsForecast(
          [model], freq=model_args["frequency"], df=training_df
      )
      fitted_models = sf.fit().fitted_
  
      ###### persist changes to handler folder
      self.model_storage.json_set("model_args", model_args)
      self.model_storage.file_set(
          "training_df", dill.dumps(training_df)
      )
      self.model_storage.file_set(
          "fitted_models", dill.dumps(fitted_models)
      )
  
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 1 for calling the StatsForecastHandler obj's underlying member method code with example usage: obj.create(target, df, args) without return types