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

# fitted(to:validateOn:eventHandler:)

Fits a linear regressor model to a sequence of examples.

## Declaration

```swift
func fitted<Input, Validation>(to input: Input, validateOn validation: Validation, eventHandler: EventHandler? = nil) async throws -> LinearRegressorModel<Scalar> where Input : Sequence, Validation : Sequence, Input.Element == AnnotatedFeature<MLShapedArray<Scalar>, Scalar>, Validation.Element == AnnotatedFeature<MLShapedArray<Scalar>, Scalar>
```

## Parameters

- `input`: A sequence of examples used for fitting the regressor.
- `validation`: A sequence of examples used for validating the fitted regressor.
- `eventHandler`: An event handler. This method reports maximum error and root-mean-square error metrics.

## Return Value

Return Value The fitted linear regressor model.

## See Also

### Fitting

- [fitted(to:eventHandler:)](createmlcomponents/linearregressor/fitted(to:eventhandler:).md)
- [LinearRegressor.Annotation](createmlcomponents/linearregressor/annotation.md)
- [LinearRegressor.Transformer](createmlcomponents/linearregressor/transformer.md)
