snowflake.ml.model.model_signature.infer_signature

snowflake.ml.model.model_signature.infer_signature(input_data: Union[ForwardRef('_SupportedBuiltins'), ForwardRef('_SupportedBuiltinsList')]], _SupportedBuiltinsList]]], output_data: Union[ForwardRef('_SupportedBuiltins'), ForwardRef('_SupportedBuiltinsList')]], _SupportedBuiltinsList]]], input_feature_names: Optional[list[str]] = None, output_feature_names: Optional[list[str]] = None, input_data_limit: Optional[int] = 100, output_data_limit: Optional[int] = 100, params: Optional[Union[Sequence[BaseParamSpec], dict[str, Any]]] = None) ModelSignature

Infer model signature from given input and output sample data.

Currently supports inferring model signatures from the following data types:

  • Pandas DataFrame with columns of supported data types, lists (including nested lists) of supported data types,

    and NumPy arrays of supported data types. - Does not support DataFrame with CategoricalIndex column index.

  • NumPy arrays of supported data types.

  • Lists of NumPy arrays of supported data types.

  • Lists of supported data types or nested lists of supported data types.

When inferring the signature, a ValueError indicates that the data is insufficient or invalid.

When it might be possible to create a signature reflecting the provided data, but it could not be inferred, a NotImplementedError is raised

Parameters:
  • input_data – Sample input data for the model.

  • output_data – Sample output data for the model.

  • input_feature_names – Names for input features. Defaults to None.

  • output_feature_names – Names for output features. Defaults to None.

  • input_data_limit – Limit the number of rows to be used in signature inference in the input data. Defaults to 100. If None, all rows are used. If the number of rows in the input data is less than the limit, all rows are used.

  • output_data_limit – Limit the number of rows to be used in signature inference in the output data. Defaults to 100. If None, all rows are used. If the number of rows in the output data is less than the limit, all rows are used.

  • params

    Optional parameter specifications to include in the signature. Can be provided as: - A dict mapping parameter names to default values, e.g.

    {"temperature": 0.7, "max_tokens": 100}. The dtype and shape of each ParamSpec will be inferred from the Python value type. Supported types are determined by

    DataType.from_python_type().

    • A sequence of BaseParamSpec (ParamSpec or ParamGroupSpec) objects for explicit control over dtype, shape, and grouping.

    • None (default) for no parameters.

Raises:

SnowflakeMLException – ValueError: Raised when input data contains columns matching parameter names.

Returns:

A model signature inferred from the given input and output sample data.