Skip to content

Wikipedia Ensemble Learning and Clustering Concepts (维基百科集成学习与聚类概念)

来源: Wikipedia (英文维基百科)
编译时间: 2026-06-01
状态: 中英对照编译
基于: Ensemble learning, Clustering, Dimensionality reduction 等条目
关联: 深度学习概念, 机器学习资源


📚 目录 (Table of Contents)

  1. 集成学习基础
  2. Bagging 与随机森林
  3. Boosting 方法
  4. Stacking 与混合
  5. 聚类基础
  6. K-Means 与层次聚类
  7. 密度聚类与谱聚类
  8. 降维方法

1. 集成学习基础 (Ensemble Learning Basics)

1.1 集成学习定义 (Ensemble Learning Definition)

英文:

Ensemble learning is a machine learning paradigm where multiple models (weak learners) are combined to produce a better predictive performance than any individual model.

中文:

集成学习是一种机器学习范式,其中多个模型 (弱学习器) 组合产生比任何单个模型更好的预测性能。

集成学习原理 (Ensemble Learning Principle):

弱学习器 1 ──┐
弱学习器 2 ──┼──► 组合 ──► 强学习器
弱学习器 3 ──┘

为什么集成有效 (Why Ensembles Work):

原因 英文 中文
统计 Averaging reduces variance 平均减少方差
计算 Avoids local minima 避免局部最优
表示 Expands hypothesis space 扩展假设空间

1.2 集成多样性 (Ensemble Diversity)

英文:

The key to successful ensemble is diversity - the individual models should make different errors.

中文:

集成成功的关键是多样性 - 个体模型应该犯不同的错误。

多样性来源 (Sources of Diversity):

来源 方法 示例
数据 不同训练集 Bootstrap, Subsampling
特征 不同特征子集 随机子空间
模型 不同算法 混合模型
参数 不同初始化 神经网络多起点

2. Bagging 与随机森林 (Bagging and Random Forests)

2.1 Bagging (Bootstrap Aggregating)

英文:

Bagging creates multiple versions of a predictor by training on bootstrap samples and aggregates their predictions.

中文:

Bagging 通过在 bootstrap 样本上训练预测器的多个版本并聚合它们的预测。

Bagging 算法 (Bagging Algorithm):

import numpy as np
from sklearn.tree import DecisionTreeClassifier

class BaggingClassifier:
    def __init__(self, n_estimators=100, max_samples=1.0):
        self.n_estimators = n_estimators
        self.max_samples = max_samples
        self.estimators = []

    def fit(self, X, y):
        n_samples = len(X)
        bootstrap_size = int(self.max_samples * n_samples)

        for _ in range(self.n_estimators):
            # Bootstrap 采样
            indices = np.random.choice(n_samples, bootstrap_size, replace=True)
            X_bootstrap = X[indices]
            y_bootstrap = y[indices]

            # 训练基学习器
            estimator = DecisionTreeClassifier()
            estimator.fit(X_bootstrap, y_bootstrap)
            self.estimators.append(estimator)

    def predict(self, X):
        # 聚合预测 (投票)
        predictions = np.array([est.predict(X) for est in self.estimators])
        return np.apply_along_axis(
            lambda x: np.bincount(x).argmax(), 
            axis=0, 
            arr=predictions
        )

2.2 随机森林 (Random Forests)

英文:

Random forests extend bagging by adding random feature selection at each split, reducing correlation between trees.

中文:

随机森林扩展 bagging,在每次分裂时添加随机特征选择,减少树之间的相关性。

随机森林参数 (Random Forest Parameters):

参数 英文 作用 典型值
n_estimators 树的数量 控制集成大小 100-500
max_features 最大特征数 控制多样性 √p 或 p/3
max_depth 最大深度 控制过拟合 无限制或 10-20
min_samples_split 最小分裂样本 控制树生长 2-10

随机森林 vs 决策树:

特性 单棵决策树 随机森林
方差
偏差 略高
过拟合 容易 较难
可解释性 较差
准确率 中等

3. Boosting 方法 (Boosting Methods)

3.1 AdaBoost

英文:

AdaBoost adaptively weights training samples, giving more weight to misclassified instances in each iteration.

中文:

AdaBoost 自适应地加权训练样本,在每次迭代中给错分实例更多权重。

AdaBoost 数学原理 (AdaBoost Mathematics):

初始化: w_i = 1/N

For m = 1 to M:
  1. 训练弱分类器 G_m
  2. 计算加权误差: err_m = Σ w_i I(y_i ≠ G_m(x_i))
  3. 计算分类器权重: α_m = log((1-err_m)/err_m)
  4. 更新样本权重: w_i ← w_i × exp(α_m × I(y_i ≠ G_m(x_i)))

最终: G(x) = sign(Σ α_m G_m(x))

3.2 梯度提升 (Gradient Boosting)

英文:

Gradient boosting builds an ensemble of weak learners sequentially, where each new learner corrects the errors of the previous ones.

中文:

