Project

class previsionio.project.Project(_id: str, name: str, description: str = None, color: previsionio.project.ProjectColor = None, created_by: str = None, admins=[], contributors=[], viewers=[], pipelines_count: int = 0, usecases_count: int = 0, dataset_count: int = 0, **kwargs)

Bases: previsionio.api_resource.ApiResource, previsionio.api_resource.UniqueResourceMixin

A Project

Parameters:
  • _id (str) – Unique id of the project
  • name (str) – Name of the project
  • description (str, optional) – Description of the project
  • color (ProjectColor, optional) – Color of the project
create_dataset(name: str, datasource: previsionio.datasource.DataSource = None, file_name: str = None, dataframe: pandas.core.frame.DataFrame = None, **kwargs)

Register a new dataset in the workspace for further processing. You need to provide either a datasource, a file name or a dataframe (only one can be specified).

Note

To start a new use case on a dataset, it has to be already registred in your workspace.

Parameters:
  • name (str) – Registration name for the dataset
  • datasource (DataSource, optional) – A DataSource object used to import a remote dataset (if you want to import a specific dataset from an existent database, you need a datasource connector (Connector object) designed to point to the related data source)
  • file_name (str, optional) – Path to a file to upload as dataset
  • dataframe (pd.DataFrame, optional) – A pandas dataframe containing the data to upload
Raises:
  • Exception – If more than one of the keyword arguments datasource, file_name, dataframe was specified
  • PrevisionException – Error while creating the dataset on the platform
Returns:

The registered dataset object in the current workspace.

Return type:

Dataset

create_datasource(connector: previsionio.connector.Connector, name: str, path: str = None, database: str = None, table: str = None, bucket: str = None, request: str = None, gCloud: previsionio.connector.GCloud = None)

Create a new datasource object on the platform.

Parameters:
  • connector (Connector) – Reference to the associated connector (the resource to go through to get a data snapshot)
  • name (str) – Name of the datasource
  • path (str, optional) – Path to the file to fetch via the connector
  • database (str, optional) – Name of the database to fetch data from via the connector
  • table (str, optional) – Name of the table to fetch data from via the connector
  • bucket (str, optional) – Name of the bucket to fetch data from via the connector
  • gCloud (GCloud, optional) – Type of google cloud service
  • request (str, optional) – Direct SQL request to use with the connector to fetch data
Returns:

The registered datasource object in the current project

Return type:

DataSource

Raises:
  • PrevisionException – Any error while uploading data to the platform or parsing the result
  • Exception – For any other unknown error
create_exporter(connector: previsionio.connector.Connector, name: str, description: str = None, path: str = None, bucket: str = None, database: str = None, table: str = None, g_cloud: previsionio.connector.GCloud = None, write_mode: previsionio.exporter.ExporterWriteMode = <ExporterWriteMode.safe: 'safe'>)

Create a new exporter object on the platform.

Parameters:
  • connector (Connector) – Reference to the associated connector (the resource to go through to get a data snapshot)
  • name (str) – Name of the exporter
  • description (str, optional) – Description of the exporter
  • bucket (str, optional) – Bucket of the file to write on via the exporter
  • path (str, optional) – Path to the file to write on via the exporter
  • database (str, optional) – Name of the database to write on via the exporter
  • table (str, optional) – Name of the table to write on via the exporter
  • g_cloud (GCloud, optional) – Type of google cloud service
  • write_mode (ExporterWriteMode, optional) – Write mode
Returns:

The registered exporter object in the current project

Return type:

Exporter

Raises:
  • PrevisionException – Any error while uploading data to the platform or parsing the result
  • Exception – For any other unknown error
create_ftp_connector(name: str, host: str, port: int = 21, username: str = '', password: str = '')

A connector to interact with a distant source of data (and easily get data snapshots using an associated DataSource resource).

Parameters:
  • name (str) – Name of the connector
  • host (str) – Url of the connector
  • port (int) – Port of the connector
  • username (str, optional) – Username to use connect to the remote data source
  • password (str, optional) – Password to use connect to the remote data source
