Scalable Analytics: Chapter 7
Principles of Supervised Learning
Definition and Goals: Supervised learning aims to learn a function such that . It is used for prediction based on a labeled dataset consisting of pairs .
Types of Output ():
Regression: When the target variable is a real number.
Classification: When the target variable is categorical.
Complex Object: Predictions involving structured or multi-faceted outputs.
Data Organization: The data is typically divided into a training set and a test set to evaluate model performance.
Large-Scale Machine Learning and the Effectiveness of Data
The Unreasonable Effectiveness of Data: Research findings indicate that model performance increases logarithmically based on the volume of training data ().
Scalability Drivers: The complexity of modern machine learning models, such as deep neural networks, allows for significant performance gains when combined with large datasets.
Core Question: The primary focus of large-scale analytics is determining how to efficiently train models on massive amounts of data.
Methods Considered:
-Nearest Neighbor (-NN)
Decision Trees (DT)
Perceptron algorithms
Support Vector Machines (SVM)
Deep Learning
Fundamentals of Decision Trees
Historical Context: Decision trees have been part of machine learning since the 1980s, introduced by Leo Breiman in 1984. Notable early algorithms include ID3 and C4.5.
Modern Relevance: Even though they are older, hand-engineered, and based on heuristics, they remain the preferred method for tabular data and Kaggle competitions. Recent innovations include Boosted Decision Trees (Gradient Boosted DT) and Random Forests.
Structural Components:
Internal Nodes: Data is split based on specific attributes.
Leaf Nodes: These nodes provide the final prediction.
Splits: Binary splits are common, where a numerical attribute is tested against a value (e.g., X^{(j)} < v).
Mathematical Representation:
features/attributes represented as .
Each attribute has a domain .
is the output variable with domain .
Data consists of examples where is a -dimensional feature vector.
Constructing the Decision Tree: The Splitting Process
Splitting Logic: The goal is to pick an attribute and value that optimizes a specific criterion to create child nodes ( and ) from a parent node ().
Regression - Purity Criterion: Splitting aims to maximize the reduction in variance:
Classification - Information Gain: This measures how much an attribute informs us about the class . It represents the average number of bits saved when transmitting if is known.
Entropy (): The smallest possible average number of bits per symbol needed to transmit a stream drawn from the distribution of .
High Entropy: Characterized by a uniform distribution.
Low Entropy: Characterized by a varied distribution with peaks and valleys.
Entropy Formula: .
Specific Conditional Entropy (): The entropy of considering only records where .
Conditional Entropy (): The average of all specific conditional entropies.
Information Gain Formula: .
Specific Example of Information Entropy
Scenario: Predicting if someone likes the movie "Casablanca" () based on their College Major ().
Data Estimates:
Calculations:
Decision Tree Construction Algorithm and Stopping Criteria
General Algorithm (InMemoryBuildNode):
Find the best split for the node results in .
If stopping criteria for are met, find and store the left prediction.
Otherwise, recursively call the build function for the left child.
Repeat the process for the right child .
Stopping Criteria Heuristics:
Leaf is "pure": The target variable variance is below a threshold (Var(y) < \epsilon).
Sample size: The number of examples in the leaf is too small.
Prediction Methods:
Regression: Predict the average of leaf examples or build a linear regression model within the leaf.
Classification: Predict the most common in the leaf.
Scalable Decision Trees using MapReduce (PLANET)
PLANET (Parallel Learner for Assembling Numerous Ensemble Trees): Designed for scenarios where the tree is small enough for memory, but the dataset is too large to scan on a single machine or fit in memory.
Setting:
Hundreds of numerical attributes (discrete or continuous, but not categorical).
Numerical target variable (Regression).
Binary splits (X(j) < v).
Workflow:
Master Node: Decides candidate splits and grows the tree level by level. It monitors the entire process.
MapReduce Jobs:
Initialization: Identifies all attribute values to consider for splits. It generates "attribute metadata."
FindBestSplit: Mappers calculate sufficient statistics (, , ) for their data subsets. Reducers aggregate these to compute global variance and purity.
InMemoryBuild: If the data at a node is small enough, it is processed locally in memory rather than via MapReduce.
Split Selection: For large data, sorting all values is inefficient. Instead, an equi-depth histogram is computed for attribute on the complete dataset , and boundary points are used as splits.
Learning Ensembles and Random Forests
Bagging (Bootstrap Aggregating): Learns multiple trees over independent samples of the training data. For a dataset with points, a new dataset is created by sampling points from with replacement. Final predictions are averaged across all trees.
Random Forests: An enhancement of bagging where the learning algorithm only selects from a random subset of features at each candidate split (Feature Bagging). This breaks the correlation between individual trees and often provides state-of-the-art results for many classification problems.
Instance-Based Learning: k-Nearest Neighbor (k-NN)
Mechanism: Unlike trees, this approach keeps the entire training dataset. For a query vector , the model identifies the most similar examples.
Requirements:
Distance Metric: Typically Euclidean distance.
Neighbor Count (): The number of points to consider.
Weighting Function: Optional (often unused in basic models).
Fitting Strategy: Predict the average output among neighbors for regression, or the majority class for classification.
Search Algorithms:
Main Memory: Linear scan, Tree-based (kd-tree), or Hashing.
Secondary Storage: R-trees.
Applications: Range searches, collaborative filtering, and finding the nearest neighbor for a query in a set .