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()
,metadata()
andget()
, respectively to insert a key-report pair into the project, to obtain the metadata 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
name
parameter of the constructor:mode : hub
If the
name
takes the form of the URIhub://<tenant>/<name>
, the project is configured to thehub
mode to communicate with theskore hub
.A tenant is a
skore hub
concept that must be configured on theskore hub
interface. 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 hub
and must be authorized to the specified tenant. You must also be authenticated beforehand, using theskore-hub-login
CLI.mode : local
Otherwise, the project is configured to the
local
mode 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 envar
SKORE_WORKSPACE
. If not, it will be by default set to askore/
directory in the USER cache directory:in Windows, usually
C:\Users\%USER%\AppData\Local\skore
,in Linux, usually
${HOME}/.cache/skore
,in macOS, usually
${HOME}/Library/Caches/skore
.
- Parameters:
- namestr
The name of the project:
if the
name
takes 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 envar
SKORE_WORKSPACE
. If not, it will be by default set to askore/
directory in the USER cache directory:in Windows, usually
C:\Users\%USER%\AppData\Local\skore
,in Linux, usually
${HOME}/.cache/skore
,in macOS, usually
${HOME}/Library/Caches/skore
.
- Attributes:
See also
Metadata
DataFrame 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.
>>> metadata = local_project.reports.metadata() >>> metadata = metadata.query("ml_task.str.contains('regression') and (rmse < 67)") >>> reports = metadata.reports()
- 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
report
in the project.- reportskore.EstimatorReport
The report to associate with
key
in the project.
- Raises:
- TypeError
If the combination of parameters are not valid.
- property reports#
Accessor for interaction with the persisted reports.