Scalable Analytics: Chapter 8
Large-Scale Machine Learning and Analytics
Machine learning at scale involves managing high-dimensional data, graph-based data, and infinite streams of data.
Key focus areas include:
High Dimensional Data: Utilizing locality-sensitive hashing (LSH), clustering, and dimensionality reduction.
Graph Data: Implementing algorithms like PageRank, SimRank, community detection, and spam detection.
Infinite Data: Managing data streams through filtering, web advertising, and processing queries on streams.
Machine Learning Algorithms: Decisions trees, Perceptron, k-Nearest Neighbors (kNN), Support Vector Machines (SVM), and Deep Learning.
Applications: Recommender systems, association rules, and duplicate document detection.
Supervised Learning Foundations
The goal of supervised learning is prediction by learning a function such that .
The target variable can take several forms:
Regression: When is a real number.
Classification: When is categorical.
Complex Objects: When the target involves more structured data.
Data in supervised learning is labeled, consisting of pairs .
The process typically involves splitting data into a training set and a test set.
Linear Models: The Perceptron
The Perceptron is an early linear model (Rosenblatt, 1958) used for binary classification.
Example: Spam Filtering:
Instance space where data points.
Features are binary or real-valued vectors based on word occurrences (e.g., "viagra", "dating", "nigeria").
There are features in total.
Class labels where for Spam and for Ham.
Classification Logic:
The decision boundary is linear.
if
otherwise.
Vectors are real-valued and normalized such that .
The goal is to find the weight vector .
Neuron Motivation:
Inputs represent feature values, each with a weight .
The activation is the sum: .
Prediction is if the activation is positive and if negative.
Perceptron Learning Algorithm (PLA):
Iterative process: Pick a currently misclassified point .
Update rule: .
Strengths and Weaknesses:
Good: Perceptron convergence theorem states that if data is linearly separable, the algorithm will converge.
Bad: If data is not separable, the weights will cycle indefinitely without converging.
Bad: It has mediocre generalization because it finds a "barely" separating solution.
Support Vector Machines (SVM)
SVMs aim to separate data classes using a line or hyperplane with the largest possible margin.
Large Margin Principle:
Distance from the separating hyperplane corresponds to prediction confidence.
The margin is the distance of the closest example from the decision boundary.
Prediction is given by .
Confidence for the -th point is .
The goal is to solve .
Deriving the Margin:
Consider Line , where .
For a point and a point on the line:
.
Note: This assumes .
Canonical Hyperplane and Normalization:
Scaling and increases the margin artificially.
Solution: Normalize weights such that for the closest points.
Let be on the plane and on the plane.
Relation: .
Since and , it follows that the distance between planes is .
Substituting for : .
Hard Constraint Optimization:
To maximize , we minimize .
Final objective: subject to .
Non-linearly Separable Data and Slack Variables
If data is not separable, hard margins fail. A penalty is introduced to allow for mistakes.
Slack Variables (\xi_i):
If point is on the wrong side of the margin, it incurs a penalty .
Objective with slack:
Subject to: and .
Slack Penalty :
High : Strict separation; values weights of heavily (hard margin approach).
Low : Permissive of mistakes to achieve a wider margin.
: Ignores the data (weights become zero).
Hinge Loss Form:
The "natural" form of SVM uses hinge loss for empirical error:
SVM Optimization and Solvers
Standard solvers use quadratic programming (minimizing a quadratic function under linear constraints).
Problem: Quadratic solvers are inefficient for massive datasets.
Alternative: Gradient Descent:
Used for minimizing convex functions .
Iterative update: , where is the learning rate.
Stochastic Gradient Descent (SGD):
Instead of computing gradients over all examples (which takes time), evaluate per individual example.
For each iteration:
For to :
Update weights: .
Case Study: Text Categorization:
Dataset: Reuters RCV1 documents.
Stats: training examples, test examples, features (words).
Finding: SGD-SVM is super fast and achieves a test error comparable to standard SVM solvers.
Practical Parameters:
Choose so initial updates match expected weight sizes.
Choose by testing small subsamples (e.g., ) and picking the one that reduces cost most.
Use early stopping with a validation set; stop when validation loss stops decreasing.
Deep Learning and Neural Networks
Deep neural networks use linear transformations combined with non-linear activation functions.
Inspired by the brain's massive modeling power:
Human neuron switching time is .
Human brain has neurons.
Scene recognition in humans takes .
Multi-Layer Perceptron (MLP):
Modern MLPs use multiple layers and differentiable activations like the Sigmoid function.
Sigmoid function: .
The derivative is .
Capable of capturing highly non-linear surfaces via backpropagation.
Convolutional Neural Networks (CNNs):
Take advantage of spatial information.
Feature translation invariance and weight sharing.
Hierarchical feature extraction.
Hyperparameter Optimization:
Common methods: Grid search, Random search, Bayesian optimization.
Tools: HyperOpt, Optuna.
Optimizer of choice: Adam (Adaptive optimizer based on gradients).
Parallelization in Machine Learning
Scale: Performance increases logarithmically relative to training data volume ().
Parallelization Strategies:
Model Parallelism: Different machines handle different parts of the model.
Data Parallelism: Data is partitioned (sharded) and processed by different workers.
Parameter Server Architecture:
A Key/Value store where Keys index model parameters (weights) and Values are the weights themselves.
Challenges include bandwidth limits, synchronization, and fault tolerance.
Asynchronous SGD (Async SGD):
Workers overwrite parameters opportunistically without central synchronization.
Theoretical slower convergence, but practically the same when gradients are sparse.
Example research: "HOGWILD!" (Recht et al., 2011).
Google's Large Scale Distributed Deep Networks (2012) combined model/data parallelism with Async SGD, fueling modern deep learning.
Reinforcement Learning (RL) and Specialized Architectures
RL involves an agent interacting with an environment through actions, receiving states and rewards.
Deep Q-Networks (DQN) (Mnih et al., 2015):
Neural networks used to approximate action-value functions.
Improved versions include DDQN, Prioritized DDQN, Dueling DDQN, and Rainbow.
A3C (Asynchronous Advantage Actor-Critic):
Global network updated by multiple individual workers interacting with their own environments.
AlphaGo:
AlphaGo Fan, AlphaGo Lee, AlphaGo Master, and AlphaGo Zero.
AlphaGo Zero (Silver, 2017) utilized 40 blocks and surpassed previous versions within days, reaching an Elo rating over 5,000.
Discussion and Events
Upcoming Events and Exam Materials:
Invited talk by Jelena Grujic (Dataminded): Focus on industry application of big data (Attendance expected for exam preparation).
Flip the classroom: Scalability to facilitate LLMs.
Deep Dive into LLMs (Andrej Karpathy): Essential video material for the course covering ChatGPT and Transformers.
Ethics: Balancing risk and innovation in big data is critical for responsible ML development with real-world impact.