liveBook · Manning

Scikit-learn API

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

The scikit-learn API is the library-wide interface convention for fitting, predicting with, transforming data using, and configuring estimators.

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

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Defines estimator roles and core methods with small listings, while deferring detailed model algorithms and internals.
Examples
Demonstrates LogisticRegression, StandardScaler, small arrays, feature targets, transformed data, predictions, probabilities, and scores.
What it assumes
Teaches estimator categories and fitting from basics, while assuming familiarity with data, targets, and standard Python values.
What you can do after
Apply it via fit, transform, predict, predict_proba, and score across compatible scikit-learn objects.
How it connects
Connects estimators with transformers, predictors, pipelines, supervised learning, unsupervised learning, and train-test separation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.