liveBook · Manning

Input

As explained in Statistics Every Programmer Needs

A feature is an input attribute of an observation used by a predictive model to make decisions or generate predictions.

A feature is an input attribute used to predict an outcome. In regression, features are also called independent variables, explanatory variables, or predictors; the outcome is the dependent, response, or target variable. Labeled data pairs known feature values with known outcomes so a fitted model can predict outcomes for new observations. section 4.0

Choose features for the outcome being predicted. Linear regression uses one or more features to predict a numeric response and assumes a linear relationship. A simple regression has one predictor; a multiple regression has two or more. Logistic regression instead combines predictors to estimate the probability of a binary outcome. Its predictors may be numeric or categorical. section 4.1 section 5.1

Predicting race split times

To estimate a Stage 2 split time from a Stage 1 split time, set `y = mds['stage2']` and `x = mds['stage1']`. Add an intercept with `x = sm.add_constant(x)`, then fit `sm.OLS(y, x).fit()`. For two predictors, select both columns into `x` instead. Ordinary least squares estimates coefficients by minimizing squared differences between observed and predicted Stage 2 times; the fitted output still needs evaluation before use. section 4.2.2

>>> x = mds[['stage1', 'second_variable']]

The two-column `x` selection shows how a single-predictor input becomes a multiple-predictor input. section 4.2.2

A fitted coefficient does not, by itself, establish that a feature is useful. Inspect coefficient p-values and overall fit, and test regression assumptions before interpreting results. Adding predictors merely to raise R² can increase complexity and multicollinearity. In a raisin-classification example, an initial logistic model uses seven morphological features; insignificant predictors and multicollinearity motivate a reduced model using MinorAxisLength and Perimeter. Feature choice is therefore part of model evaluation, not just input preparation. section 4.3 section 5.2.2

How Statistics Every Programmer Needs covers it

How deep it goes
Defines predictors by their relationship to targets, demonstrates Python input selection, and evaluates significance and multicollinearity; does not develop general feature engineering.
Examples
Uses Stage 1 split times to predict Stage 2 times and raisin morphology to predict variety.
What it assumes
Introduces predictor and response roles through a linear-regression primer, then demonstrates their selection with readable Python assignments.
What you can do after
Apply it via statsmodels by selecting predictors, fitting regression models, and reviewing significance and multicollinearity before retaining features.
How it connects
Connects features to supervised learning, response variables, regression coefficients, statistical significance, and multicollinearity.

Also explained in

Compare how 14 books explain input →

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.