Machine Learning · Chapter 7 of 40
scikit-learn Introduction
scikit-learn is the standard Python ML library. It provides a consistent API: `fit`, `predict`, `score` — the same three methods for every model.
Install: `pip install scikit-learn`.
Example 1 (python)
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(X_train, y_train)
print(model.score(X_test, y_test))Output
0.85Same API across all models.
Example 2 (python)
from sklearn.tree import DecisionTreeClassifier
model = DecisionTreeClassifier(max_depth=3)
model.fit(X, y)Different algorithm, same interface.
Key points
- Consistent fit/predict/score API.
- Ships many algorithms + utilities.
- Great docs and examples.
- The industry standard for classical ML.
💡 Note: scikit-learn works best on structured/tabular data. For deep learning use PyTorch or TensorFlow.
