---
title: "fitted(to:validateOn:eventHandler:)"
framework: createmlcomponents
role: symbol
role_heading: Instance Method
path: "createmlcomponents/lineartimeseriesforecaster/fitted(to:validateon:eventhandler:)"
---

# fitted(to:validateOn:eventHandler:)

Fits a model to a sequence of examples with validation.

## Declaration

```swift
func fitted(to input: some Sequence<AnnotatedFeature<MLShapedArray<Scalar>, MLShapedArray<Scalar>>>, validateOn validation: some Sequence<AnnotatedFeature<MLShapedArray<Scalar>, MLShapedArray<Scalar>>>, eventHandler: EventHandler? = nil) async throws -> LinearTimeSeriesForecaster<Scalar>.Model
```

## Parameters

- `input`: A sequence of annotated features. Each feature’s shape should be [featureSize] and each annotation’s shape should be [annotationSize].
- `validation`: A sequence of annotated validation features. The feature and annotation shapes should be the same as the input parameter.
- `eventHandler`: An event handler.

## Return Value

Return Value The fitted model.

## Discussion

Discussion This method uses a sliding window to chunk the input features and validation features into features of inputWindowSize elements and annotations of forecastWindowSize elements. If you want to use a different windowing strategy, use fitted(toWindows:validateOn:eventHandler:).

## See Also

### Updating and fitting

- [update(_:with:)](createmlcomponents/lineartimeseriesforecaster/update(_:with:).md)
- [update(_:withWindows:eventHandler:)](createmlcomponents/lineartimeseriesforecaster/update(_:withwindows:eventhandler:).md)
- [fitted(to:eventHandler:)](createmlcomponents/lineartimeseriesforecaster/fitted(to:eventhandler:).md)
- [fitted(toWindows:eventHandler:)](createmlcomponents/lineartimeseriesforecaster/fitted(towindows:eventhandler:).md)
- [fitted(toWindows:validateOn:eventHandler:)](createmlcomponents/lineartimeseriesforecaster/fitted(towindows:validateon:eventhandler:).md)
