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(),get(), andsync(), respectively to insert a key-report pair into the project, obtain the metadata/metrics of the inserted reports, get a specific report by its id, and synchronize reports between projects.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,
workspaceis 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 called aworkspace.The workspace can be set using kwargs or the environment variableSKORE_WORKSPACE.If not, it will be set to a default location:we search the current working directory and its parents for a skore workspace: a directory named ‘skore’ containing a file named ‘.SKORE_WORKSPACE’. If found, use that.
- otherwise if we are in a Git repository, create ‘skore’ at the root
of the repository.
otherwise create ‘skore’ in the current working directory.
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.
workspace : str or Path-like, optional
If
mode="hub", the Hub workspace name (required);If
mode="local", the local persistence directory (optional);If
mode="mlflow", ignored.
- tracking_uristr, mode:mlflow only.
The URI of the MLflow tracking server.
- Attributes:
namestrThe name of the project.
mode{“hub”, “local”, “mlflow”}The mode of the project.
workspacePath or str or NoneThe workspace for local and hub modes;
Noneotherwise.tracking_uristr or NoneThe MLflow tracking URI for mlflow mode;
Noneotherwise.- ml_taskMLTask
The ML task of the project; unset until a first report is put.
See also
SummaryTabular view of metadata and metrics for persisted reports.
compare()Compare reports side by side.
Project.summarize()Create a summary view to investigate persisted reports’ metadata/metrics.
Examples
Construct reports.
>>> from sklearn.datasets import make_regression >>> from sklearn.linear_model import LinearRegression >>> from skore import evaluate >>> >>> X, y = make_regression(random_state=42) >>> regressor = LinearRegression() >>> regressor_report = evaluate(regressor, X, y, splitter=0.2)
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(name="my-xp", mode="local", workspace=Path(tmpdir))
Put reports in the project.
>>> local_project.put("my-simple-regression", regressor_report)
Investigate metadata/metrics to filter the best reports.
>>> summary = local_project.summarize() >>> summary = summary.query("rmse < 67") >>> reports = summary.compare()
- static delete(name, *, mode='local', **kwargs)[source]#
Delete a project.
- 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.
- workspacestr or Path-like, optional
See the
Projectclass docstring for details.- 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. Theidpassed here must match theidcolumn returned byProject.summarize().- Parameters:
- idstr
The id of a report already put in the
project.
- Returns:
- reportEstimatorReport or CrossValidationReport
The report associated with
id.
Examples
>>> from sklearn.datasets import make_regression >>> from sklearn.linear_model import LinearRegression >>> from pathlib import Path >>> from tempfile import TemporaryDirectory >>> from skore import Project, evaluate >>> X, y = make_regression(random_state=42) >>> report = evaluate(LinearRegression(), X, y, splitter=0.2) >>> tmpdir = TemporaryDirectory() >>> project = Project(name="my-xp", mode="local", workspace=Path(tmpdir.name)) >>> project.put("my-regression", report) >>> summary = project.summarize() >>> report_id = summary.frame().index.get_level_values("id")[0] >>> retrieved = project.get(report_id) >>> type(retrieved).__name__ 'EstimatorReport' >>> tmpdir.cleanup()
- 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.
- Returns:
- None
The report is persisted in the project backend.
Examples
>>> from sklearn.datasets import make_regression >>> from sklearn.linear_model import LinearRegression >>> from pathlib import Path >>> from tempfile import TemporaryDirectory >>> from skore import Project, evaluate >>> X, y = make_regression(random_state=42) >>> report = evaluate(LinearRegression(), X, y, splitter=0.2) >>> tmpdir = TemporaryDirectory() >>> project = Project(name="my-xp", mode="local", workspace=Path(tmpdir.name)) >>> project.put("my-regression", report) >>> tmpdir.cleanup()
- summarize()[source]#
Obtain metadata/metrics for all persisted reports.
Reports are returned in ascending order of their
datefield.- Returns:
- summarySummary
Metadata and metrics for every report persisted in the project.
- sync(other, *, bidirectional=False, dry_run=False, **kwargs)[source]#
Copy missing reports to another project.
Reports are matched using the
report_idcolumn returned byProject.summarize().frame(). Setbidirectional=Trueto copy missing reports in both directions.- Parameters:
- otherProject or {“hub”, “local”, “mlflow”}
Destination project. When a mode is given, build the destination with this project’s name and the mode-specific keyword arguments.
- bidirectionalbool, default=False
If
False, transfer reports from this project toother. IfTrue, also transfer reports missing from this project.- dry_runbool, default=False
Return the planned operations without loading or storing reports.
- **kwargsdict
Mode-specific arguments used to build the destination when
otheris a mode string. For example, passworkspacefor"hub"ortracking_urifor"mlflow".
- Returns:
- resultpandas.DataFrame
Synchronization status indexed by
report_id. Thedirectioncolumn is"outbound"from this project toother,"inbound"fromotherto this project, or missing for skipped reports. Thestatuscolumn is"planned","transferred", or"skipped".
- property tracking_uri#
The MLflow tracking URI for mlflow mode;
Noneotherwise.
- property workspace#
The workspace for local and hub modes;
Noneotherwise.