Skip to main content
Albero Academy

The Estimator API

One consistent interface — fit, predict, transform, score.

Foundations9 min

Scikit-learn's genius is consistency: every model, transformer and pipeline shares the same handful of methods. Learn the interface once and every one of the hundreds of algorithms works the same way.

The core methods

MethodDoes
fit(X, y)Learn from data (train)
predict(X)Predict targets for new data
transform(X)Transform data (scalers, encoders)
fit_transform(X)Fit then transform in one step
score(X, y)Default performance metric
predict_proba(X)Class probabilities (classifiers)
X and y conventions
# X = features: a 2-D array/DataFrame, shape (n_samples, n_features)
# y = target: a 1-D array/Series, shape (n_samples,)
model.fit(X_train, y_train)
model.score(X_test, y_test) # R² for regressors, accuracy for classifiers

Key takeaways

  1. 01Every scikit-learn object shares one interface: fit, predict/transform, score.
  2. 02X is 2-D features (n_samples × n_features); y is the 1-D target.
  3. 03fit_transform combines fitting and transforming; predict_proba gives class probabilities.
  4. 04Learn the API once and every algorithm works the same way.

Finished this chapter?

Mark it complete to track your progress through Scikit-learn.