梯度提升顺序构建弱学习器的集成,每个新学习器纠正前面学习器的错误。

GBDT vs XGBoost vs LightGBM:

特性 GBDT XGBoost LightGBM
正则化 L1+L2 L1+L2
树生长 层次 层次 叶子-wise
缺失值 需处理 自动 自动
速度 最快
准确率 很好 很好

3.3 Stacking (Stacked Generalization)

英文:

Stacking combines multiple models using a meta-learner that learns how to best combine the base models' predictions.

中文:

Stacking 使用元学习器组合多个模型,元学习器学习如何最佳地组合基模型的预测。

Stacking 架构 (Stacking Architecture):

Level 0 (基学习器):
  模型 1 ──► 预测 1 ─┐
  模型 2 ──► 预测 2 ─┼──► Level 1
  模型 3 ──► 预测 3 ─┘       │
                         元学习器
                      最终预测

4. Stacking 与混合 (Stacking and Blending)

4.1 Stacking 实现 (Stacking Implementation)

英文:

In stacking, base models are trained on the full training set, and the meta-model is trained on out-of-fold predictions.

中文:

在 stacking 中,基模型在完整训练集上训练,元模型在折外预测上训练。

Python 实现 (Python Implementation):

from sklearn.model_selection import cross_val_predict
from sklearn.linear_model import LogisticRegression

class StackingClassifier:
    def __init__(self, base_estimators, meta_estimator):
        self.base_estimators = base_estimators
        self.meta_estimator = meta_estimator
        self.meta_features_ = None

    def fit(self, X, y):
        # 生成折外预测作为元特征
        meta_features = []
        for name, clf in self.base_estimators:
            oof_pred = cross_val_predict(clf, X, y, cv=5, method='predict_proba')
            meta_features.append(oof_pred)

        self.meta_features_ = np.hstack(meta_features)

        # 训练元模型
        self.meta_estimator.fit(self.meta_features_, y)

        # 在完整数据上重新训练基模型
        for name, clf in self.base_estimators:
            clf.fit(X, y)

    def predict(self, X):
        meta_features = []
        for name, clf in self.base_estimators:
            pred = clf.predict_proba(X)
            meta_features.append(pred)

        meta_features = np.hstack(meta_features)
        return self.meta_estimator.predict(meta_features)

4.2 Blending

英文:

Blending is similar to stacking but uses a hold-out validation set instead of cross-validation for training the meta-model.

中文:

Blending 类似于 stacking,但使用保留验证集而非交叉验证来训练元模型。

Blending vs Stacking:

特性 Blending Stacking
元特征生成 保留集 交叉验证
数据利用 较少 更充分
过拟合风险 较低 较高
实现复杂度 简单 复杂

5. 聚类基础 (Clustering Basics)

5.1 聚类定义 (Clustering Definition)

英文:

Clustering is an unsupervised learning task that groups similar objects together based on their features without using labeled data.

中文:

聚类是一种无监督学习任务,基于特征将相似对象分组,不使用标注数据。

聚类 vs 分类:

特性 聚类 分类
学习类型 无监督 有监督
训练数据 无标签 有标签
目标 发现结构 预测类别
评估 内部指标 准确率等

5.2 距离度量 (Distance Metrics)

英文:

Distance metrics quantify the dissimilarity between data points and are fundamental to clustering algorithms.

中文:

距离度量量化数据点之间的相异性,是聚类算法的基础。

常见距离度量 (Common Distance Metrics):

