Project#
- class skore.Project(name, **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.Two mutually exclusive modes are available and can be configured using the
nameparameter of the constructor:Hub mode
If the
nametakes the form of the URIhub://<tenant>/<name>, the project is configured to thehubmode to communicate with theskore hub.A tenant is a
skore 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.In this mode, you must have an account to the
skore huband must be authorized to the specified tenant. You must also be authenticated beforehand, using theskore-hub-loginCLI.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}/.cache/skore,on macOS, usually
${HOME}/Library/Caches/skore.
Refer to the Storing data science artifacts section of the user guide for more details.
- Parameters:
- namestr
The name of the project:
if the
nametakes the form of the URIhub://<tenant>/<name>, the project is configured to communicate with theskore hub,otherwise, the project is configured to communicate with a local storage, on the user machine.
- **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.
- Attributes:
See also
MetadataDataFrame designed 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.sklearn import 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, >>> )
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("my-xp", workspace=Path(tmpdir))
Put reports in the project.
>>> local_project.put("my-simple-classification", classifier_report) >>> local_project.put("my-simple-regression", regressor_report)
Investigate metadata/metrics to filter the best reports.
>>> summary = local_project.summarize() >>> summary = summary.query("ml_task.str.contains('regression') and (rmse < 67)") >>> reports = summary.reports()
- static delete(name, **kwargs)[source]#
Delete a project.
- Parameters:
- namestr
The name of the project:
if the
nametakes the form of the URIhub://<tenant>/<name>, the project is configured to communicate with theskore hub,otherwise, the project is configured to communicate with a local storage, on the user machine.
- **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.
- 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.- reportskore.EstimatorReport
The report to associate with
keyin the project.
- Raises:
- TypeError
If the combination of parameters are not valid.