Returns:

The registered connector object in the current project.

Return type:

FTPConnector

create_gcp_connector(name: str = '', host: str = '', port=None, username: str = '', password: str = '', googleCredentials: str = '')

A connector to interact with a distant source of data (and easily get data snapshots using an associated DataSource resource).

Parameters:
  • name (str) – Name of the connector
  • googleCredentials (str) – google credentials
Returns:

The registered connector object in the current project.

Return type:

GCPConnector

create_image_folder(name: str, file_name: str)

Register a new image dataset in the workspace for further processing (in the image folders group).

Note

To start a new use case on a dataset image, it has to be already registred in your workspace.

Parameters:
  • name (str) – Registration name for the dataset
  • file_name (str) – Path to the zip file to upload as image dataset
Raises:

PrevisionException – Error while creating the dataset on the platform

Returns:

The registered dataset object in the current workspace.

Return type:

DatasetImages

create_s3_connector(name: str, host: str = '', port: int = None, username: str = '', password: str = '')

A connector to interact with a distant source of data (and easily get data snapshots using an associated DataSource resource).

Parameters:
  • name (str) – Name of the connector
  • host (str) – Url of the connector
  • port (int) – Port of the connector
  • username (str, optional) – Username to use connect to the remote data source
  • password (str, optional) – Password to use connect to the remote data source
Returns:

The registered connector object in the current project.

Return type:

S3Connector

create_sftp_connector(name: str, host: str, port: int = 23, username: str = '', password: str = '')

A connector to interact with a distant source of data (and easily get data snapshots using an associated DataSource resource).

Parameters:
  • name (str) – Name of the connector
  • host (str) – Url of the connector
  • port (int) – Port of the connector
  • username (str, optional) – Username to use connect to the remote data source
  • password (str, optional) – Password to use connect to the remote data source
Returns:

The registered connector object in the current project.

Return type:

SFTPConnector

create_sql_connector(name: str, host: str, port: int = 3306, username: str = '', password: str = '')

A connector to interact with a distant source of data (and easily get data snapshots using an associated DataSource resource).

Parameters:
  • name (str) – Name of the connector
  • host (str) – Url of the connector
  • port (int) – Port of the connector
  • username (str, optional) – Username to use connect to the remote data source
  • password (str, optional) – Password to use connect to the remote data source
Returns:

The registered connector object in the current project.

Return type:

SQLConnector

delete()

Delete a project from the actual [client] workspace.

Raises:
  • PrevisionException – If the project does not exist
  • requests.exceptions.ConnectionError – Error processing the request
fit_classification(name: str, dataset: previsionio.dataset.Dataset, column_config: previsionio.usecase_config.ColumnConfig, metric: previsionio.metrics.Classification = <Classification.AUC: 'auc'>, holdout_dataset=None, training_config=<previsionio.usecase_config.TrainingConfig object>, **kwargs)

Start a tabular classification usecase version training

Parameters:
  • name (str) – Name of the usecase to create
  • dataset (Dataset) – 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 (metrics.Classification, 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)
Returns:

Newly created Classification usecase version object

Return type:

supervised.Classification

fit_image_classification(name: str, dataset: Tuple[previsionio.dataset.Dataset, previsionio.dataset.DatasetImages], column_config: previsionio.usecase_config.ColumnConfig, metric: previsionio.metrics.Classification = <Classification.AUC: 'auc'>, holdout_dataset: previsionio.dataset.Dataset = None, training_config=<previsionio.usecase_config.TrainingConfig object>, **kwargs)

Start an image classification usecase version training

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 (metrics.Classification, 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)
Returns:

Newly created ClassificationImages usecase version object

Return type:

supervised.ClassificationImages

