Skip to content

Models

Model

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

Represent a wrapped model.

Iteration steps that represent models require a wrapped model. Wrapped models present Vectice with a learned predictor and appropriate metadata about that predictor in order to summarize the model in views of the iteration.

A Vectice Model is a wrapped predictor suitable for assignment to a Vectice Step.

Parameters:

Name Type Description Default
library str

The library used to generate the model.

required
technique str

The modeling technique used.

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

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

None
properties dict[str, str] | dict[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 based on the library and technique.

None
attachments str | list[str] | None

Path of a file that will be attached to the step along with the predictor.

None
predictor Any

The predictor.

None
derived_from list[int] | None

List of dataset version ids to link as lineage.

None
inputs list[int] | None

Deprecated. Use derived_from instead.

None
Source code in src/vectice/models/model.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@deprecate(
    parameter="inputs",
    warn_at="23.1",
    fail_at="23.2",
    remove_at="23.3",
    reason="The 'inputs' parameter is renamed 'derived_from'. "
    "Using 'inputs' will raise an error in v{fail_at}. "
    "The parameter will be removed in v{remove_at}.",
)
def __init__(
    self,
    library: str,
    technique: str,
    metrics: dict[str, int] | list[Metric] | Metric | None = None,
    properties: dict[str, str] | dict[str, int] | list[Property] | Property | None = None,
    name: str | None = None,
    attachments: str | list[str] | None = None,
    predictor: Any = None,
    derived_from: list[int] | None = None,
    inputs: list[int] | None = None,
):
    """Wrap a model (predictor).

    A Vectice Model is a wrapped predictor suitable for assignment
    to a Vectice Step.

    Parameters:
        library: The library used to generate the model.
        technique: The modeling technique used.
        metrics: A dict for example `{"MSE": 1}`.
        properties: A dict, for example `{"folds": 32}`.
        name: The model name. If None, will be auto-generated based on the library and technique.
        attachments: Path of a file that will be attached to the step along with the predictor.
        predictor: The predictor.
        derived_from: List of dataset version ids to link as lineage.
        inputs: Deprecated. Use `derived_from` instead.
    """
    if not derived_from and inputs:
        derived_from = inputs

    self._library = library
    self._technique = technique
    self._name = name if name else self._generate_name()
    self._metrics = self._format_metrics(metrics) if metrics else None
    self._properties = self._format_properties(properties) if properties else None
    self._attachments = self._format_attachments(attachments) if attachments else None
    self._predictor = pickle.dumps(predictor)  # nosec
    self._derived_from = derived_from

attachments writable property

attachments: list[str] | None

The attachments associated with the model.

Returns:

Type Description
list[str] | None

The attachments associated with the model.

derived_from property

derived_from: Any

The datasets from which this model is derived.

Returns:

Type Description
Any

The datasets from which this model is derived.

inputs property

inputs: Any

Deprecated. Use derived_from instead.

Returns:

Type Description
Any

The datasets from which this model is derived.

library writable property

library: str

The name of the library used to generate the model.

Returns:

Type Description
str

The name of the library used to generate the model.

metrics writable property

metrics: list[Metric] | None

The model's metrics.

Returns:

Type Description
list[Metric] | None

The model's metrics.

name writable property

name: str

The model's name.

Returns:

Type Description
str

The model's name.

predictor writable property

predictor: Any

The model's predictor.

Returns:

Type Description
Any

The model's predictor.

properties writable property

properties: list[Property] | None

The model's properties.

Returns:

Type Description
list[Property] | None

The model's properties.

technique writable property

technique: str

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

Returns:

Type Description
str

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