<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/LinearTimeSeriesForecaster/fitted(to:validateOn:eventHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents26LinearTimeSeriesForecasterV6fitted2to10validateOn12eventHandlerAC5ModelVyx_Gqd___qd_0_yAA5EventVYbcSgtYaKSTRd__STRd_0_AA16AnnotatedFeatureVy6CoreML13MLShapedArrayVyxGASG7ElementRtd__AtURtd_0_r0_lF"
  },
  "title" : "fitted(to:validateOn:eventHandler:)"
}
-->

# fitted(to:validateOn:eventHandler:)

Fits a model to a sequence of examples with validation.

```
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

The fitted model.

## Discussion

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)