abacusai.batch_prediction
=========================

.. py:module:: abacusai.batch_prediction


Classes
-------

.. autoapisummary::

   abacusai.batch_prediction.BatchPredictionArgs
   abacusai.batch_prediction.BatchPredictionVersion
   abacusai.batch_prediction.PredictionFeatureGroup
   abacusai.batch_prediction.PredictionInput
   abacusai.batch_prediction.RefreshSchedule
   abacusai.batch_prediction.AbstractApiClass
   abacusai.batch_prediction.BatchPrediction


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

.. py:class:: BatchPredictionArgs

   Bases: :py:obj:`abacusai.api_class.abstract.ApiClass`


   An abstract class for Batch Prediction args specific to problem type.


   .. py:attribute:: _support_kwargs
      :type:  bool


   .. py:attribute:: kwargs
      :type:  dict


   .. py:attribute:: problem_type
      :type:  abacusai.api_class.enums.ProblemType


   .. py:method:: _get_builder()
      :classmethod:



.. py:class:: BatchPredictionVersion(client, batchPredictionVersion=None, batchPredictionId=None, status=None, driftMonitorStatus=None, deploymentId=None, modelId=None, modelVersion=None, predictionsStartedAt=None, predictionsCompletedAt=None, databaseOutputError=None, totalPredictions=None, failedPredictions=None, databaseConnectorId=None, databaseOutputConfiguration=None, fileConnectorOutputLocation=None, fileOutputFormat=None, connectorType=None, legacyInputLocation=None, error=None, driftMonitorError=None, monitorWarnings=None, csvInputPrefix=None, csvPredictionPrefix=None, csvExplanationsPrefix=None, databaseOutputTotalWrites=None, databaseOutputFailedWrites=None, outputIncludesMetadata=None, resultInputColumns=None, modelMonitorVersion=None, algoName=None, algorithm=None, outputFeatureGroupId=None, outputFeatureGroupVersion=None, outputFeatureGroupTableName=None, batchPredictionWarnings=None, bpAcrossVersionsMonitorVersion=None, batchPredictionArgsType=None, batchInputs={}, inputFeatureGroups={}, globalPredictionArgs={}, batchPredictionArgs={})

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


   Batch Prediction Version

   :param client: An authenticated API Client instance
   :type client: ApiClient
   :param batchPredictionVersion: The unique identifier of the batch prediction version
   :type batchPredictionVersion: str
   :param batchPredictionId: The unique identifier of the batch prediction
   :type batchPredictionId: str
   :param status: The current status of the batch prediction
   :type status: str
   :param driftMonitorStatus: The status of the drift monitor for this batch prediction version
   :type driftMonitorStatus: str
   :param deploymentId: The deployment used to make the predictions
   :type deploymentId: str
   :param modelId: The model used to make the predictions
   :type modelId: str
   :param modelVersion: The model version used to make the predictions
   :type modelVersion: str
   :param predictionsStartedAt: Predictions start date and time
   :type predictionsStartedAt: str
   :param predictionsCompletedAt: Predictions completion date and time
   :type predictionsCompletedAt: str
   :param databaseOutputError: If true, there were errors reported by the database connector while writing
   :type databaseOutputError: bool
   :param totalPredictions: Number of predictions performed in this batch prediction job
   :type totalPredictions: int
   :param failedPredictions: Number of predictions that failed
   :type failedPredictions: int
   :param databaseConnectorId: The database connector to write the results to
   :type databaseConnectorId: str
   :param databaseOutputConfiguration: Contains information about where the batch predictions are written to
   :type databaseOutputConfiguration: dict
   :param fileConnectorOutputLocation: Contains information about where the batch predictions are written to
   :type fileConnectorOutputLocation: str
   :param fileOutputFormat: The format of the batch prediction output (CSV or JSON)
   :type fileOutputFormat: str
   :param connectorType: Null if writing to internal console, else FEATURE_GROUP | FILE_CONNECTOR | DATABASE_CONNECTOR
   :type connectorType: str
   :param legacyInputLocation: The location of the input data
   :type legacyInputLocation: str
   :param error: Relevant error if the status is FAILED
   :type error: str
   :param driftMonitorError: Error message for the drift monitor of this batch predcition
   :type driftMonitorError: str
   :param monitorWarnings: Relevant warning if there are issues found in drift or data integrity
   :type monitorWarnings: str
   :param csvInputPrefix: A prefix to prepend to the input columns, only applies when output format is CSV
   :type csvInputPrefix: str
   :param csvPredictionPrefix: A prefix to prepend to the prediction columns, only applies when output format is CSV
   :type csvPredictionPrefix: str
   :param csvExplanationsPrefix: A prefix to prepend to the explanation columns, only applies when output format is CSV
   :type csvExplanationsPrefix: str
   :param databaseOutputTotalWrites: The total number of rows attempted to write (may be less than total_predictions if write mode is UPSERT and multiple rows share the same ID)
   :type databaseOutputTotalWrites: int
   :param databaseOutputFailedWrites: The number of failed writes to the Database Connector
   :type databaseOutputFailedWrites: int
   :param outputIncludesMetadata: If true, output will contain columns including prediction start time, batch prediction version, and model version
   :type outputIncludesMetadata: bool
   :param resultInputColumns: If present, will limit result files or feature groups to only include columns present in this list
   :type resultInputColumns: list[str]
   :param modelMonitorVersion: The version of the model monitor
   :type modelMonitorVersion: str
   :param algoName: The name of the algorithm used to train the model
   :type algoName: str
   :param algorithm: The algorithm that is currently deployed.
   :type algorithm: str
   :param outputFeatureGroupId: The Batch Prediction output feature group ID if applicable
   :type outputFeatureGroupId: str
   :param outputFeatureGroupVersion: The Batch Prediction output feature group version if applicable
   :type outputFeatureGroupVersion: str
   :param outputFeatureGroupTableName: The Batch Prediction output feature group name if applicable
   :type outputFeatureGroupTableName: str
   :param batchPredictionWarnings: Relevant warnings if any issues are found
   :type batchPredictionWarnings: str
   :param bpAcrossVersionsMonitorVersion: The version of the batch prediction across versions monitor
   :type bpAcrossVersionsMonitorVersion: str
   :param batchPredictionArgsType: The type of the batch prediction args
   :type batchPredictionArgsType: str
   :param batchInputs: Inputs to the batch prediction
   :type batchInputs: PredictionInput
   :param inputFeatureGroups: List of prediction feature groups
   :type inputFeatureGroups: PredictionFeatureGroup
   :param globalPredictionArgs:
   :type globalPredictionArgs: BatchPredictionArgs
   :param batchPredictionArgs: Argument(s) passed to every prediction call
   :type batchPredictionArgs: BatchPredictionArgs


   .. py:method:: __repr__()

      Return repr(self).



   .. py:method:: to_dict()

      Get a dict representation of the parameters in this class

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



   .. py:method:: download_batch_prediction_result_chunk(offset = 0, chunk_size = 10485760)

      Returns a stream containing the batch prediction results.

      :param offset: The offset to read from.
      :type offset: int
      :param chunk_size: The maximum amount of data to read.
      :type chunk_size: int



   .. py:method:: get_batch_prediction_connector_errors()

      Returns a stream containing the batch prediction database connection write errors, if any writes failed for the specified batch prediction job.

      :param batch_prediction_version: Unique string identifier of the batch prediction job to get the errors for.
      :type batch_prediction_version: str



   .. py:method:: refresh()

      Calls describe and refreshes the current object's fields

      :returns: The current object
      :rtype: BatchPredictionVersion



   .. py:method:: describe()

      Describes a Batch Prediction Version.

      :param batch_prediction_version: Unique string identifier of the Batch Prediction Version.
      :type batch_prediction_version: str

      :returns: The Batch Prediction Version.
      :rtype: BatchPredictionVersion



   .. py:method:: get_logs()

      Retrieves the batch prediction logs.

      :param batch_prediction_version: The unique version ID of the batch prediction version.
      :type batch_prediction_version: str

      :returns: The logs for the specified batch prediction version.
      :rtype: BatchPredictionVersionLogs



   .. py:method:: download_result_to_file(file)

      Downloads the batch prediction version in a local file.

      :param file: A file object opened in a binary mode e.g., file=open('/tmp/output', 'wb').
      :type file: file object



   .. py:method:: wait_for_predictions(timeout=86400)

      A waiting call until batch prediction version is ready.

      :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



   .. py:method:: wait_for_drift_monitor(timeout=86400)

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

      :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



   .. py:method:: get_status(drift_monitor_status = False)

      Gets the status of the batch prediction version.

      :returns: A string describing the status of the batch prediction version, for e.g., pending, complete, etc.
      :rtype: str



   .. py:method:: load_results_as_pandas()

      Loads the output feature groups into a python pandas dataframe.

      :returns: A pandas dataframe with annotations and text_snippet columns.
      :rtype: DataFrame