fit_image_multiclassification(name: str, dataset: Tuple[previsionio.dataset.Dataset, previsionio.dataset.DatasetImages], column_config: previsionio.usecase_config.ColumnConfig, metric: previsionio.metrics.MultiClassification = <MultiClassification.log_loss: 'log_loss'>, holdout_dataset: previsionio.dataset.Dataset = None, training_config=<previsionio.usecase_config.TrainingConfig object>, **kwargs) → previsionio.supervised.Supervised

Start an image multiclassification usecase version training

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 (metrics.MultiClassification, optional) – Specific metric to use for the usecase (default: metrics.MultiClassification.log_loss)
  • 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)
Returns:

Newly created MultiClassificationImages usecase version

object

Return type:

supervised.MultiClassificationImages

fit_image_regression(name: str, dataset: Tuple[previsionio.dataset.Dataset, previsionio.dataset.DatasetImages], column_config: previsionio.usecase_config.ColumnConfig, metric: previsionio.metrics.Regression = <Regression.RMSE: 'rmse'>, holdout_dataset: previsionio.dataset.Dataset = None, training_config=<previsionio.usecase_config.TrainingConfig object>, **kwargs)

Start an image regression usecase version training

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 (metrics.Regression, 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)
Returns:

Newly created RegressionImages usecase version object

Return type:

supervised.RegressionImages

fit_multiclassification(name: str, dataset: previsionio.dataset.Dataset, column_config: previsionio.usecase_config.ColumnConfig, metric: previsionio.metrics.MultiClassification = <MultiClassification.log_loss: 'log_loss'>, holdout_dataset: previsionio.dataset.Dataset = None, training_config=<previsionio.usecase_config.TrainingConfig object>, **kwargs)

Start a tabular multiclassification usecase version training

Parameters:
  • name (str) – Name of the usecase to create
  • dataset (Dataset) – 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 (metrics.MultiClassification, 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)
Returns:

Newly created MultiClassification usecase version object

Return type:

supervised.MultiClassification

fit_regression(name: str, dataset: previsionio.dataset.Dataset, column_config: previsionio.usecase_config.ColumnConfig, metric: previsionio.metrics.Regression = <Regression.RMSE: 'rmse'>, holdout_dataset=None, training_config=<previsionio.usecase_config.TrainingConfig object>, **kwargs)

Start a tabular regression usecase version training

Parameters:
  • name (str) – Name of the usecase to create
  • dataset (Dataset) – 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 (metrics.Regression, 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)
Returns:

Newly created Regression usecase version object

Return type:

supervised.Regression

fit_text_similarity(name: str, dataset: previsionio.dataset.Dataset, description_column_config: previsionio.text_similarity.DescriptionsColumnConfig, metric: previsionio.metrics.TextSimilarity = <TextSimilarity.accuracy_at_k: 'accuracy_at_k'>, top_k: int = 10, lang: previsionio.text_similarity.TextSimilarityLang = <TextSimilarityLang.Auto: 'auto'>, queries_dataset: previsionio.dataset.Dataset = None, queries_column_config: previsionio.text_similarity.QueriesColumnConfig = None, models_parameters: previsionio.text_similarity.ListModelsParameters = <previsionio.text_similarity.ListModelsParameters object>)

Start a text similarity usecase training with a specific training configuration.

Parameters:
  • name (str) – Name of the usecase to create
  • dataset (Dataset) – Reference to the dataset object to use for as training dataset
  • description_column_config (DescriptionsColumnConfig) – Description column configuration (see the documentation of the DescriptionsColumnConfig resource for more details on each possible column types)
  • metric (metrics.TextSimilarity, optional) – Specific metric to use for the usecase (default: accuracy_at_k)
  • top_k (int, optional) – top_k (default: 10)
  • queries_dataset (Dataset, optional) – Reference to a dataset object to use as a queries dataset (default: None)
  • queries_column_config (QueriesColumnConfig) – Queries column configuration (see the documentation of the QueriesColumnConfig resource for more details on each possible column types)
  • models_parameters (ListModelsParameters) – Specific training configuration (see the documentation of the ListModelsParameters resource for more details on all the parameters)
Returns:

Newly created TextSimilarity usecase version object

