snowflake.ml.model.model_signature.FeatureSpec¶
- class snowflake.ml.model.model_signature.FeatureSpec(name: str, dtype: DataType, shape: Optional[tuple[int, ...]] = None, nullable: bool = True)¶
- Bases: - BaseFeatureSpec- Specification of a feature in Snowflake native model packaging. - Initialize a feature. - Parameters:
- name – Name of the feature. 
- dtype – Type of the elements in the feature. 
- nullable – Whether the feature is nullable. Defaults to True. 
- shape – - Used to represent scalar feature, 1-d feature list, or n-d tensor. Use -1 to represent variable length. Defaults to None. - Examples - None: scalar 
- (2,): 1d list with a fixed length of 2. 
- (-1,): 1d list with variable length, used for ragged tensor representation. 
- (d1, d2, d3): 3d tensor. 
 
- nullable – Whether the feature is nullable. Defaults to True. 
 
- Raises:
- SnowflakeMLException – TypeError: When the dtype input type is incorrect. 
- SnowflakeMLException – TypeError: When the shape input type is incorrect. 
 
 - Methods - as_dtype(force_numpy_dtype: bool = False) Union[dtype[Any], None, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, collections.abc.Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype, UInt8Dtype, UInt16Dtype, UInt32Dtype, UInt64Dtype, Float32Dtype, Float64Dtype, BooleanDtype, StringDtype]¶
- Convert to corresponding local Type. 
 - as_snowpark_type() DataType¶
- Convert to corresponding Snowpark Type. 
 - classmethod from_dict(input_dict: dict[str, Any]) FeatureSpec¶
- Deserialize the feature specification from a dict. - Parameters:
- input_dict – The dict containing information of the feature specification. 
- Returns:
- A feature specification instance deserialized and created from the dict. 
 
 - classmethod from_mlflow_spec(input_spec: Union[mlflow.types.ColSpec, mlflow.types.TensorSpec], feature_name: str) FeatureSpec¶
 - to_dict() dict[str, Any]¶
- Serialize the feature group into a dict. - Returns:
- A dict that serializes the feature group. 
 
 - Attributes - name¶
- Name of the feature.