.. py:class:: PredictionFeatureGroup(client, featureGroupId=None, featureGroupVersion=None, datasetType=None, default=None, required=None)

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


   Batch Input Feature Group

   :param client: An authenticated API Client instance
   :type client: ApiClient
   :param featureGroupId: The unique identifier of the feature group
   :type featureGroupId: str
   :param featureGroupVersion: The unique identifier of the feature group version used for predictions
   :type featureGroupVersion: str
   :param datasetType: dataset type
   :type datasetType: str
   :param default: If true, this feature group is the default feature group in the model
   :type default: bool
   :param required: If true, this feature group is required for the batch prediction
   :type required: bool


   .. py:method:: __repr__()

      Return repr(self).



   .. py:method:: to_dict()

      Get a dict representation of the parameters in this class

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



.. py:class:: PredictionInput(client, featureGroupDatasetIds=None, datasetIdRemap=None, featureGroups={}, datasets={})

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


   Batch inputs

   :param client: An authenticated API Client instance
   :type client: ApiClient
   :param featureGroupDatasetIds: The list of dataset IDs to use as input
   :type featureGroupDatasetIds: list
   :param datasetIdRemap: Replacement datasets to swap as prediction input
   :type datasetIdRemap: dict
   :param featureGroups: List of prediction feature groups
   :type featureGroups: PredictionFeatureGroup
   :param datasets: List of prediction datasets
   :type datasets: PredictionDataset


   .. py:method:: __repr__()

      Return repr(self).



   .. py:method:: to_dict()

      Get a dict representation of the parameters in this class

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



