You are viewing documentation about an older version (1.2.0). View latest version

snowflake.ml.model.ModelVersion

class snowflake.ml.model.ModelVersion

Bases: object

Model Version Object representing a specific version of the model that could be run.

Methods

delete_metric(metric_name: str) None

Delete a metric from metric storage.

Args:

metric_name: The name of the metric to be deleted.

Raises:

KeyError: When the requested metric name does not exist.

get_metric(metric_name: str) Any

Get the value of a specific metric.

Args:

metric_name: The name of the metric.

Raises:

KeyError: When the requested metric name does not exist.

Returns:

The value of the metric.

run(X: Union[DataFrame, DataFrame], *, function_name: Optional[str] = None) Union[DataFrame, DataFrame]

Invoke a method in a model version object.

Args:

X: The input data, which could be a pandas DataFrame or Snowpark DataFrame. function_name: The function name to run. It is the name used to call a function in SQL.

Defaults to None. It can only be None if there is only 1 method.

Raises:

ValueError: When no method with the corresponding name is available. ValueError: When there are more than 1 target methods available in the model but no function name specified.

Returns:

The prediction data. It would be the same type dataframe as your input.

set_metric(metric_name: str, value: Any) None

Set the value of a specific metric.

Args:

metric_name: The name of the metric. value: The value of the metric.

show_functions() List[ModelFunctionInfo]

Show all functions information in a model version that is callable.

Returns:

A list of ModelFunctionInfo objects containing the following information:

  • name: The name of the function to be called (both in SQL and in Python SDK).

  • target_method: The original method name in the logged Python object.

  • signature: Python signature of the original method.

show_metrics() Dict[str, Any]

Show all metrics logged with the model version.

Returns:

A dictionary showing the metrics.

Attributes

comment

The comment to the model version.

description

The description for the model version. This is an alias of comment.

fully_qualified_model_name

Return the fully qualified name of the model to which the model version belongs.

model_name

Return the name of the model to which the model version belongs, usable as a reference in SQL.

version_name

Return the name of the version to which the model version belongs, usable as a reference in SQL.