liveBook · Manning

Training

As explained in Statistics Every Programmer Needs

fit is an estimator method that learns model parameters or structure from supplied training data.

Training fits a model to supplied data: depending on the estimator, this can build model structure or estimate parameters. Keep training distinct from testing on data the model has not seen. section 6.3.2 section 7.3.9

What fitting does depends on the model:

  • A decision tree classifier uses fit(X_train, y_train) to build a tree from the training split; predictions are then made on the held-out test split. section 6.3.2
  • An ARIMA model estimates parameters from training data, using maximum likelihood estimation to optimize coefficients under its assumptions. Its fitted results can support prediction and diagnostics. section 7.3.9
  • A logistic regression fit estimates regression parameters; its summary reports coefficients, p-values, and goodness-of-fit statistics that can inform model evaluation. section 5.2.2
>>> clf = clf.fit(X_train, y_train)

Example of fitting a decision tree classifier to training features and labels. section 6.3.2

>>> model_fit = model.fit()

Example of fitting a configured ARIMA model. section 7.3.9

How Statistics Every Programmer Needs covers it

How deep it goes
Explains tree construction and ARIMA parameter estimation, but does not detail the fitting algorithms’ internals.
Examples
Demonstrates fitting a decision tree, an ARIMA model, and a logistic regression to training data.
What it assumes
Assumes prepared training data and a configured model; distinguishes fitting data from held-out test data.
What you can do after
Apply via scikit-learn or statsmodels to fit configured models to training data.
How it connects
Connects training with decision trees, ARIMA, logistic regression, and maximum likelihood estimation.

Also explained in

Compare how 24 books explain training →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.