Skip to content
dreamcode
dreamcode
Back to map
ML with sklearn · Lesson 44 of 44
+15 XP on finish
PYTHON APPLIED

Intro to machine learning with scikit-learn

scikit-learn provides a consistent API for machine learning in Python. The core workflow is: prepare data, split into training and test sets, choose a model, call .fit() to train, and .predict() to classify or regress on new data.

How it reads
train_test_split divides data into training and evaluation portions
model.fit(X_train, y_train) trains the model on labeled examples
model.predict(X_test) generates predictions on unseen data
Cloud tip: Always evaluate on a held-out test set, never on training data. Training accuracy can be misleadingly high if the model memorizes rather than generalizes.
Check your understanding
Answer all 3 to complete this lesson · +15 XP
1. What does model.fit(X, y) do in scikit-learn?
2. Why should you split data into training and test sets?
3. What does accuracy_score measure?