> 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/mlmodel.md).

# MLModel

The `MLModel` class abstracts a machine learning model, containing a computation graph for making predictions along with feature type information and metadata.

## Inspecting Feature Types

Models provide information about their expected input and output feature types. This type information is crucial for writing model predictors.

### Input Features

```csharp
/// <summary>
/// Model input feature types.
/// </summary>
MLFeatureType[] inputs { get; }
```

The model provides its expected input feature types. This information is crucial in order to create input features for predictions. Typically, a predictor will handle any necessary conversions of your input feature so that it matches the type that the model expects.

{% hint style="info" %}
The `inputs` are reported in the same order that they are expected by the model when making predictions.
{% endhint %}

### Output Features

```csharp
/// <summary>
/// Model output feature types.
/// </summary>
MLFeatureType[] outputs { get; }
```

The model provides its output feature types. This information is crucial in order to convert the model's raw outputs into more usable forms by predictors.

{% hint style="info" %}
The `outputs` are reported in the same order that they are produced by the model when making predictions.
{% endhint %}

## Inspecting Metadata

```csharp
/// <summary>
/// Get the model metadata dictionary.
/// </summary>
IReadOnlyDictionary<string, string> metadata { get; }
```

Models expose metadata that was defined when they were created.

## Disposing the Model

```csharp
/// <summary>
/// Dispose the model and release resources.
/// </summary>
void Dispose ();
```

Models can consume native and cloud resources, including threads, memory allocators, and so on. As a result, you must dispose of the model once you are done using it.

{% hint style="info" %}
The `MLModel` class implements the [`IDisposable`](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable?view=net-5.0) interface, and as such can be used with `using` blocks.
{% endhint %}

{% hint style="danger" %}
Do not use a model once it has been disposed. Doing so will lead to a hard crash.
{% 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/mlmodel.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.
