> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ModelSpec

> Defines how model columns are categorized and used along with model task configuration.

Defines how model columns are categorized and used along with model task configuration.

ModelSpec provides a comprehensive specification of how different columns in your
model's data should be interpreted and used. It categorizes columns into inputs,
outputs, targets, decisions, and metadata, and allows for custom feature definitions
that enhance model monitoring and analysis capabilities.

This specification is crucial for Fiddler to understand your model's structure,
enabling proper monitoring, drift detection, bias analysis, and explainability
features. It acts as the contract between your model and Fiddler's monitoring
infrastructure.

* **custom\_features** (*List* *\[Multivariate* *|* *VectorFeature* *|* *TextEmbedding* *|* *ImageEmbedding* *|* *Enrichment* *]*)

## Examples

Creating a basic model spec for classification:

```python theme={null}
spec = ModelSpec(
    inputs=["age", "income", "credit_score"],
    outputs=["prediction", "probability"],
    targets=["approved"],
    metadata=["customer_id", "timestamp"]
)
```

Creating a spec with custom features:

```python theme={null}
from fiddler.schemas.custom_features import Multivariate, TextEmbedding

spec = ModelSpec(
    inputs=["user_clicks", "session_time", "review_text_embedding"],
    outputs=["recommendation_score"],
    targets=["user_rating"],
    metadata=["user_id", "session_id"],
    custom_features=[
        Multivariate(
            name="user_behavior",
            columns=["user_clicks", "session_time"],
            n_clusters=5
        ),
        TextEmbedding(
            name="review_clusters",
            column="review_text_embedding",
            source_column="review_text",
            n_clusters=8
        )
    ]
)
```

Creating a spec for ranking models:

```python theme={null}
ranking_spec = ModelSpec(
    inputs=["query_features", "doc_features", "relevance_score"],
    outputs=["ranking_score"],
    targets=["click_through"],
    decisions=["final_ranking"],
    metadata=["query_id", "doc_id"]
)
```

## schema\_version

Schema version

## inputs

Feature columns

## outputs

Prediction columns

## targets

Label columns

## model\_config

Configuration for the model, should be a dictionary conforming to \[ConfigDict]\[pydantic.config.ConfigDict].

## decisions

Decisions columns

## metadata

Metadata columns

## custom\_features

Custom feature definitions

## remove\_column()

Remove a column name from spec if it exists.
