The scikit-learn API is a consistent convention for learning from data, transforming it, making predictions, and configuring models. Its familiar methods—fit, partial_fit, predict, predict_proba, and transform—let practitioners reuse patterns across classification, regression, preprocessing, clustering, dimensionality reduction, and model selection. section 4.1.1
The API separates common responsibilities among reusable objects:
- Estimators learn from data with fit(data, targets) for supervised learning or fit(data) for unsupervised learning. section 4.1.2
- Transformers learn or apply mappings through transform and fit_transform, such as scaling input features. section 4.1.2
- Predictors produce outcomes with predict and probabilities with predict_proba, while score provides a model score. section 4.1.2
- Parameters use ordinary Python values, and public attributes expose learned parameters and configuration for inspection. section 4.1.1 section 4.1.2
A compact classification workflow
Create a LogisticRegression estimator, fit it on feature rows and targets, then predict outcomes or probabilities for new rows. Replace the estimator or add a transformer without changing the overall fit-and-use pattern. section 4.1.2
X = [[-1, -1], [-2, -1], [1, 1], [2, 1]] y = [1, 1, 0, 0] model.fit(X, y)
Use the listing to see the estimator interface with a small feature matrix and target vector. section 4.1.2
