liveBook · Manning

Predictive analytics

As explained in Effective Data Analysis

Predictive modeling is the construction and use of models to generate predictions for new or unknown observations.

Predictive analytics uses historical data to fit a statistical or machine-learning model, then uses that model to estimate outcomes for new observations. A fitted regression equation, for example, can estimate a house price from its square footage and number of bedrooms. section 9.1.2

A practical modeling workflow begins with the decision the prediction will support:

  • Ask what needs predicting, such as whether users will complete a paid sign-up or how many daily rat sightings might be reported. section 9.2
  • Explore possible predictors. Weather variables correlated with rat sightings offer candidates; business hypotheses can also identify inputs worth examining. section 9.2 section 9.3.3
  • Fit and test a model, then choose a useful deliverable. A product operations team might need adjustable inputs for estimating a new product’s profit margin, even in a spreadsheet. section 9.1.2 section 9.3.3
import statsmodels.api as sm

import pandas as pd
housing_prices = pd.read_csv("housing_prices.csv")     #1

X = housing_prices[["sq_footage", "n_bedrooms"]]
y = housing_prices["price"]     #2
X = sm.add_constant(X)     #3

model = sm.OLS(y, X).fit()     #4
print(model.summary())

The Python listing selects house features and prices, fits an ordinary least squares regression with statsmodels, and prints its summary. The fitted coefficients provide an equation for making estimates. section 9.1.2

Prediction requires more than readable coefficients: coefficients alone do not establish predictive ability. Assess diagnostics together; for a profit-margin model, suggested metrics include R², AIC, BIC, and RMSE. Check whether the training data represents where the model will be used. A house-price equation fitted in one geographic region may not transfer elsewhere, and omitted inputs such as renovations or commuting distance may matter. section 9.1.2 section 9.3.3

Explanation versus prediction

A finance team might use regression to report the direction and strength of relationships with product profit margins. A product operations team instead needs accurate estimates for new products and may try derived features or, optionally, a random forest to improve predictive power. section 9.3.3

How Effective Data Analysis covers it

How deep it goes
Explains fitting and applying a regression equation, outlines question-led modeling, and calls for diagnostics without detailing every testing procedure.
Examples
Uses house-price estimation and weather-linked rat sightings, then poses a product-profit-margin modeling exercise.
What it assumes
Assumes historical observations and candidate inputs; introduces prediction through new values entered into a fitted regression equation.
What you can do after
Build it from scratch by fitting a predictive model, assessing its metrics, and planning an adjustable profit-margin tool for stakeholders.
How it connects
Links regression, correlation, feature selection, model diagnostics, and machine-learning algorithms to prediction.

Also explained in

Compare how 3 books explain predictive analytics →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Data Analysis. The section links point to the parts of the book it draws on.