liveBook · Manning

Label

As explained in Financial AI in Practice

The outcome value associated with an example that a predictive model is trained to estimate.

A label is the outcome value assigned to an example that a predictive model is trained to estimate. In market-direction prediction, labels encode whether the next-day move is bullish, bearish, or neutral; in fraud detection, they distinguish fraudulent from legitimate transactions. section 10.4.1 section 8.2.1

Label design determines which outcomes the model learns to distinguish:

  • For SPY, next-day returns above +1% are bullish, below −1% are bearish, and returns between those thresholds are neutral. The threshold can be tuned to a trading strategy’s goals and tolerance for noise. section 10.4.1
  • For credit-card transactions, Class 1 means fraud and Class 0 means legitimate. Fraud accounts for only about 0.17% of the dataset, creating severe class imbalance that affects modeling and metric choices. section 8.2.1
Listing 10.3 Creating realistic target labels
import numpy as np

def create_target_labels(data, threshold=0.01):
    """Create next-day directional labels with realistic thresholds"""
    returns = data['SPY_close'].pct_change().shift(-1)     #1

    conditions = [
        (returns > threshold),   # Bullish moves
        (returns < -threshold)   # Bearish moves
    ]
    choices = [1, -1]  # 1: Up, -1: Down
    data['target'] = np.select(conditions, choices, default=0)    #2

    return data.dropna()

etf_data_labeled = create_target_labels(etf_data)
print(f"Target distribution:\n{etf_data_labeled['target'].value_counts()}")

See Python code that derives next-day returns, assigns labels using a configurable threshold, and checks their distribution. section 10.4.1

How Financial AI in Practice covers it

How deep it goes
Works through threshold-based label construction and distribution checks, without detailing model training.
Examples
Uses SPY directional classes and credit-card fraud-versus-legitimate labels.
What you can do after
Builds target labels from next-day returns using a configurable threshold in Python.
How it connects
Connects target variables with returns, look-ahead bias, and class imbalance.

Also explained in

Compare how 20 books explain label →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Financial AI in Practice. The section links point to the parts of the book it draws on.