abacusai.model
Module Contents
Classes
A model |
- class abacusai.model.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, location={}, refreshSchedules={}, latestModelVersion={})
Bases:
abacusai.return_class.AbstractApiClass
A model
- Parameters
client (ApiClient) – An authenticated API Client instance
name (str) – The user-friendly name for the model.
modelId (str) – The unique identifier of the model.
modelConfig (dict) – The training config options used to train this model.
modelPredictionConfig (dict) – The prediction config options for the model.
createdAt (str) – Date and time at which the model was created.
projectId (str) – The project this model belongs to.
shared (bool) – If model is shared to the Abacus.AI model showcase.
sharedAt (str) – The date and time at which the model was shared to the model showcase
trainFunctionName (str) – 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.
predictFunctionName (str) – 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.
trainingInputTables (list) – 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).
sourceCode (str) – Python code used to make the model.
latestModelVersion (ModelVersion) – The latest model version.
location (ModelLocation) – Location information for models that are imported.
refreshSchedules (RefreshSchedule) – List of refresh schedules that indicate when the next model version will be trained
- __repr__(self)
Return repr(self).
- to_dict(self)
Get a dict representation of the parameters in this class
- Returns
The dict value representation of the class parameters
- Return type
- refresh(self)
Calls describe and refreshes the current object’s fields
- Returns
The current object
- Return type
- describe(self)
Retrieves a full description of the specified model.
- update_python(self, function_source_code=None, train_function_name=None, predict_function_name=None, training_input_tables=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
- Parameters
function_source_code (str) – 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.
train_function_name (str) – 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.
predict_function_name (str) – 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.
training_input_tables (list) – 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).
- Returns
The updated model
- Return type
- set_training_config(self, training_config)
Edits the default model training config
- set_prediction_params(self, prediction_config)
Sets the model prediction config for the model
- 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.
- Parameters
- Returns
An object to show the model metrics and explanations for what each metric means.
- Return type
- list_versions(self, limit=100, start_after_version=None)
Retrieves a list of the version for a given model.
- Parameters
- Returns
An array of model versions.
- Return type
- retrain(self, deployment_ids=[])
Retrains the specified model. Gives you an option to choose the deployments you want the retraining to be deployed to.
- delete(self)
Deletes the specified model and all its versions. Models which are currently used in deployments cannot be deleted.
- Parameters
model_id (str) – The ID of the model to delete.
- wait_for_training(self, timeout=None)
A waiting call until model is trained.
- Parameters
timeout (int, optional) – 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.
- wait_for_evaluation(self, timeout=None)
A waiting call until model is evaluated completely.
- Parameters
timeout (int, optional) – 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.
- wait_for_full_automl(self, timeout=None)
A waiting call until full AutoML cycle is completed.
- Parameters
timeout (int, optional) – 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.
- get_status(self, get_automl_status=False)
Gets the status of the model training.
- create_refresh_policy(self, cron)
To create a refresh policy for a model.
- Parameters
cron (str) – A cron style string to set the refresh time.
- Returns
The refresh policy object.
- Return type
- list_refresh_policies(self)
Gets the refresh policies in a list.
- Returns
A list of refresh policy objects.
- Return type
List[RefreshPolicy]