> For the complete documentation index, see [llms.txt](https://docs.natml.ai/unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.natml.ai/unity/api/mlfeature.md).

# 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

```csharp
// 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`](/unity/api/mlfeature/mlarrayfeature.md).

{% hint style="warning" %}
When this conversion is used, the created feature will have no `shape` information.
{% endhint %}

### From a Texture2D

```csharp
// 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`](https://docs.unity3d.com/ScriptReference/Texture2D.html) to an [`MLImageFeature`](/unity/api/mlfeature/mlimagefeature.md).

{% hint style="info" %}
The [`MLImageFeature`](/unity/api/mlfeature/mlimagefeature.md) class will handle any conversions of pixel data to match a model's required [input type](/unity/api/mlmodel.md#input-features).
{% endhint %}

### From a WebCamTexture

```csharp
// With a `WebCamTexture`
WebCamTexture webCamTexture = ...;
// Create a feature
MLFeature feature = webCamTexture;
```

NatML provides an implicit conversion from a [`WebCamTexture`](https://docs.unity3d.com/ScriptReference/WebCamTexture.html) to an [`MLImageFeature`](/unity/api/mlfeature/mlimagefeature.md).

### From an AudioClip

```csharp
// With an `AudioClip`
AudioClip audioClip = ...;
// Create a feature
MLFeature feature = audioClip;
```

NatML provides an implicit conversion from an [`AudioClip`](https://docs.unity3d.com/ScriptReference/AudioClip.html) to an [`MLAudioFeature`](/unity/api/mlfeature/mlaudiofeature.md).

### From a String

```csharp
// With a `string`
var text = "hello, world";
// Create a feature
MLFeature feature = text;
```

NatML provides an implicit conversion from a `string` to an [`MLTextFeature`](/unity/api/mlfeature/mltextfeature.md).

## Inspecting the Feature

```csharp
/// <summary>
/// Feature type.
/// </summary>
MLFeatureType type { get; }
```

Every feature has a corresponding [`MLFeatureType`](/unity/api/mlfeaturetype.md) that provides information about the feature's shape, data type, and so on.

{% hint style="info" %}
The feature `type` is immutable and can never be `null`.
{% endhint %}
