abacusai.batch_prediction

Module Contents

Classes

BatchPrediction

Batch predictions

class abacusai.batch_prediction.BatchPrediction(client, batchPredictionId=None, createdAt=None, name=None, deploymentId=None, fileConnectorOutputLocation=None, globalPredictionArgs=None, databaseConnectorId=None, databaseOutputConfiguration=None, explanations=None, fileOutputFormat=None, connectorType=None, legacyInputLocation=None, featureGroupTableName=None, csvInputPrefix=None, csvPredictionPrefix=None, csvExplanationsPrefix=None, outputIncludesMetadata=None, resultInputColumns=None, batchInputs={}, latestBatchPredictionVersion={}, refreshSchedules={})

Bases: abacusai.return_class.AbstractApiClass

Batch predictions

Parameters
  • client (ApiClient) – An authenticated API Client instance

  • batchPredictionId (str) – The unique identifier of the batch prediction request

  • createdAt (str) – When the batch prediction was created

  • name (str) – Name given to the batch prediction object

  • deploymentId (str) – The deployment used to make the predictions

  • fileConnectorOutputLocation (str) – Contains information about where the batch predictions are written to

  • globalPredictionArgs (dict) – Argument(s) passed to every prediction call

  • databaseConnectorId (str) – The database connector to write the results to

  • databaseOutputConfiguration (dict) – Contains information about where the batch predictions are written to

  • explanations (bool) – If true, explanations for each prediction were created

  • fileOutputFormat (str) – The format of the batch prediction output (CSV or JSON)

  • connectorType (str) – Null if writing to internal console, else FEATURE_GROUP | FILE_CONNECTOR | DATABASE_CONNECTOR

  • legacyInputLocation (str) – The location of the input data

  • featureGroupTableName (str) – The table name of the Batch Prediction feature group

  • csvInputPrefix (str) – A prefix to prepend to the input columns, only applies when output format is CSV

  • csvPredictionPrefix (str) – A prefix to prepend to the prediction columns, only applies when output format is CSV

  • csvExplanationsPrefix (str) – A prefix to prepend to the explanation columns, only applies when output format is CSV

  • outputIncludesMetadata (bool) – If true, output will contain columns including prediction start time, batch prediction version, and model version

  • resultInputColumns (list of string) – If present, will limit result files or feature groups to only include columns present in this list

  • batchInputs (PredictionInput) – Inputs to the batch prediction

  • latestBatchPredictionVersion (BatchPredictionVersion) – The latest batch prediction version

  • refreshSchedules (RefreshSchedule) – List of refresh schedules that dictate the next time the batch prediction will be run

__repr__()

Return repr(self).

to_dict()

Get a dict representation of the parameters in this class

Returns

The dict value representation of the class parameters

Return type

dict

start()

Creates a new batch prediction version job for a given batch prediction job description

Parameters

batch_prediction_id (str) – The unique identifier of the batch prediction to create a new version of

Returns

The batch prediction version started by this method call.

Return type

BatchPredictionVersion

refresh()

Calls describe and refreshes the current object’s fields

Returns

The current object

Return type

BatchPrediction

describe()

Describes the batch prediction

Parameters

batch_prediction_id (str) – The unique ID associated with the batch prediction.

Returns

The batch prediction description.

Return type

BatchPrediction

list_versions(limit=100, start_after_version=None)

Retrieves a list of versions of a given batch prediction

Parameters
  • limit (int) – The number of versions to list

  • start_after_version (str) – The version to start after

Returns

A list of batch prediction versions.

Return type

BatchPredictionVersion

update(deployment_id=None, global_prediction_args=None, explanations=None, output_format=None, csv_input_prefix=None, csv_prediction_prefix=None, csv_explanations_prefix=None, output_includes_metadata=None, result_input_columns=None)

Updates a batch prediction job description