Return type:

previsionio.text_similarity.TextSimilarity

fit_timeseries_regression(name: str, dataset: previsionio.dataset.Dataset, column_config: previsionio.usecase_config.ColumnConfig, time_window: previsionio.timeseries.TimeWindow, metric: previsionio.metrics.Regression = <Regression.RMSE: 'rmse'>, holdout_dataset: previsionio.dataset.Dataset = None, training_config=<previsionio.usecase_config.TrainingConfig object>) → previsionio.timeseries.TimeSeries

Start a timeseries regression usecase version training

Parameters:
  • name (str) – Name of the usecase to create
  • dataset (Dataset) – Reference to the dataset object to use for as training dataset
  • column_config (ColumnConfig) – Column configuration for the usecase version (see the documentation of the ColumnConfig resource for more details on each possible column types)
  • time_window (TimeWindow) – Time configuration (see the documentation of the TimeWindow resource for more details)
  • metric (metrics.Regression, optional) – Specific metric to use for the usecase (default: metrics.Regression.RMSE)
  • 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)
Returns:

Newly created TimeSeries usecase version object

Return type:

TimeSeries

classmethod from_id(_id: str)

Get a project from the instance by its unique id.

Parameters:_id (str) – Unique id of the resource to retrieve
Returns:The fetched datasource
Return type:Project
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
info() → Dict

Get a datasource from the instance by its unique id.

Parameters:_id (str) – Unique id of the resource to retrieve
Returns:
Information about the Project with these entries:
”_id” “name” “description” “color” “created_by” “admins” “contributors” “viewers” “pipelines_count” “usecases_count” “dataset_count” “users”
Return type:Dict
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
classmethod list(all: bool = False)

List all the available project in the current active [client] workspace.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched project objects
Return type:list(Project)
list_connectors(all: bool = True)

List all the available connectors in the current active project.

Warning

Contrary to the parent list() function, this method returns actual Connector objects rather than plain dictionaries with the corresponding data.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched dataset objects
Return type:list(Connector)
list_datasets(all: bool = True)

List all the available datasets in the current active project.

Warning

Contrary to the parent list() function, this method returns actual Dataset objects rather than plain dictionaries with the corresponding data.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched dataset objects
Return type:list(Dataset)
list_datasource(all: bool = False)

List all the available datasources in the current active project.

Warning

Contrary to the parent list() function, this method returns actual DataSource objects rather than plain dictionaries with the corresponding data.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched dataset objects
Return type:list(DataSource)
list_exporter(all: bool = False)

List all the available exporters in the current active project.

Warning

Contrary to the parent list() function, this method returns actual Exporter objects rather than plain dictionaries with the corresponding data.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched dataset objects
Return type:list(Exporter)
list_image_folders(all: bool = True)

List all the available dataset image in the current active [client] workspace.

Warning

Contrary to the parent list() function, this method returns actual DatasetImages objects rather than plain dictionaries with the corresponding data.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched dataset objects
Return type:list(DatasetImages)
list_usecase_deployments(all: bool = True)

List all the available usecase in the current project.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched usecase deployment objects
Return type:list(UsecaseDeployment)
list_usecases(all: bool = True)

List all the available usecase in the current project.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched usecase objects
Return type:list(Usecase)
classmethod new(name: str, description: str = None, color: previsionio.project.ProjectColor = None) → previsionio.project.Project

Create a new project on the platform.

Parameters:
  • name (str) – Name of the project
  • description (str, optional) – Description of the project
  • color (str, optional) – Color of the project
Returns:

The registered project object in the current workspace

Return type:

Project

Raises:
  • PrevisionException – Any error while uploading data to the platform or parsing the result
  • Exception – For any other unknown error
users()

Get a project from the instance by its unique id.

Parameters:_id (str) – Unique id of the resource to retrieve
Returns:The fetched datasource
Return type:Project
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
class previsionio.project.ProjectColor

Bases: enum.Enum

An enumeration.