<!--
{
  "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/MultivariateLinearRegressor/fitted(to:validateOn:eventHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents27MultivariateLinearRegressorV6fitted2to10validateOn12eventHandlerAC5ModelVyx_GAA14AnnotatedBatchVyxG_AMSgyAA5EventVYbcSgtYaKF::OverloadGroup"
  },
  "title" : "fitted(to:validateOn:eventHandler:)"
}
-->

# fitted(to:validateOn:eventHandler:)

Fits a linear regressor model to shaped arrays of features and annotations.

```
func fitted(to input: AnnotatedBatch<Scalar>, validateOn validation: AnnotatedBatch<Scalar>?, eventHandler: EventHandler? = nil) async throws -> MultivariateLinearRegressor<Scalar>.Model
```

## Parameters

`input`

An annotated batch containing the features and annotations. The last dimension of the features is
the model’s input size and the last dimension of the annotations is the model’s output size. All the
leading dimensions of the features must match all leading dimensions of the annotations. For example, the
feature shape can be `[N, X]` and the annotation shape can be `[N, Y]` for `N` examples where `X` is the
input size and `Y` is the output size.

`validation`

An annotated batch containing the validation features and annotations. The last dimension of
the features must be `inputSize` and the last dimension of the annotations must be `outputSize`. All the
leading dimensions of the features must match all leading dimensions of the annotations.

`eventHandler`

An event handler. This method reports the mean squared errors.

## Return Value

The fitted model.

---

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)