Supervised usecases

class previsionio.supervised.Classification(**usecase_info)

Bases: previsionio.supervised.Supervised

A (binary) classification usecase for a categorical target with exactly 2 modalities using a basic dataset.

predict_proba(df, use_best_single=False, confidence=False) → pandas.core.frame.DataFrame

Get the predictions for a dataset stored in the current active [client] workspace using the best model of the usecase with a Scikit-learn style blocking prediction mode, and returns the probabilities.

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) – pandas DataFrame containing the test data
  • confidence (bool, optional) – Whether to predict with confidence values (default: False)
  • use_best_single (bool, optional) – Whether to use the best single model instead of the best model overall (default: False)
Returns:

Prediction probabilities data (as pandas dataframe) and prediction job ID.

Return type:

tuple(pd.DataFrame, str)

class previsionio.supervised.ClassificationImages(**usecase_info)

Bases: previsionio.supervised.SupervisedImages

A (binary) classification usecase for a categorical target with exactly 2 modalities using an image dataset.

class previsionio.supervised.MultiClassification(**usecase_info)

Bases: previsionio.supervised.Supervised

A multiclassification usecase for a categorical target with strictly more than 2 modalities using a basic dataset.

class previsionio.supervised.MultiClassificationImages(**usecase_info)

Bases: previsionio.supervised.SupervisedImages

A multiclassification usecase for a categorical target with strictly more than 2 modalities using an image dataset.

class previsionio.supervised.Regression(**usecase_info)

Bases: previsionio.supervised.Supervised

A regression usecase for a numerical target using a basic dataset.

class previsionio.supervised.RegressionImages(**usecase_info)

Bases: previsionio.supervised.SupervisedImages

A regression usecase for a numerical target using an image dataset.

class previsionio.supervised.Supervised(**usecase_info)

Bases: previsionio.usecase.BaseUsecase

A supervised usecase.

classmethod fit(name, dataset, column_config, metric=None, holdout_dataset=None, training_config=<previsionio.usecase_config.TrainingConfig object>, type_problem=None, **kwargs)

Start a supervised usecase training with a specific training configuration (on the platform).

Parameters:
  • name (str) – Name of the usecase to create
  • dataset (Dataset, DatasetImages) – Reference to the dataset object to use for as training dataset
  • column_config (ColumnConfig) – Column configuration for the usecase (see the documentation of the ColumnConfig resource for more details on each possible column types)
  • metric (str, optional) – Specific metric to use for the usecase (default: None)
  • holdout_dataset (Dataset, optional) – Reference to a dataset object to use as a holdout dataset (default: None)
  • training_config (TrainingConfig) – Specific training configuration (see the documentation of the TrainingConfig resource for more details on all the parameters)
  • type_problem (str, optional) – Specific problem type to train (default: None)
Returns:

Newly created supervised usecase object

Return type:

Supervised

classmethod from_id(_id, version=1)

Get a supervised usecase from the platform by its unique id.

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

Fetched usecase

Return type:

Supervised

Raises:

PrevisionException – Invalid problem type or any error while fetching data from the platform or parsing result

classmethod from_name(name, raise_if_non_unique=False, partial_match=False)

Get a supervised usecase from the platform by its name.

Parameters:
  • name (str) – Name of the usecase to retrieve
  • raise_if_non_unique (bool, optional) – Whether or not to raise an error if duplicates are found (default: False)
  • partial_match (bool, optional) – If true, usecases with a name containing the requested name will also be returned; else, only perfect matches will be found (default: False)
Raises:

PrevisionException – Error if duplicates are found and the raise_if_non_unique is enabled

Returns:

Fetched usecase

Return type:

Supervised

new_version(**fit_params)

Start a supervised usecase training to create a new version of the usecase (on the platform): the training config is copied from the current version and then overridden for the given parameters.

Parameters:fit_params (kwargs) – Training config parameters to change for the new version (compared to the current version)
Returns:Newly created supervised usecase object (new version)
Return type:Supervised
class previsionio.supervised.SupervisedImages(**usecase_info)

Bases: previsionio.supervised.Supervised

A supervised usecase with an image dataset.

class previsionio.timeseries.TimeSeries(**usecase_info)

Bases: previsionio.usecase.BaseUsecase

A TimeSeries usecase.

model_class

alias of previsionio.model.RegressionModel

class previsionio.timeseries.TimeWindow(derivation_start, derivation_end, forecast_start, forecast_end)

Bases: previsionio.usecase_config.UsecaseConfig

A time window object for representing either feature derivation window periods or forecast window periods

exception previsionio.timeseries.TimeWindowException

Bases: Exception