MLFeature

abstract class NatML.MLFeature

The MLFeature class is an abstract base class representing input and output features used in making predictions. All predictors accept one or more features, which are then provided to the model to make predictions.

Creating a Feature

NatML provides implicit conversions from common data types into MLFeature instances:

From an Array

// With a `float` array
float[] array = ...;
// Create a feature
MLFeature feature = array;
// Then make a prediction
predictor.Predict(feature);
// This works too
predictor.Predict(array);

NatML provides an implicit conversion from a float[] to an MLArrayFeature.

From a Texture2D

// With a `Texture2D`
Texture2D texture = ...;
// Create a feature
MLFeature feature = texture;
// Then make a prediction
predictor.Predict(feature);
// This works too
predictor.Predict(texture);

NatML provides an implicit conversion from a Texture2D to an MLImageFeature.

The MLImageFeature class will handle any conversions of pixel data to match a model's required input type.

From a WebCamTexture

NatML provides an implicit conversion from a WebCamTexture to an MLImageFeature.

From an AudioClip

NatML provides an implicit conversion from an AudioClip to an MLAudioFeature.

From a String

NatML provides an implicit conversion from a string to an MLTextFeature.

Inspecting the Feature

Every feature has a corresponding MLFeatureType that provides information about the feature's shape, data type, and so on.

The feature type is immutable and can never be null.

Last updated

Was this helpful?