Machine Learning: Data Representation and Exploration Notes
Machine Learning Overview and Historical Context
Artificial intelligence (AI) encompasses historical developments and significant scientific breakthroughs that led to modern applications.
Historical Milestones:
Perceptron (1958): A foundational neural network structure. The mathematical model defines the output () as , where are inputs, are weights, and outputs are typically in the set .
Backpropagation (1986): A critical development in training neural networks, enabling deeper architectures and complex function mappings, such as , , , and .
Modern AI Applications:
Consumer AI: Generative models for content creation.
Research AI: Applications in Protein Folding (biology), Game Engines (simulation), and Autonomous Driving (transportation).
Fundamental Data Representation
Objects of interest (e.g., cars, persons, countries) are assumed to be represented as -dimensional column vectors unless otherwise noted.
Example: Porsche Playing Cards: A car is represented as a 6-dimensional column vector ():
Porsche 959 (1988):
Model Year:
Displacement:
Power Output:
Acceleration:
Top Speed:
Weight:
Porsche 911 GT1 (1997): []
Porsche Carrera GT (2003): []
The Data Matrix ():
All representations are collected into a matrix .
Rows: Called samples (denoted ).
Columns: Called features (denoted ).
Notation:
: The -th sample.
: The -th feature (entire column).
: The -th feature of the -th sample.
Feature Types and Encodings
Features are categorized based on their data properties:
Categorical Features (Unordered):
Binary: Takes two values, e.g., .
Nominal: Takes multiple unordered values, e.g., .
Numerical Features (Ordered):
Ordinal: Ordered labels without consistent spacing, e.g., .
Discrete: Countable values, e.g., .
Continuous: Real-valued numbers, e.g., (mass, distance).
1-of-k Encoding (One-Hot Encoding): Categorical data is converted to numerical vectors. For example, animal types [cat, dog, rabbit] become binary columns where a "cat" is [] and a "rabbit" is [].
Complex Data Structures
Text Data: Represented using Bag-of-Words.
Words are counted after ignoring capitalization and punctuation based on a defined dictionary.
Pro: Allows distance/similarity computation between documents.
Con: Ignores word order (e.g., "The policeman handcuffed the robber" looks the same as "The robber handcuffed the policeman").
Image Data: Represented as sequences of grayscale pixel intensities.
Values range from (black) to (white).
Dimensionality is extremely high; a resolution image has over pixels.
Graph Data: Represented via Adjacency Matrices.
Entries can be binary (presence of an edge) or numerical (edge weights).
Operations on Features
Aggregation: Grouping raw features to reduce combinations (e.g., grouping specific cities into countries like Germany or France).
Transformation (Discretization/Binning): Turning numerical data into categorical data (e.g., converting ages into bins like <20, , and ).
Selection: Removing irrelevant features (e.g., StudentID) to treat similar samples equally.
Data Size Rule of Thumb: A popular approximation for the required number of samples is n > 10 \times d.
Data Cleaning: Identifying and fixing issues including noise (distortion), outliers (entry errors), missing values, and duplicated data.
Data Exploration and Categorical Statistics
Exploration aims to find outliers, corrupt data, feature correlations, and understand data distribution/ranges using statistics and visualization.
Frequency: The fraction of entries belonging to a specific class .
Distribution: The set of frequencies for all classes.
Mode: The most frequent class in the dataset.
Entropy (): Measures the randomness or "average units of information" in a sample.
Formula:
Range: (no randomness) to (total randomness, where all classes have equal frequency).
Exercise (Binary Entropy): If a binary feature is "1" with probability , the entropy is .
Numerical Statistics
Range: Defined by the minimum and maximum: . Anomalies (negative mass, unit mismatch) can be identified here.
Arithmetic Mean (): A measure of central tendency: .
Standard Deviation (): A measure of statistical dispersion: .
Sample Variance: Denoted as .
Robust Statistics:
Median (): The middle value of a sorted list. For odd , it is at position . For even , it is the average of positions and . It is less sensitive to outliers than the mean.
Interquartile Range (): The range between the first quartile (, -quantile) and third quartile (, -quantile). .
Quantiles: A value is a -quantile if a fraction of entries are .
, , , , .
Correlation and Distances
Sample Covariance: .
Correlation Coefficient (): Measures linear correlation: .
Range: .
Invariance: Invariant under linear transformations .
Distances:
Euclidean Distance: .
Hamming Distance: Counts the number of positions where values differ: (useful for categorical data).
Limitations of Statistics and Visualization Tools
Anscombe's Quartet & Datasaurus Dozen: Datasets with identical summary statistics (mean, variance, correlation) but vastly different visual distributions, highlighting the necessity of visualization.
Visualization Methods:
Quantile Plot: Maps data values against their $q$-quantiles.
Box Plot: Displays and visually.
Histogram: Visualizes counts aggregated into bins.
Line Plot: Shows one variable as a function of another.
Scatter Plot: Explores joint distribution of two features; color can represent a third variable.
Matrix Plot: Heatmap showing all matrix entries or pairwise correlations.
Introduction to Supervised Learning
Motivation: Determining cause-and-effect in complex scenarios (e.g., tracking food intake to identify allergies).
Setup:
Input: Features of samples (e.g., quantities of food eaten).
Output: Class labels (e.g., sick or not sick).
Goal: Find a model to accurately predict labels for new samples.
Classification: A branch of supervised learning where labels are categorical. The resulting model is a classifier.