Model

class previsionio.model.Model(_id: str, experiment_version_id: str, project_id: str, model_name: str = None, deployable: bool = False, **other_params)

Bases: previsionio.api_resource.ApiResource

A Model object is generated by Prevision AutoML plateform when you launch an experiment version. All models generated by Prevision.io are deployable in our Store

With this Model class, you can select the model with the optimal hyperparameters that responds to your buisiness requirements, then you can deploy it as a real-time/batch endpoint that can be used for a web Service.

Parameters:
  • _id (str) – Unique id of the model
  • experiment_version_id (str) – Unique id of the experiment version of the model
  • name (str, optional) – Name of the model (default: None)
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.ClassicModel(_id: str, experiment_version_id: str, project_id: str, model_name: str = None, deployable: bool = False, **other_params)

Bases: previsionio.model.Model

chart()

Return chart analysis information for a model.

Returns:Chart analysis results
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
cross_validation

Get model’s cross validation dataframe.

Returns:Cross-validation dataframe
Return type:pd.Dataframe
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
feature_importance

Return a dataframe of feature importances for the given model features, with their corresponding scores (sorted by descending feature importance scores).

Returns:Dataframe of feature importances
Return type:pd.DataFrame
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.ClassificationModel(_id, experiment_version_id, **other_params)

Bases: previsionio.model.ClassicModel

A model object for a (binary) classification experiment, i.e. an experiment where the target is categorical with exactly 2 modalities.

Parameters:
  • _id (str) – Unique id of the model
  • experiment_version_id (str) – Unique id of the experiment version of the model
  • experiment_version (str, int) – Version of the experiment of the model (either an integer for a specific version, or “last”)
  • name (str, optional) – Name of the model (default: None)
chart()

Return chart analysis information for a model.

Returns:Chart analysis results
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
cross_validation

Get model’s cross validation dataframe.

Returns:Cross-validation dataframe
Return type:pd.Dataframe
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
feature_importance

Return a dataframe of feature importances for the given model features, with their corresponding scores (sorted by descending feature importance scores).

Returns:Dataframe of feature importances
Return type:pd.DataFrame
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

get_dynamic_performances(threshold: float = 0.5)

Get model performance for the given threshold.

Parameters:threshold (float, optional) – Threshold to check the model’s performance for (default: 0.5)
Returns:Model classification performance dict with the following keys:
  • confusion_matrix
  • accuracy
  • precision
  • recall
  • f1_score
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
optimal_threshold

Get the value of threshold probability that optimizes the F1 Score.

Returns:Optimal value of the threshold (if it not a classification problem it returns None)
Return type:float
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.RegressionModel(_id: str, experiment_version_id: str, project_id: str, model_name: str = None, deployable: bool = False, **other_params)

Bases: previsionio.model.ClassicModel

A model object for a regression experiment, i.e. an experiment where the target is numerical.

Parameters:
  • _id (str) – Unique id of the model
  • experiment_version_id (str) – Unique id of the experiment version of the model
  • experiment_version (str, int) – Version of the experiment of the model (either an integer for a specific version, or “last”)
  • name (str, optional) – Name of the model (default: None)
chart()

Return chart analysis information for a model.

Returns:Chart analysis results
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
cross_validation

Get model’s cross validation dataframe.

Returns:Cross-validation dataframe
Return type:pd.Dataframe
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
feature_importance

Return a dataframe of feature importances for the given model features, with their corresponding scores (sorted by descending feature importance scores).

Returns:Dataframe of feature importances
Return type:pd.DataFrame
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.MultiClassificationModel(_id: str, experiment_version_id: str, project_id: str, model_name: str = None, deployable: bool = False, **other_params)

Bases: previsionio.model.ClassicModel

A model object for a multi-classification experiment, i.e. an experiment where the target is categorical with strictly more than 2 modalities.

Parameters:
  • _id (str) – Unique id of the model
  • experiment_version_id (str) – Unique id of the experiment version of the model
  • experiment_version (str, int) – Version of the experiment of the model (either an integer for a specific version, or “last”)
  • name (str, optional) – Name of the model (default: None)
chart()

Return chart analysis information for a model.

Returns:Chart analysis results
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
cross_validation

Get model’s cross validation dataframe.

Returns:Cross-validation dataframe
Return type:pd.Dataframe
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
feature_importance

Return a dataframe of feature importances for the given model features, with their corresponding scores (sorted by descending feature importance scores).

Returns:Dataframe of feature importances
Return type:pd.DataFrame
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.ExternalClassificationModel(_id, experiment_version_id, **other_params)

Bases: previsionio.model.ClassificationModel

A model object for an external (binary) classification experiment, i.e. an experiment where the target is categorical with exactly 2 modalities.

Parameters:
  • _id (str) – Unique id of the model
  • experiment_version_id (str) – Unique id of the experiment version of the model
  • experiment_version (str, int) – Version of the experiment of the model (either an integer for a specific version, or “last”)
  • name (str, optional) – Name of the model (default: None)
