model¶
- class virtualitics_sdk.assets.model.Model(model, label, metadata=None, name=None, description=None, version=None, **kwargs)¶
Bases:
Asset
The model asset is a wrapper for machine learning models. Accessing attributes and member functions of the model asset also passes through access to the underlying machine learning model.
- Parameters:
model (
Any
) – The machine learning model that this asset keeps track of.label (
str
) – Label ofAsset
, see its documentation for more details.metadata (
Optional
[dict
]) – Metadata ofAsset
, see its documentation for more details. Defaults to None.name (
Optional
[str
]) – Name ofAsset
, see its documentation for more details. Defaults to None.description (
Optional
[str
]) – Description ofAsset
, see its documentation for more details. Defaults to None.version (
Optional
[int
]) – Version ofAsset
, see its documentation for more details. Defaults to 0.
EXAMPLE:
# Imports from virtualitics_sdk.assets.model import Model from sklearn.linear_model import LogisticRegression . . . # Example usage X = np.random.rand(10).reshape(-1, 1) Y = np.random.randint(0, 2, size=(10, 1)) model = Model(LogisticRegression(), label="test", name="model") model.fit(X, Y)
Additionally, for specific packages the model asset stores hyperparameter information and the time it took to run certain model functions. Currently supported packages are xgboost and sklearn.
- get_all_metainfo()¶
Returns the dictionary containing the model metadata.
- Return type:
Dict
- Returns:
Model metadata, including hyperparameters and times taken for last function calls.
- get_recent_time()¶
Returns the time taken for the most recent function which had its time recorded.
- Returns:
The time taken in seconds as a float. If no time is found, returns None instead.
- get_time(attr)¶
Returns the last time taken to run the function named attr. The function needs to have been called on the model asset rather than the underlying ML model in order for the time to be recorded. Returns None if no time was found.
- Parameters:
attr (
str
) – The name of the function to find the time taken.- Return type:
Optional
[str
]- Returns:
The time taken in seconds as a float. If no time is found, returns None instead.
- update_model_notes()¶
This function updates the asset’s stored metadata about the model.
- Return type:
None