:py:mod:`abacusai.model`
========================

.. py:module:: abacusai.model


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   abacusai.model.Model




.. py:class:: Model(client, name=None, modelId=None, modelConfig=None, modelPredictionConfig=None, createdAt=None, projectId=None, shared=None, sharedAt=None, trainFunctionName=None, predictFunctionName=None, trainingInputTables=None, sourceCode=None, cpuSize=None, memory=None, trainingFeatureGroupIds=None, location={}, refreshSchedules={}, latestModelVersion={})

   Bases: :py:obj:`abacusai.return_class.AbstractApiClass`

   A model

   :param client: An authenticated API Client instance
   :type client: ApiClient
   :param name: The user-friendly name for the model.
   :type name: str
   :param modelId: The unique identifier of the model.
   :type modelId: str
   :param modelConfig: The training config options used to train this model.
   :type modelConfig: dict
   :param modelPredictionConfig: The prediction config options for the model.
   :type modelPredictionConfig: dict
   :param createdAt: Date and time at which the model was created.
   :type createdAt: str
   :param projectId: The project this model belongs to.
   :type projectId: str
   :param shared: If model is shared to the Abacus.AI model showcase.
   :type shared: bool
   :param sharedAt: The date and time at which the model was shared to the model showcase
   :type sharedAt: str
   :param trainFunctionName: Name of the function found in the source code that will be executed to train the model. It is not executed when this function is run.
   :type trainFunctionName: str
   :param predictFunctionName: Name of the function found in the source code that will be executed run predictions through model. It is not executed when this function is run.
   :type predictFunctionName: str
   :param trainingInputTables: List of feature groups that are supplied to the train function as parameters. Each of the parameters are materialized Dataframes (same type as the functions return value).
   :type trainingInputTables: list
   :param sourceCode: Python code used to make the model.
   :type sourceCode: str
   :param cpuSize: Cpu size specified for the python model training.
   :type cpuSize: str
   :param memory: Memory in GB specified for the python model training.
   :type memory: int
   :param trainingFeatureGroupIds: The unique identifiers of the feature groups used as the inputs to train this model on.
   :type trainingFeatureGroupIds: list of unique string identifiers
   :param latestModelVersion: The latest model version.
   :type latestModelVersion: ModelVersion
   :param location: Location information for models that are imported.
   :type location: ModelLocation
   :param refreshSchedules: List of refresh schedules that indicate when the next model version will be trained
   :type refreshSchedules: RefreshSchedule

   .. py:method:: __repr__(self)

      Return repr(self).


   .. py:method:: to_dict(self)

      Get a dict representation of the parameters in this class

      :returns: The dict value representation of the class parameters
      :rtype: dict


   .. py:method:: refresh(self)

      Calls describe and refreshes the current object's fields

      :returns: The current object
      :rtype: Model


   .. py:method:: describe(self)

      Retrieves a full description of the specified model.

      :param model_id: The unique ID associated with the model.
      :type model_id: str

      :returns: The description of the model.
      :rtype: Model


   .. py:method:: rename(self, name)

      Renames a model

      :param name: The name to apply to the model
      :type name: str


   .. py:method:: update_python(self, function_source_code = None, train_function_name = None, predict_function_name = None, training_input_tables = None, cpu_size = None, memory = None)

      Updates an existing python Model using user provided Python code. If a list of input feature groups are supplied,

      we will provide as arguments to the train and predict functions with the materialized feature groups for those
      input feature groups.

      This method expects `functionSourceCode` to be a valid language source file which contains the functions named
      `trainFunctionName` and `predictFunctionName`. `trainFunctionName` returns the ModelVersion that is the result of
      training the model using `trainFunctionName` and `predictFunctionName` has no well defined return type,
      as it returns the prediction made by the `predictFunctionName`, which can be anything


      :param function_source_code: Contents of a valid python source code file. The source code should contain the functions named trainFunctionName and predictFunctionName. A list of allowed import and system libraries for each language is specified in the user functions documentation section.
      :type function_source_code: str
      :param train_function_name: Name of the function found in the source code that will be executed to train the model. It is not executed when this function is run.
      :type train_function_name: str
      :param predict_function_name: Name of the function found in the source code that will be executed run predictions through model. It is not executed when this function is run.
      :type predict_function_name: str
      :param training_input_tables: List of feature groups that are supplied to the train function as parameters. Each of the parameters are materialized Dataframes (same type as the functions return value).
      :type training_input_tables: list
      :param cpu_size: Size of the cpu for the model training function
      :type cpu_size: str
      :param memory: Memory (in GB) for the model training function
      :type memory: int

      :returns: The updated model
      :rtype: Model


   .. py:method:: update_python_zip(self, train_function_name = None, predict_function_name = None, train_module_name = None, predict_module_name = None, training_input_tables = None, cpu_size = None, memory = None)

      Updates an existing python Model using a provided zip file. If a list of input feature groups are supplied,

      we will provide as arguments to the train and predict functions with the materialized feature groups for those
      input feature groups.

      This method expects `trainModuleName` and `predictModuleName` to be valid language source files which contains the functions named
      `trainFunctionName` and `predictFunctionName`, respectively. `trainFunctionName` returns the ModelVersion that is the result of
      training the model using `trainFunctionName` and `predictFunctionName` has no well defined return type,
      as it returns the prediction made by the `predictFunctionName`, which can be anything


      :param train_function_name: Name of the function found in train module that will be executed to train the model. It is not executed when this function is run.
      :type train_function_name: str
      :param predict_function_name: Name of the function found in the predict module that will be executed run predictions through model. It is not executed when this function is run.
      :type predict_function_name: str
      :param train_module_name: Full path of the module that contains the train function from the root of the zip.
      :type train_module_name: str
      :param predict_module_name: Full path of the module that contains the predict function from the root of the zip.
      :type predict_module_name: str
      :param training_input_tables: List of feature groups that are supplied to the train function as parameters. Each of the parameters are materialized Dataframes (same type as the functions return value).
      :type training_input_tables: list
      :param cpu_size: Size of the cpu for the model training function
      :type cpu_size: str
      :param memory: Memory (in GB) for the model training function
      :type memory: int

      :returns: The updated model
      :rtype: Upload


   .. py:method:: set_training_config(self, training_config)

      Edits the default model training config

      :param training_config: The training config key/value pairs used to train this model.
      :type training_config: dict

      :returns: The model object correspoding after the training config is applied
      :rtype: Model


   .. py:method:: set_prediction_params(self, prediction_config)

      Sets the model prediction config for the model

      :param prediction_config: The prediction config for the model
      :type prediction_config: dict

      :returns: The model object correspoding after the prediction config is applied
      :rtype: Model


   .. py:method:: get_metrics(self, model_version = None, baseline_metrics = False)

      Retrieves a full list of the metrics for the specified model.

      If only the model's unique identifier (modelId) is specified, the latest trained version of model (modelVersion) is used.


      :param model_version: The version of the model.
      :type model_version: str
      :param baseline_metrics: If true, will also return the baseline model metrics for comparison.
      :type baseline_metrics: bool

      :returns: An object to show the model metrics and explanations for what each metric means.
      :rtype: ModelMetrics


   .. py:method:: list_versions(self, limit = 100, start_after_version = None)

      Retrieves a list of the version for a given model.

      :param limit: The max length of the list of all dataset versions.
      :type limit: int
      :param start_after_version: The id of the version after which the list starts.
      :type start_after_version: str

      :returns: An array of model versions.
      :rtype: ModelVersion


   .. py:method:: retrain(self, deployment_ids = [], feature_group_ids = None)

      Retrains the specified model. Gives you an option to choose the deployments you want the retraining to be deployed to.

      :param deployment_ids: List of deployments to automatically deploy to.
      :type deployment_ids: list
      :param feature_group_ids: List of feature group ids provided by the user to train the model on.
      :type feature_group_ids: list

      :returns: The model that is being retrained.
      :rtype: Model


   .. py:method:: delete(self)

      Deletes the specified model and all its versions. Models which are currently used in deployments cannot be deleted.

      :param model_id: The ID of the model to delete.
      :type model_id: str


   .. py:method:: wait_for_training(self, timeout=None)

      A waiting call until model is trained.

      :param timeout: The waiting time given to the call to finish, if it doesn't finish by the allocated time, the call is said to be timed out.
      :type timeout: int, optional


   .. py:method:: wait_for_evaluation(self, timeout=None)

      A waiting call until model is evaluated completely.

      :param timeout: The waiting time given to the call to finish, if it doesn't finish by the allocated time, the call is said to be timed out.
      :type timeout: int, optional


   .. py:method:: wait_for_full_automl(self, timeout=None)

      A waiting call until full AutoML cycle is completed.

      :param timeout: The waiting time given to the call to finish, if it doesn't finish by the allocated time, the call is said to be timed out.
      :type timeout: int, optional


   .. py:method:: get_status(self, get_automl_status = False)

      Gets the status of the model training.

      :returns: A string describing the status of a model training (pending, complete, etc.).
      :rtype: str


   .. py:method:: create_refresh_policy(self, cron)

      To create a refresh policy for a model.

      :param cron: A cron style string to set the refresh time.
      :type cron: str

      :returns: The refresh policy object.
      :rtype: RefreshPolicy


   .. py:method:: list_refresh_policies(self)

      Gets the refresh policies in a list.

      :returns: A list of refresh policy objects.
      :rtype: List[RefreshPolicy]



