Skip to content

Models

Model

Model(
    library=None,
    technique=None,
    metrics=None,
    properties=None,
    name=None,
    attachments=None,
    predictor=None,
    derived_from=None,
    additional_info=None,
)

Represent a wrapped model.

To document models within an iteration, you need to wrap it as a Vectice model. It involves capturing metadata about the predictor. This metadata enables Vectice to provide summaries and insights about the model.

A Vectice Model is a wrapped predictor that can be logged inside a Vectice iteration.

Parameters:

Name Type Description Default
library str | None

The library used to generate the model.

None
technique str | None

The modeling technique used.

None
metrics dict[str, int | float] | list[Metric] | Metric | None

A dict for example {"MSE": 1}.

None
properties dict[str, str | int] | list[Property] | Property | None

A dict, for example {"folds": 32}.

None
name str | None

The model name. If None, will be auto-generated by Vectice.

None
attachments TAttachment | None

The file paths that will be attached to the iteration along with the predictor.

None
predictor Any

The predictor.

None
derived_from list[TDerivedFrom] | None

List of dataset versions or model versions (or their ids) to link as lineage.

None
additional_info dict[str, str] | AdditionalInfo | None

An optional set of key values related to the context in which the model was created. For instance if an experiment tracker was used or a specific framework.

None

additional_info

additional_info(additional_info)

Attach an additional info to the model.

Parameters:

Name Type Description Default
additional_info dict[str, str] | AdditionalInfo

The additional information to be passed to the model linked to Experiment Trackers or other context in which the model was created.

required

attachments

attachments(attachments)

Attach a file or files to the model.

Parameters:

Name Type Description Default
attachments TAttachment

The filename or filenames of the file or set of files to attach to the model.

required

derived_from

derived_from()

The datasets versions or models versions from which this model is derived.

Returns:

Type Description
list[str]

The datasets versions or models versions from which this model is derived.

latest_version_id

latest_version_id(value)

Set the id of the latest version of this model.

Parameters:

Name Type Description Default
value str

The id of the latest version of this model.

required

library

library(library)

Set the name of the library used to create the model.

Parameters:

Name Type Description Default
library str

The name of the library used to create the model.

required

metrics

metrics(metrics)

Set the model's metrics.

Parameters:

Name Type Description Default
metrics dict[str, int | float] | list[Metric] | Metric | None

The metrics of the model.

required

mlflow staticmethod

mlflow(run_id, client, url=None, derived_from=None)

Extract automatically information from an Mlflow run into a Vectice model to be assigned to an iteration.

import mlflow
from mlflow.client import MlflowClient
from vectice import Model

model = Model.mlflow(
        run_id="d479ca87954f4a0abc4da3333b990cb3",
        client=MlflowClient() #also work with client=mlflow
    )

Parameters:

Name Type Description Default
run_id str

The run id of the mlflow model to be wrapped.

required
client MlflowClient

The mlflow client in order to access the run through get_run() method. WARNING: the client should have the tracking URI where the run is located.

required
url str | None

The Mlflow UI URL to access the run info.

None
derived_from list[TDerivedFrom] | None

List of dataset versions or model versions (or their ids) to link as lineage.

None

name

name(name)

Set the model's name.

Parameters:

Name Type Description Default
name str

The name of the model.

required

predictor

predictor(predictor)

Set the model's predictor.

Parameters:

Name Type Description Default
predictor Any

The predictor of the model.

required

properties

properties(properties)

Set the model's properties.

Parameters:

Name Type Description Default
properties dict[str, str | int] | list[Property] | Property | None

The properties of the model.

required

technique

technique(technique)

Set the name of the modeling technique used to learn the model.

Parameters:

Name Type Description Default
technique str

The modeling technique used.

required