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

# fitted(to:eventHandler:)

Fits a linear regressor model to a sequence of examples.

## Declaration

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

## Parameters

- `input`: A sequence of examples used for fitting the 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:validateOn:eventHandler:)](createmlcomponents/linearregressor/fitted(to:validateon:eventhandler:).md)
- [LinearRegressor.Annotation](createmlcomponents/linearregressor/annotation.md)
- [LinearRegressor.Transformer](createmlcomponents/linearregressor/transformer.md)