距离 公式 适用场景
欧氏距离 d(x,y) = √(Σ(xᵢ-yᵢ)²) 连续变量
曼哈顿距离 d(x,y) = Σ xᵢ-yᵢ
闵可夫斯基距离 d(x,y) = (Σ xᵢ-yᵢ
余弦相似度 cos(θ) = (x·y)/(
Jaccard J(A,B) = A∩B

6. K-Means 与层次聚类 (K-Means and Hierarchical Clustering)

6.1 K-Means 算法 (K-Means Algorithm)

英文:

K-means partitions data into K clusters by minimizing the within-cluster sum of squared distances.

中文:

K-means 通过最小化簇内平方距离和将数据划分为 K 个簇。

K-Means 算法 (K-Means Algorithm):

1. 随机初始化 K 个中心 μ₁, μ₂, ..., μ_K
2. 重复直到收敛:
   a. 分配步骤: 将每个点分配到最近的中心
      C_k = {x_i : ||x_i - μ_k||² ≤ ||x_i - μ_j||² ∀j}
   b. 更新步骤: 重新计算中心
      μ_k = (1/|C_k|) Σ_{x∈C_k} x

选择 K 值 (Choosing K):

方法 英文 说明
肘部法则 Elbow Method 寻找 SSE 下降的拐点
轮廓系数 Silhouette Score 最大化簇间分离
Gap Statistic Gap Statistic 与随机数据比较

6.2 层次聚类 (Hierarchical Clustering)

英文:

Hierarchical clustering creates a tree of clusters (dendrogram) showing the sequence of cluster merges or splits.

中文:

层次聚类创建簇的树状图 (谱系图),显示簇合并或分裂的序列。

凝聚 vs 分裂 (Agglomerative vs Divisive):

凝聚 (自底向上):     分裂 (自顶向下):
  ○ ○ ○ ○ ○          ○○○○○
   │ │ │ │            │
  ○─○ ○─○ ○          │
   │   │             ├───┐
  ○───┴───○          │   │
                    ○○○ ○○

链式方法 (Linkage Methods):

方法 英文 公式
单链 Single d(A,B) = min d(a,b)
全链 Complete d(A,B) = max d(a,b)
平均链 Average d(A,B) = avg d(a,b)
Ward 法 Ward 最小化方差增加

7. 密度聚类与谱聚类 (Density and Spectral Clustering)

7.1 DBSCAN (Density-Based Spatial Clustering)

英文:

DBSCAN clusters points based on density, identifying core points, border points, and noise.

中文:

DBSCAN 基于密度聚类,识别核心点、边界点和噪声。

DBSCAN 参数 (DBSCAN Parameters):

参数 说明 影响
eps 邻域半径 过小则碎片化,过大则合并
min_samples 最小点数 定义核心点

DBSCAN 优点 (DBSCAN Advantages):

  • ✅ 可发现任意形状的簇
  • ✅ 能识别噪声点
  • ✅ 不需要指定 K 值
  • ❌ 对密度变化敏感
  • ❌ 高维效果差

7.2 谱聚类 (Spectral Clustering)

英文:

Spectral clustering uses the eigenvalues of a similarity matrix to reduce dimensionality before clustering.

中文:

谱聚类在聚类前使用相似性矩阵的特征值进行降维。

谱聚类步骤 (Spectral Clustering Steps):

1. 构建相似性矩阵 W
   w_ij = exp(-||x_i - x_j||² / 2σ²)

2. 计算拉普拉斯矩阵
   L = D - W (非标准化)
   L_sym = D^{-1/2} L D^{-1/2} (标准化)

3. 特征分解
   取前 k 个特征向量 U

4. 在 U 上运行 K-means

8. 降维方法 (Dimensionality Reduction Methods)

8.1 PCA (Principal Component Analysis)

英文:

PCA finds orthogonal directions of maximum variance in the data and projects data onto these principal components.

中文:

PCA 找到数据中方差最大的正交方向,并将数据投影到这些主成分上。

PCA 算法 (PCA Algorithm):

1. 数据中心化: X ← X - μ

2. 计算协方差矩阵: Σ = (1/n) X^T X

3. 特征分解: Σ = V Λ V^T

4. 选择前 k 个主成分

5. 投影: Z = X V_k

选择主成分数 (Choosing Number of Components):

\[ \text{解释方差比例} = \frac{\sum_{i=1}^k \lambda_i}{\sum_{i=1}^p \lambda_i} \]

通常选择能解释 95% 方差的主成分数。

8.2 t-SNE (t-Distributed Stochastic Neighbor Embedding)

英文:

t-SNE is a nonlinear dimensionality reduction technique optimized for visualization, preserving local structure.

中文:

t-SNE 是一种非线性降维技术,优化用于可视化,保持局部结构。

t-SNE vs PCA:

特性 PCA t-SNE
线性/非线性 线性 非线性
保持结构 全局方差 局部邻域
计算速度
可解释性
适用场景 特征提取 可视化

8.3 UMAP (Uniform Manifold Approximation and Projection)

英文:

UMAP is a modern dimensionality reduction technique that preserves both local and global structure better than t-SNE.

中文:

UMAP 是一种现代降维技术,比 t-SNE 更好地保持局部和全局结构。

UMAP 优势 (UMAP Advantages):

  • ✅ 比 t-SNE 更快
  • ✅ 保持全局结构
  • ✅ 可扩展到更大数据集
  • ✅ 可用于降维和可视化

🔑 关键术语对照表 (Glossary)

English 中文 定义
Ensemble learning 集成学习 组合多个模型的方法
Bagging Bagging Bootstrap 聚合
Random forest 随机森林 特征子集的 bagging 树
Boosting Boosting 顺序纠正错误的集成
AdaBoost AdaBoost 自适应提升
Gradient boosting 梯度提升 拟合负梯度的提升
XGBoost XGBoost 正则化梯度提升
Stacking Stacking 元学习器组合模型
Clustering 聚类 无监督分组
K-Means K-Means 基于质心的聚类
Hierarchical clustering 层次聚类 创建谱系图的聚类
DBSCAN DBSCAN 基于密度的聚类
Spectral clustering 谱聚类 基于特征分解的聚类
PCA 主成分分析 线性降维
t-SNE t-SNE 非线性降维可视化
UMAP UMAP 现代流形降维

编译完成时间: 2026-06-01
来源: Wikipedia Ensemble learning, Clustering, PCA, t-SNE 等条目
关联文档: ../../resources/machine-learning-resources.md


**维基百科集成学习与聚类概念 | 中英对照版** [返回顶部](#目录-table-of-contents)