chart()

Return chart analysis information for a model.

Returns:Chart analysis results
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

get_dynamic_performances(threshold: float = 0.5)

Get model performance for the given threshold.

Parameters:threshold (float, optional) – Threshold to check the model’s performance for (default: 0.5)
Returns:Model classification performance dict with the following keys:
  • confusion_matrix
  • accuracy
  • precision
  • recall
  • f1_score
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
optimal_threshold

Get the value of threshold probability that optimizes the F1 Score.

Returns:Optimal value of the threshold (if it not a classification problem it returns None)
Return type:float
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.ExternalRegressionModel(_id: str, experiment_version_id: str, project_id: str, model_name: str = None, deployable: bool = False, **other_params)

Bases: previsionio.model.RegressionModel

A model object for an external regression experiment, i.e. an experiment where the target is numerical.

Parameters:
  • _id (str) – Unique id of the model
  • experiment_version_id (str) – Unique id of the experiment version of the model
  • experiment_version (str, int) – Version of the experiment of the model (either an integer for a specific version, or “last”)
  • name (str, optional) – Name of the model (default: None)
chart()

Return chart analysis information for a model.

Returns:Chart analysis results
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.ExternalMultiClassificationModel(_id: str, experiment_version_id: str, project_id: str, model_name: str = None, deployable: bool = False, **other_params)

Bases: previsionio.model.MultiClassificationModel

A model object for an external multi-classification experiment, i.e. an experiment where the target is categorical with strictly more than 2 modalities.

Parameters:
  • _id (str) – Unique id of the model
  • experiment_version_id (str) – Unique id of the experiment version of the model
  • experiment_version (str, int) – Version of the experiment of the model (either an integer for a specific version, or “last”)
  • name (str, optional) – Name of the model (default: None)
chart()

Return chart analysis information for a model.

Returns:Chart analysis results
Return type:dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
predict(df: pandas.core.frame.DataFrame, confidence: bool = False, prediction_dataset_name: str = None) → pandas.core.frame.DataFrame

Make a prediction in a Scikit-learn blocking style.

Warning

For large dataframes and complex (blend) models, this can be slow (up to 1-2 hours). Prefer using this for simple models and small dataframes or use option use_best_single = True.

Parameters:
  • df (pd.DataFrame) – A pandas dataframe containing the testing data
  • confidence (bool, optional) – Whether to predict with confidence estimator (default: False)
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(dataset: previsionio.dataset.Dataset, confidence: bool = False, dataset_folder: previsionio.dataset.Dataset = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • dataset_folder (Dataset, None) – Matching folder dataset resource for the prediction, if necessary
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict
class previsionio.model.TextSimilarityModel(_id: str, experiment_version_id: str, project_id: str, model_name: str = None, deployable: bool = False, **other_params)

Bases: previsionio.model.Model

delete()

Delete a resource from the actual [client] workspace.

Raises:PrevisionException – Any error while deleting data from the platform
classmethod from_id(_id: str) → Union[previsionio.model.RegressionModel, previsionio.model.ClassificationModel, previsionio.model.MultiClassificationModel, previsionio.model.TextSimilarityModel]

Get an experiment from the platform by its unique id.

Parameters:
  • _id (str) – Unique id of the experiment to retrieve
  • version (int, optional) – Specific version of the experiment to retrieve (default: 1)
Returns:

Fetched experiment

Return type:

BaseExperimentVersion

Raises:

PrevisionException – Any error while fetching data from the platform or parsing result

hyperparameters

Return the hyperparameters of a model.

Returns:Hyperparameters of the model
Return type:dict
predict(df: pandas.core.frame.DataFrame, queries_dataset_content_column: str, top_k: int = 10, queries_dataset_matching_id_description_column: str = None, prediction_dataset_name: str = None) → Optional[pandas.core.frame.DataFrame]

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • queries_dataset_content_column (str) – Content queries column name
  • top_k (integer) – Number of the nearest description to predict
  • queries_dataset_matching_id_description_column (str) – Matching id description column name
Returns:

Prediction results dataframe

Return type:

pd.DataFrame

predict_from_dataset(queries_dataset: previsionio.dataset.Dataset, queries_dataset_content_column: str, top_k: int = 10, queries_dataset_matching_id_description_column: str = None) → previsionio.prediction.ValidationPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:
  • dataset (Dataset) – Dataset resource to make a prediction for
  • queries_dataset_content_column (str) – Content queries column name
  • top_k (integer) – Number of the nearest description to predict
  • queries_dataset_matching_id_description_column (str) – Matching id description column name
Returns:

The registered prediction object in the current workspace

Return type:

ValidationPrediction

update_status(specific_url: str = None) → Dict

Get an update on the status of a resource.

Parameters:specific_url (str, optional) – Specific (already parametrized) url to fetch the resource from (otherwise the url is built from the resource type and unique _id)
Returns:Updated status info
Return type:dict