Project#
- class skore.Project(name, *, mode='local', **kwargs)[source]#
API to manage a collection of key-report pairs.
Its constructor initializes a project by creating a new project or by loading an existing one.
The class main methods are
put(),summarize()andget(), respectively to insert a key-report pair into the project, to obtain the metadata/metrics of the inserted reports and to get a specific report by its id.Three mutually exclusive modes are available and can be configured using the
modeparameter of the constructor:Hub mode
The project is configured to communicate with
skore hub.In this mode,
nameis expected to be of the form<workspace>/<name>, where the workspace is askore hubconcept that must be configured on theskore hubinterface. It represents an isolated entity managing users, projects, and resources. It can be a company, organization, or team that operates independently within the system.Note: Using Project in
hubmode requires an account onskore hub, with access rights to the specified workspace. Authentication toskore hubis done by runningskore.login()before instantiating the Project.Local mode
Otherwise, the project is configured to the
localmode to be persisted on the user machine in a directory calledworkspace.The workspace can be shared between all the projects.The workspace can be set using kwargs or the environment variableSKORE_WORKSPACE.If not, it will be by default set to askore/directory in the user cache directory:on Windows, usually
C:\Users\%USER%\AppData\Local\skore,on Linux, usually
${HOME}/.local/share/skore,on macOS, usually
${HOME}/Library/Application Support/skore.
MLflow mode
In this mode,
nameis used as the MLflow experiment name. Reports are persisted as MLflow model artifacts in runs created under this experiment.Refer to the Storing data science artifacts section of the user guide for more details.
- Parameters:
- namestr
The name of the project.
- mode{“hub”, “local”, “mlflow”}
The mode of the project.
- **kwargsdict
Extra keyword arguments passed to the project, depending on its mode.
- workspacePath, mode:local only.
The directory where the local project is persisted.
- Attributes:
See also
Project.summarize()Create a summary view to investigate persisted reports’ metadata/metrics.
Examples
Construct reports.
>>> from sklearn.datasets import make_classification, make_regression >>> from sklearn.linear_model import LinearRegression, LogisticRegression >>> from sklearn.model_selection import train_test_split >>> from skore import CrossValidationReport, EstimatorReport >>> >>> X, y = make_classification(random_state=42) >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) >>> classifier = LogisticRegression(max_iter=10) >>> classifier_report = EstimatorReport( >>> classifier, >>> X_train=X_train, >>> y_train=y_train, >>> X_test=X_test, >>> y_test=y_test, >>> ) >>> >>> X, y = make_regression(random_state=42) >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) >>> regressor = LinearRegression() >>> regressor_report = EstimatorReport( >>> regressor, >>> X_train=X_train, >>> y_train=y_train, >>> X_test=X_test, >>> y_test=y_test, >>> ) >>> >>> cv_regressor_report = CrossValidationReport(regressor, X, y)
Construct the project in local mode, persisted in a temporary directory.
>>> from pathlib import Path >>> from tempfile import TemporaryDirectory >>> from skore import Project >>> >>> tmpdir = TemporaryDirectory().name >>> local_project = Project(mode="local", name="my-xp", workspace=Path(tmpdir))
Put reports in the project.
>>> local_project.put("my-simple-regression", regressor_report) >>> local_project.put("my-simple-cv_regression", cv_regressor_report)
Investigate metadata/metrics to filter the best reports.
>>> summary = local_project.summarize() >>> summary = summary.query("rmse < 67") >>> reports = summary.reports()
- static delete(name, *, mode='local', **kwargs)[source]#
Delete a project. Not implemented for MLFlow projects.
- Parameters:
- namestr
The name of the project.
- mode{“hub”, “local”, “mlflow”}, default “local”
The mode of the project.
- **kwargsdict
Extra keyword arguments passed to the project, depending on its mode.
- workspacePath, mode:local only.
The directory where the local project is persisted.
The workspace can be shared between all the projects.The workspace can be set using kwargs or the environment variableSKORE_WORKSPACE.If not, it will be by default set to askore/directory in the USER cache directory:on Windows, usually
C:\Users\%USER%\AppData\Local\skore,on Linux, usually
${HOME}/.cache/skore,on macOS, usually
${HOME}/Library/Caches/skore.
- tracking_uristr, mode:mlflow only.
The URI of the MLflow tracking server.
- get(id)[source]#
Get a persisted report by its id.
Report IDs can be found via
skore.Project.summarize(), which is also the preferred method of interacting with askore.Project.- Parameters:
- idstr
The id of a report already put in the
project.
- Raises:
- KeyError
If a non-existent ID is passed.
- property mode#
The mode of the project.
- property name#
The name of the project.
- put(key, report)[source]#
Put a key-report pair to the project.
If the key already exists, its last report is modified to point to this new report, while keeping track of the report history.
- Parameters:
- keystr
The key to associate with
reportin the project. Name of the run for mode:mlflow- reportEstimatorReport | CrossValidationReport
The report to associate with
keyin the project.
- Raises:
- TypeError
If the combination of parameters are not valid.