Parameters
  • deployment_id (str) – The unique identifier to a deployment.

  • global_prediction_args (dict) – Argument(s) to pass on every prediction call.

  • explanations (bool) – If true, will provide SHAP Explanations for each prediction, if supported by the use case.

  • output_format (str) – If specified, sets the format of the batch prediction output (CSV or JSON).

  • csv_input_prefix (str) – A prefix to prepend to the input columns, only applies when output format is CSV

  • csv_prediction_prefix (str) – A prefix to prepend to the prediction columns, only applies when output format is CSV

  • csv_explanations_prefix (str) – A prefix to prepend to the explanation columns, only applies when output format is CSV

  • output_includes_metadata (bool) – If true, output will contain columns including prediction start time, batch prediction version, and model version

  • result_input_columns (list) – If present, will limit result files or feature groups to only include columns present in this list

Returns

The batch prediction description.

Return type

BatchPrediction

set_file_connector_output(output_format=None, output_location=None)

Updates the file connector output configuration of the batch prediction

Parameters
  • output_format (str) – If specified, sets the format of the batch prediction output (CSV or JSON).

  • output_location (str) – If specified, the location to write the prediction results. Otherwise, results will be stored in Abacus.AI.

Returns

The batch prediction description.

Return type

BatchPrediction

set_database_connector_output(database_connector_id=None, database_output_config=None)

Updates the database connector output configuration of the batch prediction

Parameters
  • database_connector_id (str) – The unique identifier of an Database Connection to write predictions to.

  • database_output_config (dict) – A key-value pair of columns/values to write to the database connector

Returns

The batch prediction description.

Return type

BatchPrediction

set_feature_group_output(table_name)

Creates a feature group and sets it to be the batch prediction output

Parameters

table_name (str) – The name of the feature group table to create

Returns

The batch prediction after the output has been applied

Return type

BatchPrediction

set_output_to_console()

Sets the batch prediction output to the console, clearing both the file connector and database connector config

Parameters

batch_prediction_id (str) – The unique identifier of the batch prediction

Returns

The batch prediction description.

Return type

BatchPrediction

set_dataset(dataset_type, dataset_id=None)

[Deprecated] Sets the batch prediction input dataset. Only applicable for legacy dataset-based projects

Parameters
  • dataset_type (str) – The dataset type to set

  • dataset_id (str) – The dataset to set

Returns

The batch prediction description.

Return type

BatchPrediction

set_feature_group(feature_group_type, feature_group_id=None)

Sets the batch prediction input feature group.

Parameters
  • feature_group_type (str) – The feature group type to set. The feature group type of the feature group. The type is based on the use case under which the feature group is being created. For example, Catalog Attributes can be a feature group type under personalized recommendation use case.

  • feature_group_id (str) – The feature group to set as input to the batch prediction

Returns

The batch prediction description.

Return type

BatchPrediction

set_dataset_remap(dataset_id_remap)

For the purpose of this batch prediction, will swap out datasets in the input feature groups

Parameters

dataset_id_remap (dict) – Key/value pairs of dataset_ids to replace during batch predictions

Returns

Batch Prediction object

Return type

BatchPrediction

delete()

Deletes a batch prediction

Parameters

batch_prediction_id (str) – The unique identifier of the batch prediction

wait_for_predictions(timeout=86400)

A waiting call until batch predictions are ready.

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_drift_monitor(timeout=86400)

A waiting call until batch prediction drift monitor calculations are ready.

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()

Gets the status of the latest batch prediction version.

Returns

A string describing the status of the latest batch prediction version e.g., pending, complete, etc.

Return type

str

create_refresh_policy(cron)

To create a refresh policy for a batch prediction.

Parameters

cron (str) – A cron style string to set the refresh time.

Returns

The refresh policy object.

Return type

RefreshPolicy

list_refresh_policies()

Gets the refresh policies in a list.

Returns

A list of refresh policy objects.

Return type

List[RefreshPolicy]

describe_output_feature_group()

Gets the results feature group for this batch prediction

Returns

A feature group object.

Return type

FeatureGroup