.. py:class:: RefreshSchedule(client, refreshPolicyId=None, nextRunTime=None, cron=None, refreshType=None, error=None)

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


   A refresh schedule for an object. Defines when the next version of the object will be created

   :param client: An authenticated API Client instance
   :type client: ApiClient
   :param refreshPolicyId: The unique identifier of the refresh policy
   :type refreshPolicyId: str
   :param nextRunTime: The next run time of the refresh policy. If null, the policy is paused.
   :type nextRunTime: str
   :param cron: A cron-style string that describes the when this refresh policy is to be executed in UTC
   :type cron: str
   :param refreshType: The type of refresh that will be run
   :type refreshType: str
   :param error: An error message for the last pipeline run of a policy
   :type error: str


   .. py:method:: __repr__()

      Return repr(self).



   .. py:method:: to_dict()

      Get a dict representation of the parameters in this class

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



.. py:class:: AbstractApiClass(client, id)

   .. py:method:: __eq__(other)

      Return self==value.



   .. py:method:: _get_attribute_as_dict(attribute)


.. py:class:: BatchPrediction(client, batchPredictionId=None, createdAt=None, name=None, deploymentId=None, fileConnectorOutputLocation=None, databaseConnectorId=None, databaseOutputConfiguration=None, fileOutputFormat=None, connectorType=None, legacyInputLocation=None, outputFeatureGroupId=None, featureGroupTableName=None, outputFeatureGroupTableName=None, summaryFeatureGroupTableName=None, csvInputPrefix=None, csvPredictionPrefix=None, csvExplanationsPrefix=None, outputIncludesMetadata=None, resultInputColumns=None, modelMonitorId=None, modelVersion=None, bpAcrossVersionsMonitorId=None, algorithm=None, batchPredictionArgsType=None, batchInputs={}, latestBatchPredictionVersion={}, refreshSchedules={}, inputFeatureGroups={}, globalPredictionArgs={}, batchPredictionArgs={})

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


   Make batch predictions.

   :param client: An authenticated API Client instance
   :type client: ApiClient
   :param batchPredictionId: The unique identifier of the batch prediction request.
   :type batchPredictionId: str
   :param createdAt: When the batch prediction was created, in ISO-8601 format.
   :type createdAt: str
   :param name: Name given to the batch prediction object.
   :type name: str
   :param deploymentId: The deployment used to make the predictions.
   :type deploymentId: str
   :param fileConnectorOutputLocation: Contains information about where the batch predictions are written to.
   :type fileConnectorOutputLocation: str
   :param databaseConnectorId: The database connector to write the results to.
   :type databaseConnectorId: str
   :param databaseOutputConfiguration: Contains information about where the batch predictions are written to.
   :type databaseOutputConfiguration: dict
   :param fileOutputFormat: The format of the batch prediction output (CSV or JSON).
   :type fileOutputFormat: str
   :param connectorType: Null if writing to internal console, else FEATURE_GROUP | FILE_CONNECTOR | DATABASE_CONNECTOR.
   :type connectorType: str
   :param legacyInputLocation: The location of the input data.
   :type legacyInputLocation: str
   :param outputFeatureGroupId: The Batch Prediction output feature group ID if applicable
   :type outputFeatureGroupId: str
   :param featureGroupTableName: The table name of the Batch Prediction output feature group.
   :type featureGroupTableName: str
   :param outputFeatureGroupTableName: The table name of the Batch Prediction output feature group.
   :type outputFeatureGroupTableName: str
   :param summaryFeatureGroupTableName: The table name of the metrics summary feature group output by Batch Prediction.
   :type summaryFeatureGroupTableName: str
   :param csvInputPrefix: A prefix to prepend to the input columns, only applies when output format is CSV.
   :type csvInputPrefix: str
   :param csvPredictionPrefix: A prefix to prepend to the prediction columns, only applies when output format is CSV.
   :type csvPredictionPrefix: str
   :param csvExplanationsPrefix: A prefix to prepend to the explanation columns, only applies when output format is CSV.
   :type csvExplanationsPrefix: str
   :param outputIncludesMetadata: If true, output will contain columns including prediction start time, batch prediction version, and model version.
   :type outputIncludesMetadata: bool
   :param resultInputColumns: If present, will limit result files or feature groups to only include columns present in this list.
   :type resultInputColumns: list
   :param modelMonitorId: The model monitor for this batch prediction.
   :type modelMonitorId: str
   :param modelVersion: The model instance used in the deployment for the batch prediction.
   :type modelVersion: str
   :param bpAcrossVersionsMonitorId: The model monitor for this batch prediction across versions.
   :type bpAcrossVersionsMonitorId: str
   :param algorithm: The algorithm that is currently deployed.
   :type algorithm: str
   :param batchPredictionArgsType: The type of batch prediction arguments used for this batch prediction.
   :type batchPredictionArgsType: str
   :param batchInputs: Inputs to the batch prediction.
   :type batchInputs: PredictionInput
   :param latestBatchPredictionVersion: The latest batch prediction version.
   :type latestBatchPredictionVersion: BatchPredictionVersion
   :param refreshSchedules: List of refresh schedules that dictate the next time the batch prediction will be run.
   :type refreshSchedules: RefreshSchedule
   :param inputFeatureGroups: List of prediction feature groups.
   :type inputFeatureGroups: PredictionFeatureGroup
   :param globalPredictionArgs:
   :type globalPredictionArgs: BatchPredictionArgs
   :param batchPredictionArgs: Argument(s) passed to every prediction call.
   :type batchPredictionArgs: BatchPredictionArgs


   .. py:method:: __repr__()

      Return repr(self).



   .. py:method:: to_dict()

      Get a dict representation of the parameters in this class

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



   .. py:method:: start()

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

      :param batch_prediction_id: The unique identifier of the batch prediction to create a new version of.
      :type batch_prediction_id: str

      :returns: The batch prediction version started by this method call.
      :rtype: BatchPredictionVersion



   .. py:method:: refresh()

      Calls describe and refreshes the current object's fields

      :returns: The current object
      :rtype: BatchPrediction



   .. py:method:: describe()

      Describe the batch prediction.

      :param batch_prediction_id: The unique identifier associated with the batch prediction.
      :type batch_prediction_id: str

      :returns: The batch prediction description.
      :rtype: BatchPrediction



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

      Retrieves a list of versions of a given batch prediction

      :param limit: Number of versions to list.
      :type limit: int
      :param start_after_version: Version to start after.
      :type start_after_version: str

      :returns: List of batch prediction versions.
      :rtype: list[BatchPredictionVersion]



   .. py:method:: update(deployment_id = None, global_prediction_args = None, batch_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, name = None)

      Update a batch prediction job description.

      :param deployment_id: Unique identifier of the deployment.
      :type deployment_id: str
      :param batch_prediction_args: Batch Prediction args specific to problem type.
      :type batch_prediction_args: BatchPredictionArgs
      :param output_format: If specified, sets the format of the batch prediction output (CSV or JSON).
      :type output_format: str
      :param csv_input_prefix: Prefix to prepend to the input columns, only applies when output format is CSV.
      :type csv_input_prefix: str
      :param csv_prediction_prefix: Prefix to prepend to the prediction columns, only applies when output format is CSV.
      :type csv_prediction_prefix: str
      :param csv_explanations_prefix: Prefix to prepend to the explanation columns, only applies when output format is CSV.
      :type csv_explanations_prefix: str
      :param output_includes_metadata: If True, output will contain columns including prediction start time, batch prediction version, and model version.
      :type output_includes_metadata: bool
      :param result_input_columns: If present, will limit result files or feature groups to only include columns present in this list.
      :type result_input_columns: list
      :param name: If present, will rename the batch prediction.
      :type name: str

      :returns: The batch prediction.
      :rtype: BatchPrediction



   .. py:method:: set_file_connector_output(output_format = None, output_location = None)

      Updates the file connector output configuration of the batch prediction

      :param output_format: The format of the batch prediction output (CSV or JSON). If not specified, the default format will be used.
      :type output_format: str
      :param output_location: The location to write the prediction results. If not specified, results will be stored in Abacus.AI.
      :type output_location: str

      :returns: The batch prediction description.
      :rtype: BatchPrediction



   .. py:method:: set_database_connector_output(database_connector_id = None, database_output_config = None)

      Updates the database connector output configuration of the batch prediction

      :param database_connector_id: Unique string identifier of an Database Connection to write predictions to.
      :type database_connector_id: str
      :param database_output_config: Key-value pair of columns/values to write to the database connector.
      :type database_output_config: dict

      :returns: Description of the batch prediction.
      :rtype: BatchPrediction



   .. py:method:: set_feature_group_output(table_name)

      Creates a feature group and sets it as the batch prediction output.

      :param table_name: Name of the feature group table to create.
      :type table_name: str

      :returns: Batch prediction after the output has been applied.
      :rtype: BatchPrediction



   .. py:method:: set_output_to_console()

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

      :param batch_prediction_id: The unique identifier of the batch prediction.
      :type batch_prediction_id: str

      :returns: The batch prediction description.
      :rtype: BatchPrediction



   .. py:method:: set_feature_group(feature_group_type, feature_group_id = None)

      Sets the batch prediction input feature group.

      :param feature_group_type: Enum string representing the feature group type to set. The type is based on the use case under which the feature group is being created (e.g. Catalog Attributes for personalized recommendation use case).
      :type feature_group_type: str
      :param feature_group_id: Unique identifier of the feature group to set as input to the batch prediction.
      :type feature_group_id: str

      :returns: Description of the batch prediction.
      :rtype: BatchPrediction



   .. py:method:: set_dataset_remap(dataset_id_remap)

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

      :param dataset_id_remap: Key/value pairs of dataset ids to be replaced during the batch prediction.
      :type dataset_id_remap: dict

      :returns: Batch prediction object.
      :rtype: BatchPrediction



   .. py:method:: delete()

      Deletes a batch prediction and associated data, such as associated monitors.

      :param batch_prediction_id: Unique string identifier of the batch prediction.
      :type batch_prediction_id: str



   .. py:method:: wait_for_predictions(timeout=86400)

      A waiting call until batch predictions are ready.

      :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



   .. py:method:: wait_for_drift_monitor(timeout=86400)

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

      :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



   .. py:method:: 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.
      :rtype: str



   .. py:method:: create_refresh_policy(cron)

      To create a refresh policy for a batch prediction.

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

      Gets the refresh policies in a list.

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



   .. py:method:: describe_output_feature_group()

      Gets the results feature group for this batch prediction

      :returns: A feature group object.
      :rtype: FeatureGroup



   .. py:method:: load_results_as_pandas()

      Loads the output feature groups into a python pandas dataframe.

      :returns: A pandas dataframe with annotations and text_snippet columns.
      :rtype: DataFrame



