pdstools.infinity.resources.prediction_studio.v24_2.prediction

Classes

_PredictionV24_2Mixin

v24.2 Prediction business logic — shared parts.

Prediction

The Prediction class provide functionality including retrieving

AsyncPrediction

Async variant of the v24.2 Prediction.

Module Contents

class _PredictionV24_2Mixin

v24.2 Prediction business logic — shared parts.

prediction_id: str
async _get_models() list[dict[str, str]]

Internal function to fetch models linked to a specific prediction.

This function gathers all models that are connected to a particular prediction. It organizes these models into three groups: default models, category models, and supporting models, each serving a unique role in making the prediction.

Returns:

A collection of model dicts associated with the prediction.

Return type:

list of dict

async get_metric(*, metric: pdstools.infinity.internal._constants.METRIC, start_date: datetime.date | None = None, end_date: datetime.date | None = None, frequency: Literal['Daily', 'Weekly', 'Monthly'] = 'Daily') polars.DataFrame

Fetches and returns metric data for a prediction within a specified date range, using datetime objects for dates.

This method retrieves metric data, such as performance or usage statistics, for a given prediction. The data can be fetched for a specific period and at a defined frequency (daily, weekly, or monthly).

Parameters:
  • metric (METRIC) – The type of metric to retrieve.

  • start_date (datetime) – The start date for the data retrieval.

  • end_date (datetime, optional) – The end date for the data retrieval. If not provided, data is fetched until the current date.

  • frequency ({"Daily", "Weekly", "Monthly"}, optional) – The frequency at which to retrieve the data. Defaults to “Daily”.

Returns:

A DataFrame containing the requested metric data, including values, snapshot times, and data usage.

Return type:

pl.DataFrame

Raises:

NoMonitoringInfo – If no monitoring data is available for the given parameters.

async package_staged_changes(message: str | None = None)

Initiates the deployment of pending changes for a prediction model into the production setting.

This function initiates a Change Request (CR) to either deploy pending changes directly to a Revision Manager, if available, or to create a branch with all pending changes in Prediction Studio. An optional message can be included to detail the nature of the changes being deployed.

Parameters:

message (str, optional) – Descriptive message about the changes being deployed. Defaults to “Approving the changes” if not specified.

Returns:

Details the result of the deployment process.

Return type:

dict

async get_staged_changes()

Retrieves a list of changes for a specific prediction.

This method is used to fetch the list of changes that have been made to a prediction but not yet deployed to the production environment. The changes are staged and pending deployment.

Returns:

A list of changes staged for the prediction, detailing each modification pending deployment.

Return type:

list

class Prediction(client, *, predictionId: str, label: str, status: str, lastUpdateTime: str, objective: str | None = None, subject: str | None = None)

Bases: _PredictionV24_2Mixin, pdstools.infinity.resources.prediction_studio.v24_1.prediction.Prediction

The Prediction class provide functionality including retrieving notifications, models, adding conditional models, getting champion challengers, metrics, and plotting metrics.

Parameters:
  • predictionId (str)

  • label (str)

  • status (str)

  • lastUpdateTime (str)

  • objective (str | None)

  • subject (str | None)

get_notifications(category: pdstools.infinity.resources.prediction_studio.types.NotificationCategory | None = None, return_df: Literal[False] = False) pdstools.infinity.internal._pagination.PaginatedList[pdstools.infinity.resources.prediction_studio.base.Notification]
get_notifications(category: pdstools.infinity.resources.prediction_studio.types.NotificationCategory | None = None, return_df: Literal[True] = True) polars.DataFrame

Fetches a list of notifications for a specific prediction.

This function retrieves notifications related to a prediction. You can filter these notifications by their category. Optionally, the notifications can be returned as a DataFrame for easier analysis and visualization.

Parameters:
  • category ({"All", "Responses", "Performance", "Model approval", "Output", "Predictors", "Prediction deployment", "Generic"} or None) – The category of notifications to retrieve. If not specified, all notifications are fetched.

  • return_df (bool, default False) – If True, returns the notifications as a DataFrame. Otherwise, returns a list.

Returns:

A list of notifications or a DataFrame containing the notifications, depending on the value of return_df.

Return type:

PaginatedList[Notification] or polars.DataFrame

get_champion_challengers()

Fetches list of ChampionChallenger objects linked to the prediction.

This function fetches Champion-challenger pairs from a prediction. In cases where a challenger model is absent, it returns a ChampionChallenger object containing only the champion model.

Returns:

A list of entries, each pairing a primary model with its challenger across various segments of the prediction.

Return type:

list of ChampionChallenger

add_conditional_model(new_model, category: str, context: str | None = None)

Incorporates a new model into a prediction for a specified category and context.

Parameters:
  • new_model (str or Model) – Identifier of the model to be added.

  • category (str) – The category under which the model will be classified.

  • context (str, optional) – The specific context or scenario in which the model will be utilized.

Returns:

An object detailing the updated configuration with the newly added model.

Return type:

ChampionChallenger

class AsyncPrediction(client, *, predictionId: str, label: str, status: str, lastUpdateTime: str, objective: str | None = None, subject: str | None = None)

Bases: _PredictionV24_2Mixin, pdstools.infinity.resources.prediction_studio.v24_1.prediction.AsyncPrediction

Async variant of the v24.2 Prediction.

Parameters:
  • predictionId (str)

  • label (str)

  • status (str)

  • lastUpdateTime (str)

  • objective (str | None)

  • subject (str | None)

async get_notifications(category: pdstools.infinity.resources.prediction_studio.types.NotificationCategory | None = None, return_df: bool = False) pdstools.infinity.internal._pagination.AsyncPaginatedList[pdstools.infinity.resources.prediction_studio.base.AsyncNotification] | polars.DataFrame

Fetches a list of notifications for a specific prediction.

Parameters:
  • category ({"All", "Responses", "Performance", "Model approval", "Output", "Predictors", "Prediction deployment", "Generic"} or None) – The category of notifications to retrieve.

  • return_df (bool, default False) – If True, returns the notifications as a DataFrame.

Returns:

A list of notifications or a DataFrame.

Return type:

AsyncPaginatedList[AsyncNotification] or polars.DataFrame

async get_champion_challengers()

Fetches list of ChampionChallenger objects linked to the prediction.

Returns:

Champion-challenger pairs from a prediction.

Return type:

list of AsyncChampionChallenger

async add_conditional_model(new_model, category: str, context: str | None = None)

Incorporates a new model into a prediction for a specified category and context.

Parameters:
  • new_model (str or AsyncModel) – Identifier of the model to be added.

  • category (str) – The category under which the model will be classified.

  • context (str, optional) – The specific context or scenario.

Returns:

An object detailing the updated configuration.

Return type:

AsyncChampionChallenger