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 argumentsdatasource
,file_name
,dataframe
was specifiedPrevisionException
– Error while creating the dataset on the platform
Returns: The registered dataset object in the current workspace.
Return type:
-
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: Raises: PrevisionException
– Any error while uploading data to the platform or parsing the resultException
– For any other unknown error
- connector (
-
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: Raises: PrevisionException
– Any error while uploading data to the platform or parsing the resultException
– For any other unknown error
- connector (
-
create_external_classification
()¶ Create a tabular classification usecase version from external models
Parameters: - usecase_name (str) – Name of the usecase to create
- holdout_dataset (
Dataset
) – Reference to the holdout dataset object to use for as holdout dataset - target_column – The name of the target column for this usecase version
- external_models (list(tuple)) – the external models to add in the usecase version to create Each tuple contains 3 items describing an external model as follows: - name of the model - a path to the model in onnx format - a path to a yaml file containing metadata about the model
- metric (str, optional) – Specific metric to use for the usecase (default:
auc
) - dataset (
Dataset
, optional) – Reference to the dataset object that has been used to train the model (default:None
) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created ExternalUsecaseVersion object
Return type: external_models.ExternalUsecaseVersion
-
create_external_multiclassification
()¶ Create a tabular multiclassification usecase version from external models
Parameters: - usecase_name (str) – Name of the usecase to create
- holdout_dataset (
Dataset
) – Reference to the holdout dataset object to use for as holdout dataset - target_column – The name of the target column for this usecase version
- external_models (list(tuple)) – the external models to add in the usecase version to create Each tuple contains 3 items describing an external model as follows: - name of the model - a path to the model in onnx format - a path to a yaml file containing metadata about the model
- metric (str, optional) – Specific metric to use for the usecase (default:
log_loss
) - dataset (
Dataset
, optional) – Reference to the dataset object that has been used to train the model (default:None
) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created ExternalUsecaseVersion object
Return type: external_models.ExternalUsecaseVersion
-
create_external_regression
()¶ Create a tabular regression usecase version from external models
Parameters: - usecase_name (str) – Name of the usecase to create
- holdout_dataset (
Dataset
) – Reference to the holdout dataset object to use for as holdout dataset - target_column – The name of the target column for this usecase version
- external_models (list(tuple)) – the external models to add in the usecase version to create Each tuple contains 3 items describing an external model as follows: - name of the model - a path to the model in onnx format - a path to a yaml file containing metadata about the model
- metric (str, optional) – Specific metric to use for the usecase (default:
rmse
) - dataset (
Dataset
, optional) – Reference to the dataset object that has been used to train the model (default:None
) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created ExternalUsecaseVersion object
Return type: external_models.ExternalUsecaseVersion
-
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: Returns: The registered connector object in the current project.
Return type:
-
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: Returns: The registered connector object in the current project.
Return type:
-
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: Raises: PrevisionException
– Error while creating the dataset on the platformReturns: The registered dataset object in the current workspace.
Return type:
-
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: Returns: The registered connector object in the current project.
Return type:
-
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: Returns: The registered connector object in the current project.
Return type:
-
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: Returns: The registered connector object in the current project.
Return type:
-
delete
()¶ Delete a project from the actual [client] workspace.
Raises: PrevisionException
– If the project does not existrequests.exceptions.ConnectionError
– Error processing the request
-
fit_classification
(usecase_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>, usecase_version_description: str = None)¶ Start a tabular classification usecase version training
Parameters: - usecase_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 theColumnConfig
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 theTrainingConfig
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created Supervised usecase version object
Return type:
-
fit_image_classification
(usecase_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=None, training_config=<previsionio.usecase_config.TrainingConfig object>, usecase_version_description: str = None)¶ Start an image classification usecase version training
Parameters: - usecase_name (str) – Name of the usecase to create
- dataset (
Dataset
,DatasetImages
) – Reference to the datasets objects to use for as training datasets - column_config (
ColumnConfig
) – Column configuration for the usecase (see the documentation of theColumnConfig
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 theTrainingConfig
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created Supervised usecase version object
Return type:
-
fit_image_multiclassification
(usecase_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=None, training_config=<previsionio.usecase_config.TrainingConfig object>, usecase_version_description: str = None)¶ Start an image multiclassification usecase version training
Parameters: - usecase_name (str) – Name of the usecase to create
- dataset (
Dataset
,DatasetImages
) – Reference to the datasets objects to use for as training datasets - column_config (
ColumnConfig
) – Column configuration for the usecase (see the documentation of theColumnConfig
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 theTrainingConfig
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created Supervised usecase version object
Return type:
-
fit_image_regression
(usecase_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=None, training_config=<previsionio.usecase_config.TrainingConfig object>, usecase_version_description: str = None)¶ Start an image regression usecase version training
Parameters: - usecase_name (str) – Name of the usecase to create
- dataset (
Dataset
,DatasetImages
) – Reference to the datasets objects to use for as training datasets - column_config (
ColumnConfig
) – Column configuration for the usecase (see the documentation of theColumnConfig
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 theTrainingConfig
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created Supervised usecase version object
Return type:
-
fit_multiclassification
(usecase_name: str, dataset: previsionio.dataset.Dataset, column_config: previsionio.usecase_config.ColumnConfig, metric: previsionio.metrics.MultiClassification = <MultiClassification.log_loss: 'log_loss'>, holdout_dataset=None, training_config=<previsionio.usecase_config.TrainingConfig object>, usecase_version_description: str = None)¶ Start a tabular multiclassification usecase version training
Parameters: - usecase_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 theColumnConfig
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 theTrainingConfig
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created Supervised usecase version object
Return type:
-
fit_regression
(usecase_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>, usecase_version_description: str = None)¶ Start a tabular regression usecase version training
Parameters: - usecase_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 theColumnConfig
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 theTrainingConfig
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created Supervised usecase version object
Return type:
-
fit_text_similarity
(usecase_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>, usecase_version_description: str = None)¶ Start a text similarity usecase version training with a specific training configuration.
Parameters: - usecase_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 theDescriptionsColumnConfig
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 theQueriesColumnConfig
resource for more details on each possible column types) - models_parameters (
ListModelsParameters
) – Specific training configuration (see the documentation of theListModelsParameters
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created TextSimilarity usecase version object
Return type:
-
fit_timeseries_regression
(usecase_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>, usecase_version_description: str = None) → previsionio.timeseries.TimeSeries¶ Start a timeseries regression usecase version training
Parameters: - usecase_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 theColumnConfig
resource for more details on each possible column types) - time_window (
TimeWindow
) – Time configuration (see the documentation of theTimeWindow
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 theTrainingConfig
resource for more details on all the parameters) - usecase_version_description (str) – Description of the usecase version to create
Returns: Newly created TimeSeries usecase version object
Return type:
-
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 actualConnector
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 actualDataset
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 actualDataSource
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 actualExporter
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 actualDatasetImages
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: Returns: The registered project object in the current workspace
Return type: Raises: PrevisionException
– Any error while uploading data to the platform or parsing the resultException
– For any other unknown error