# fit()

*noun*

say it: **“FIT”** **/ˈfɪt/**

In scikit-learn, the method that trains a model: it learns from examples and their right answers.

## What does **fit()** do in scikit-learn?

**fit()** is the scikit-learn method that trains a model: `model.fit(X, y)` learns from the features `X` (one row per
example) and the labels `y` (the right answers). It returns the model, so `.predict()` can follow on the same line.

```python
from sklearn.linear_model import LinearRegression
temps = [[60], [70], [80]]   # features: one row per day
cups = [20, 40, 60]          # labels: cups of lemonade sold
model = LinearRegression().fit(temps, cups)
print(model.coef_)   # [2.]: 2 more cups per degree
```

## In a sentence

- “A model can't predict until you've called **fit()**.”
- “Calling **fit()** on last summer's sales trained the lemonade model.”

Level: Apprentice · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=2)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/fit
