The Elements of Statistical Learning Key Concepts (统计学习要素核心概念)¶
来源: The Elements of Statistical Learning (Hastie, Tibshirani, Friedman)
编译时间: 2026-06-01
状态: 中英对照编译
基于: ESL 第 2-7 章核心概念
关联: 统计学概念, 机器学习资源
📚 目录 (Table of Contents)¶
1. 监督学习导论 (Introduction to Supervised Learning)¶
1.1 学习框架 (Learning Framework)¶
英文:
Supervised learning involves learning a function f: X → Y from labeled training data. The goal is to predict the output Y for new input X.
中文:
监督学习涉及从有标签的训练数据中学习函数 f: X → Y。目标是为新输入 X 预测输出 Y。
符号表示 (Notation):
| 符号 | 英文 | 中文 |
|---|---|---|
| X | Input variables | 输入变量 |
| Y | Output variable | 输出变量 |
| (xᵢ, yᵢ) | Training observations | 训练观测 |
| f̂ | Estimated function | 估计函数 |
| L(Y, f(X)) | Loss function | 损失函数 |
1.2 损失函数 (Loss Functions)¶
英文:
The loss function L(Y, f(X)) quantifies the error in predicting Y by f(X). Common choices include squared error for regression and 0-1 loss for classification.
中文:
损失函数 L(Y, f(X)) 量化用 f(X) 预测 Y 的误差。常见选择包括回归的平方误差和分类的 0-1 损失。
常见损失函数 (Common Loss Functions):
| 损失 | 公式 | 适用场景 |
|---|---|---|
| 平方误差 | L(Y, f(X)) = (Y - f(X))² | 回归 |
| 绝对误差 | L(Y, f(X)) = |Y - f(X)| | 鲁棒回归 |
| 0-1 损失 | L(Y, f(X)) = I(Y ≠ f(X)) | 分类 |
| 对数损失 | L(Y, p) = -log p(Y|X) | 概率分类 |
1.3 偏差 - 方差分解 (Bias-Variance Decomposition)¶
英文:
The expected prediction error can be decomposed into bias, variance, and irreducible error components.
中文:
期望预测误差可以分解为偏差、方差和不可约误差三个组成部分。
分解公式 (Decomposition Formula):
其中: - Bias²: 模型预测的期望与真实值的差异 - Var: 模型预测的方差 - σ²: 不可约误差 (噪声)
偏差 - 方差权衡 (Bias-Variance Tradeoff):
误差
↑
│ 总误差
│ ╱
│ ╱
│ ╱
│ ╱
│ ╱
│ ╱
│ ╱
│ ╱
│ ╱
│ ╱
│───────────────────→ 模型复杂度
│
│─ ─ ─ ─ 偏差²
│
│ ─ ─ ─ ─ 方差
2. 线性回归方法 (Linear Regression Methods)¶
2.1 最小二乘法 (Least Squares Method)¶
英文:
The least squares method estimates β by minimizing the residual sum of squares (RSS).
中文:
最小二乘法通过最小化残差平方和 (RSS) 来估计 β。
目标函数 (Objective Function):
最小二乘解 (Least Squares Solution):
Python 实现 (Python Implementation):
import numpy as np
def least_squares(X, y):
"""
普通最小二乘法
参数:
X: 设计矩阵 (N × p)
y: 响应变量 (N × 1)
返回:
beta: 系数估计 (p × 1)
"""
# 添加截距项
X_with_intercept = np.column_stack([np.ones(X.shape[0]), X])
# 最小二乘解
beta = np.linalg.inv(X_with_intercept.T @ X_with_intercept) @ X_with_intercept.T @ y
return beta
# 使用示例
# beta_hat = least_squares(X, y)
2.2 线性回归的统计推断 (Statistical Inference for Linear Regression)¶
英文:
Under the assumption of normally distributed errors, we can perform hypothesis tests and construct confidence intervals for the regression coefficients.
中文:
在误差服从正态分布的假设下,我们可以对回归系数进行假设检验和构建置信区间。
系数标准误 (Coefficient Standard Errors):
其中 \(\hat{\sigma}^2 = \frac{\text{RSS}}{N - p - 1}\)
t 统计量 (t-Statistic):
3. 线性分类方法 (Linear Classification Methods)¶
3.1 线性判别分析 (Linear Discriminant Analysis, LDA)¶
英文:
LDA models the class densities as multivariate normal distributions with common covariance matrix and classifies based on the linear discriminant functions.
中文:
LDA 将类密度建模为具有共同协方差矩阵的多元正态分布,并基于线性判别函数进行分类。
判别函数 (Discriminant Function):
其中: - \(\mu_k\): 类 k 的均值向量 - \(\Sigma\): 共同协方差矩阵 - \(\pi_k\): 类 k 的先验概率
分类规则 (Classification Rule):
3.2 逻辑回归 (Logistic Regression)¶
英文:
Logistic regression models the log-odds of the probability as a linear function of the inputs.
中文:
逻辑回归将概率的对数几率建模为输入的线性函数。
模型公式 (Model Formula):
极大似然估计 (Maximum Likelihood Estimation):
4. 基展开与正则化 (Basis Expansions and Regularization)¶
4.1 基展开 (Basis Expansions)¶
英文:
Basis expansions transform the original input variables into a richer feature space, allowing linear methods to capture nonlinear relationships.
中文:
基展开将原始输入变量转换为更丰富的特征空间,使线性方法能够捕捉非线性关系。
常见基函数 (Common Basis Functions):
| 基类型 | 公式 | 用途 |
|---|---|---|
| 多项式 | h_j(X) = X^j | 平滑非线性 |
| 分段常数 | h_j(X) = I(c_j ≤ X < c_{j+1}) | 阶梯函数 |
| 样条 | Cubic splines | 平滑分段多项式 |
| 小波 | Wavelet bases | 局部特征 |
样条基 (Spline Basis):
自然三次样条:
│ ╭───╮
│ ╱ ╲
│ ╱ ╲
│ ╱ ╲
│ ╱ ╲
│╱ ╲
──────┼───────────────┼─────
t₁ t₂ t₃ t₄
←── 结 (Knots) ──→
4.2 岭回归 (Ridge Regression)¶
英文:
Ridge regression shrinks the coefficients by adding an L2 penalty term to the least squares objective.
中文:
岭回归通过在最小二乘目标中添加 L2 惩罚项来收缩系数。
岭回归目标 (Ridge Objective):
岭回归解 (Ridge Solution):
Python 实现 (Python Implementation):
def ridge_regression(X, y, lambda_param):
"""
岭回归
参数:
X: 设计矩阵 (N × p)
y: 响应变量 (N × 1)
lambda_param: 正则化参数 λ
返回:
beta: 系数估计 (p × 1)
"""
p = X.shape[1]
# 添加截距项
X_with_intercept = np.column_stack([np.ones(X.shape[0]), X])
# 惩罚矩阵 (不对截距惩罚)
penalty_matrix = lambda_param * np.eye(p + 1)
penalty_matrix[0, 0] = 0 # 不惩罚截距
# 岭回归解
beta = np.linalg.inv(X_with_intercept.T @ X_with_intercept + penalty_matrix) @ X_with_intercept.T @ y
return beta
# 使用示例
# beta_ridge = ridge_regression(X, y, lambda_param=1.0)
4.3 Lasso (Least Absolute Shrinkage and Selection Operator)¶
英文:
Lasso uses an L1 penalty, which has the effect of forcing some coefficients to be exactly zero, thus performing variable selection.
中文:
Lasso 使用 L1 惩罚,其效果是强制一些系数恰好为零,从而执行变量选择。
Lasso 目标 (Lasso Objective):
岭回归 vs Lasso (Ridge vs Lasso):
| 特性 | 岭回归 | Lasso |
|---|---|---|
| 惩罚类型 | L2 (平方) | L1 (绝对值) |
| 系数收缩 | 连续收缩 | 可收缩到零 |
| 变量选择 | 否 | 是 |
| 计算 | 解析解 | 需要数值优化 |
| 适用场景 | 所有预测变量相关 | 稀疏模型 |
几何解释 (Geometric Interpretation):
Lasso (L1): 岭回归 (L2):
β₂ β₂
↑ ↑
│ ╭───╮ │ ╭───╮
│ ╱ ╲ │ ╱ ╲
│╱ ╲ │ ╱ ╲
└─────────┼──→ β₁ │ ╱ ╲
╱│╲ ╱│ │╱ ╲
╱ │ ╲ ╱ │ └─────────────┼──→ β₁
╱ │ ╲ ╱ │ ╱ ╱
╱ │ ╲ ╱ │ ╱ ╱
────────────── ╱ ╱
菱形约束 圆形约束
5. 核光滑方法 (Kernel Smoothing Methods)¶
5.1 核密度估计 (Kernel Density Estimation)¶
英文:
Kernel density estimation is a nonparametric method for estimating the probability density function of a random variable.
中文:
核密度估计是一种非参数方法,用于估计随机变量的概率密度函数。
核密度估计公式 (KDE Formula):
其中: - \(K\): 核函数 (如高斯核) - \(h\): 带宽 (平滑参数)
常见核函数 (Common Kernel Functions):
| 核函数 | 公式 | 形状 |
|---|---|---|
| 高斯核 | K(u) = (1/√(2π)) exp(-u²/2) | 钟形 |
| 均匀核 | K(u) = 0.5 × I(|u| ≤ 1) | 矩形 |
| Epanechnikov | K(u) = 0.75 × (1 - u²) × I(|u| ≤ 1) | 抛物线 |
5.2 Nadaraya-Watson 回归 (Nadaraya-Watson Regression)¶
英文:
The Nadaraya-Watson estimator is a kernel-based method for nonparametric regression.
中文:
Nadaraya-Watson 估计器是一种基于核的非参数回归方法。
NW 估计器 (NW Estimator):
6. 模型评估与选择 (Model Inference and Selection)¶
6.1 交叉验证 (Cross-Validation)¶
英文:
Cross-validation is a resampling method for estimating the prediction error of a model and for model selection.
中文:
交叉验证是一种重采样方法,用于估计模型的预测误差和进行模型选择。
K 折交叉验证 (K-Fold Cross-Validation):
K=5 折交叉验证:
数据: [█████][█████][█████][█████][█████]
↓
Fold 1: [测试 ][训练 ][训练 ][训练 ][训练 ]
Fold 2: [训练 ][测试 ][训练 ][训练 ][训练 ]
Fold 3: [训练 ][训练 ][测试 ][训练 ][训练 ]
Fold 4: [训练 ][训练 ][训练 ][测试 ][训练 ]
Fold 5: [训练 ][训练 ][训练 ][训练 ][测试 ]
↓
平均 CV 误差
CV 误差估计 (CV Error Estimate):
其中 \(\hat{f}^{-\kappa(i)}\) 是在不包含第 i 个观测的折上拟合的模型。
6.2 信息准则 (Information Criteria)¶
英文:
Information criteria provide a measure of model quality that penalizes model complexity.
中文:
信息准则提供了惩罚模型复杂度的模型质量度量。
常见信息准则 (Common Information Criteria):
| 准则 | 公式 | 特点 |
|---|---|---|
| AIC | AIC = -2ℓ + 2p | 渐近等价于留一 CV |
| BIC | BIC = -2ℓ + p log(N) | 更强惩罚,一致性 |
| Cp | Cp = RSS/σ̂² - N + 2p | 用于线性模型 |
6.3 偏差 - 方差权衡实践 (Bias-Variance Tradeoff in Practice)¶
训练误差 vs 测试误差 (Training Error vs Test Error):
误差
↑
│
│ 测试误差
│ ╱
│ ╱ ← 最优复杂度
│ ╱│
│ ╱ │
│ ╱ │
│ ╱ │
│ ╱ │
│ ╱ │
│ ╱ │
│ ╱ │
│────────────────│─────→ 模型复杂度
│ │
│ │
│ 训练误差 ──────│
│
7. 树与集成方法 (Trees and Ensemble Methods)¶
7.1 决策树 (Decision Trees)¶
英文:
Decision trees partition the feature space into regions and fit a simple model (usually a constant) in each region.
中文:
决策树将特征空间划分为区域,并在每个区域中拟合一个简单模型 (通常是常数)。
树的分割 (Tree Partitioning):
特征空间分割:
x₂
↑
│
R₂ │ R₁
────┼─────
R₃ │ R₄
│
└─────────→ x₁
对应的树:
x₁ < t₁?
╱ ╲
是 否
╱ ╲
x₂ < t₂? x₂ < t₃?
╱ ╲ ╱ ╲
R₂ R₁ R₃ R₄
分裂准则 (Splitting Criterion):
| 问题类型 | 准则 | 公式 |
|---|---|---|
| 回归 | 最小化 RSS | min Σ(yᵢ - ȳ_R)² |
| 分类 | 基尼指数 | 1 - Σ p̂_mk² |
| 分类 | 交叉熵 | -Σ p̂_mk log p̂_mk |
7.2 随机森林 (Random Forests)¶
英文:
Random forests are an ensemble method that builds many decision trees and averages their predictions, with additional randomness in the feature selection at each split.
中文:
随机森林是一种集成方法,它构建许多决策树并平均它们的预测,并在每次分裂时在特征选择中引入额外的随机性。
随机森林算法 (Random Forest Algorithm):
For b = 1 to B:
1. 从训练数据中有放回抽取 bootstrap 样本
2. 生长决策树 T_b:
- 在每个节点:
a. 从 m 个变量中随机选择
b. 选择最佳分裂点
c. 将节点分成两个子节点
3. 返回树 T_b
预测:
- 回归: ŷ = (1/B) Σ T_b(x)
- 分类: ŷ = majority vote{T_b(x)}
7.3 梯度提升 (Gradient Boosting)¶
英文:
Gradient boosting builds an ensemble of trees sequentially, where each tree is fit to the residual errors of the previous trees.
中文:
梯度提升顺序构建树的集成,其中每棵树拟合前面树的残差误差。
梯度提升算法 (Gradient Boosting Algorithm):
1. 初始化: F₀(x) = argmin_γ Σ L(yᵢ, γ)
2. For m = 1 to M:
a. 计算伪残差: rᵢₘ = -[∂L(yᵢ, F(xᵢ))/∂F(xᵢ)]|_{F=Fₘ₋₁}
b. 拟合回归树到 rᵢₘ, 得到叶子区域 Rⱼₘ
c. 计算叶子值: γⱼₘ = argmin_γ Σ L(yᵢ, Fₘ₋₁(xᵢ) + γ)
d. 更新: Fₘ(x) = Fₘ₋₁(x) + ν Σ γⱼₘ I(x ∈ Rⱼₘ)
3. 输出: F_M(x)
其中 ν 是学习率 (shrinkage parameter)。
🔑 关键术语对照表 (Glossary)¶
| English | 中文 | 定义 |
|---|---|---|
| Supervised learning | 监督学习 | 从标注数据学习预测函数 |
| Loss function | 损失函数 | 量化预测误差的函数 |
| Bias-variance tradeoff | 偏差 - 方差权衡 | 模型复杂度与泛化能力的平衡 |
| Least squares | 最小二乘法 | 最小化残差平方和的估计方法 |
| Ridge regression | 岭回归 | L2 正则化的线性回归 |
| Lasso | Lasso | L1 正则化的线性回归 |
| Basis expansion | 基展开 | 将输入转换到更丰富特征空间 |
| Kernel smoothing | 核光滑 | 基于核的非参数估计方法 |
| Cross-validation | 交叉验证 | 重采样评估预测误差 |
| Decision tree | 决策树 | 基于树分割的特征空间划分 |
| Random forest | 随机森林 | 树的 bagging 集成 |
| Gradient boosting | 梯度提升 | 顺序拟合残差的集成方法 |
| AIC/BIC | AIC/BIC | 模型选择信息准则 |
编译完成时间: 2026-06-01
来源: The Elements of Statistical Learning 第 2-7 章
关联文档: ../../wikipedia-concepts/statistics-concepts-zh-en.md