liveBook · Manning

Supervised learning

As explained in Investing for Programmers

A machine-learning approach that trains a model from examples paired with known target outcomes.

Supervised learning trains a model on labeled examples: features describe each case, while a known label or outcome supplies the prediction target. In financial research, the model can classify a stock as buy, sell, or hold, or estimate its future return. section 8.1

A practical supervised-learning workflow includes:

  • Build an analytical table with an identifier, selected features, and one label or target outcome. section 8.1.2
  • Choose quantifiable inputs such as prices, earnings, expenses, macroeconomic indicators, or other financial and nonfinancial data. section 8.1.2

Next-day price prediction

A compact experiment loads AAPL history with yfinance, keeps Open, High, Low, Close, and Volume, and shifts Close by one day to create Target. A RandomForestRegressor learns from the first 80% of observations, predicts the remaining observations, and evaluates them with root mean squared error. A chart compares the forecast with actual prices.

Supervised learning is useful but fragile in markets. Models can overfit or underfit, historical performance may not persist, and changing data sources, economic conditions, accounting practices, regulations, and industry patterns require caution and retraining. Trading applications must also account for slippage, transaction costs, and spreads. section 8.5 section 11.3.2

How Investing for Programmers covers it

How deep it goes
Descends from labels and features through dataset construction, model training, testing, error measurement, and forecasting limitations.
Examples
Uses clustered stock labels, macroeconomic features, and an AAPL random-forest next-day price experiment.
What it assumes
Assumes access to quantifiable historical data and requires competence in data collection, processing, and scalable algorithmic implementation.
What you can do after
Apply it via pandas, yfinance, and scikit-learn to train, test, evaluate, and visualize financial predictions.
How it connects
Connects classification, regression, feature selection, unsupervised learning, random forests, backtesting, and overfitting.

Also explained in

Compare how 19 books explain supervised learning →

Related concepts

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