Let's think about it this way for a second
Linear Regression is one of the simplest, easiest-to-understand ML algorithms — it finds the linear relationship (a straight line) between a feature (x) and a target (y). scikit-learn's API pattern is consistent across every algorithm — `.fit(X_train, y_train)` (train the model) and `.predict(X_test)` (make predictions) — you'll see this same pattern come up again and again throughout the tutorial, no matter which algorithm you're using.
Let's connect it to a real scenario
To predict house price (y) from house size (X) — writing `from sklearn.linear_model import LinearRegression; model = LinearRegression(); model.fit(X_train, y_train)` trains the model, and `predictions = model.predict(X_test)` predicts the price for the test data — running `model.score(X_test, y_test)` immediately shows you the model's accuracy (R² score).
Let's look at it together
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(X_train, y_train)
predictions = model.predict(X_test)
print(predictions[:5])
accuracy = model.score(X_test, y_test)
print(f"R^2 score: {accuracy:.2f}")[245000. 312000. 198000. 410000. 275000.]
R^2 score: 0.875-minute try-it
Create your own sample dataset (house size vs. price), then train/predict/score a Linear Regression model — confirm you get an R² score back.
A quick word of caution
Don't treat a single R² score as the final word on whether a Linear Regression model is 'good' or 'bad' — you should look at multiple evaluation metrics together (covered in the Intermediate chapter).