> 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.natml.ai/unity/api/mlfeature.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
