BrainBank

机器学习:中英双语指南

8/3/2026, 8:18:57 PM · updated 8/3/2026, 8:21:13 PM

#knowledge#machine-learning#ml-paradigms#model-selection#data-science-frameworks#algorithm-basics

This article hasn't been translated to English yet — showing the Chinese original.

该中英双语指南为机器学习提供了一套结构化的概念框架,系统区分了学习范式、任务类型与算法家族,并详细指导了从数据准备到生产部署的全流程工程化评估与实战策略。

Machine_Learning_Bilingual_Validated_Guide

Machine Learning: Bilingual Guide

机器学习:中英双语指南

Validation status / 复核结论: The original explanation was broadly correct and well structured. This edition corrects several boundary cases, sharpens algorithm-selection guidance, and distinguishes learning paradigms, task types, model families, and deployment requirements.
原说明整体正确、结构完整。本修订版进一步纠正边界问题,并明确区分学习范式、任务类型、模型家族及生产部署条件。


1. The most important distinction / 最重要的概念区分

Machine learning should not be organized as one flat list. Four different layers are involved:

机器学习不能被理解成一个平铺的算法清单,而应分成四个层次:

  1. Learning paradigm / 学习范式 — how the model receives feedback.
  2. Task type / 任务类型 — what output the model must produce.
  3. Algorithm or model family / 算法或模型家族 — how the relationship is learned.
  4. Operational system / 生产系统 — how the model is evaluated, deployed, monitored, and used.

The basic pipeline is:

Business question → Learning paradigm → Task → Algorithm → Evaluation → Deployment → Monitoring
业务问题 → 学习范式 → 任务类型 → 算法选择 → 评估 → 部署 → 监控

Examples:

  • Supervised learning / 监督学习 is a learning paradigm.
  • Classification / 分类 is a task.
  • Random forest / 随机森林 is an algorithm family.
  • F1, calibration, latency, and drift monitoring / F1、概率校准、延迟和漂移监控 are evaluation and operational concerns.

One algorithm can solve several tasks. Random forests support classification and regression. Neural networks can support classification, regression, generation, representation learning, and reinforcement learning.

同一算法可以解决多种任务。例如随机森林可以分类,也可以回归;神经网络可以用于分类、回归、生成、表示学习及强化学习。


2. Learning paradigms / 学习范式

Paradigm 学习范式Feedback/data 数据与反馈Main purpose 主要目的Typical uses 典型用途
Supervised learning 监督学习Labeled examples 有标签样本Learn input-to-target mapping 学习输入到目标的映射Classification, regression, ranking 分类、回归、排序
Unsupervised learning 无监督学习Unlabeled data 无标签数据Discover structure or representations 发现结构或表示Clustering, dimensionality reduction 聚类、降维
Semi-supervised learning 半监督学习Few labels plus many unlabeled examples 少量标签和大量无标签数据Improve a supervised task with unlabeled data 利用无标签数据改善监督任务Image, text, medical classification 图像、文本、医疗分类
Self-supervised learning 自监督学习Targets generated from raw data 从原始数据构造训练目标Learn reusable representations 学习可复用表示LLM and vision pretraining 大语言模型及视觉预训练
Reinforcement learning 强化学习Rewards from interaction 交互产生的奖励Learn sequential decisions 学习连续决策Control, games, scheduling 控制、游戏、调度
Active learning 主动学习Model requests selected labels 模型选择需要人工标注的样本Reduce labeling cost 降低标注成本Expert document or image review 专业文档或影像标注
Online learning 在线学习Data arrives continuously 数据持续到达Adapt incrementally 持续更新与适应Fraud, recommendation, streaming 欺诈、推荐、数据流
Transfer learning 迁移学习Knowledge from a pretrained model 使用预训练知识Adapt to a related task 迁移到相关任务NLP, vision, speech NLP、视觉、语音
Federated learning 联邦学习Training remains distributed 训练数据保持分散Learn without centralizing raw data 不集中原始数据完成训练Mobile, healthcare, cross-organization 手机、医疗、跨机构

These categories can overlap. A system may use self-supervised pretraining, supervised fine-tuning, active labeling, and online monitoring in the same lifecycle.

这些范式并非互斥。一个系统可以先进行自监督预训练,再做监督微调,同时采用主动标注,并在部署后进行在线监控。


3. Supervised learning / 监督学习

Supervised data contain input features (X) and known targets (y):

监督学习数据包含特征 (X) 和已知目标 (y):

[ f(X) \rightarrow y ]

3.1 Classification / 分类

Classification predicts discrete categories or class probabilities.
分类用于预测离散类别或类别概率。

Form 类型Example 示例
Binary classification 二分类Win/not win; fraud/not fraud 中标/未中标;欺诈/非欺诈
Multiclass classification 多分类Cat, dog, or bird 猫、狗或鸟
Multilabel classification 多标签分类One contract covers IT, cyber, and logistics 一份合同同时涉及IT、网络安全及物流
Ordinal classification 序数分类Low, medium, high risk 低、中、高风险

Common algorithms / 常用算法

Algorithm 算法Strong use cases 适用场景Conditions for effective training 有效训练条件Main limitations 主要局限
Logistic regression 逻辑回归Explainable binary or multiclass business models 可解释业务分类Appropriate encoding; limited severe multicollinearity; linear decision structure in transformed feature space 正确编码;控制严重共线性;变换后的特征空间近似线性Misses complex interactions without feature engineering 无法自动学习复杂交互
Decision tree 决策树Human-readable rules, mixed nonlinear effects 可读规则、混合非线性关系Control depth, leaf size, and pruning 控制深度、叶节点样本量及剪枝Unstable and easily overfits 不稳定且容易过拟合
Random forest 随机森林Robust tabular baseline, nonlinear interactions 稳健的表格基线、非线性交互Enough diverse samples; tune depth, leaf size, and number of trees 足够且多样的数据;调节深度、叶节点及树数Larger and less directly interpretable than one tree 模型较大、解释性弱于单树
Gradient-boosted trees 梯度提升树Often top-performing on structured/tabular data 结构化表格数据常表现优秀Validation, early stopping, careful learning rate/depth tuning 验证集、早停、谨慎调整学习率和深度Sensitive to tuning and leakage 对调参及数据泄漏敏感
XGBoost/LightGBM/CatBoostLarge or complex tabular datasets 大型或复杂表格数据Clean split; correct missing/categorical handling; class imbalance strategy 正确拆分;处理缺失值和类别变量;处理类别不平衡Not normally the first choice for raw images, audio, or long text 通常不是原始图像、音频或长文本的首选
Support Vector Machine (SVM) 支持向量机Medium-sized high-dimensional data, text features 中等规模高维数据、文本特征Scale features; tune kernel and regularization 特征缩放;选择核函数和正则化Kernel SVM scales poorly to very large datasets 核SVM不适合超大数据
K-nearest neighbors (KNN) K近邻Small datasets and similarity-based decisions 小数据及相似案例判断Meaningful distance; feature scaling; manageable dimensionality 距离具有意义;特征缩放;维度不能过高Slow inference and curse of dimensionality 推理慢、受维度灾难影响
Naive Bayes 朴素贝叶斯Spam, document and token-count classification 垃圾邮件、文档和词频分类Distributional assumptions roughly useful; informative token statistics 分布假设具有一定合理性;词项统计有区分度Independence assumption is often unrealistic 独立性假设通常不完全成立
Neural networks 神经网络Images, speech, text, complex high-dimensional data 图像、语音、文本和复杂高维数据Large data or suitable pretrained model; compute; regularization; careful validation 大数据或合适预训练模型;算力;正则化;严格验证Cost, tuning complexity, limited transparency 成本高、调参复杂、透明度有限

Classification metrics / 分类指标

Metric 指标Meaning 含义Best used when 适用情况
Accuracy 准确率Fraction of all predictions correct 总体预测正确比例Classes and error costs are reasonably balanced 类别及错误成本较均衡
Precision 精确率Of predicted positives, how many are correct 预测为正的样本中多少为真False positives are costly 误报成本高
Recall/Sensitivity 召回率/敏感度Of actual positives, how many are found 真实正类中发现多少False negatives are costly 漏报成本高
Specificity 特异度Of actual negatives, how many are rejected correctly 真实负类中正确排除多少Negative-class control matters 需要控制负类误判
F1 scoreHarmonic balance of precision and recall 精确率与召回率的调和平衡Imbalanced classes and both errors matter 类别不平衡且两种错误均重要
ROC-AUCRanking ability across thresholds 跨阈值的整体排序能力General discrimination comparison 一般区分能力比较
PR-AUCPrecision-recall performance across thresholds 跨阈值精确率—召回率表现Positive class is rare 正类稀少
Log lossQuality and confidence of predicted probabilities 概率预测的质量与置信度Probability quality matters 需要可靠概率
Brier scoreMean squared error of probabilities 概率的均方误差Calibration and risk decisions 概率校准及风险决策

For a contract-win model, precision matters when bids are expensive and resources must be concentrated; recall matters when missing a viable opportunity is costly. If the model reports “70% chance of winning,” probability calibration must also be tested.

对于合同中标模型,如果投标成本高、资源需要集中,Precision更重要;如果漏掉可行机会的代价高,Recall更重要。如果模型输出“70%中标概率”,还必须检验概率校准。

3.2 Regression / 回归

Regression predicts a continuous number, such as cost, demand, duration, or contract value.
回归预测连续数值,例如成本、需求量、工期或合同金额。

Algorithm 算法Best use 适用场景Effective conditions 有效条件Limitation 局限
Linear regression 线性回归Explainable linear effects 可解释线性关系Approximate linearity; controlled multicollinearity; residual diagnostics 近似线性;控制共线性;检查残差Weak on complex nonlinear structure 不擅长复杂非线性结构
Ridge 岭回归Many correlated predictors 多个相关特征Standardize features; tune L2 penalty 特征标准化;调节L2惩罚Retains most predictors 通常保留多数特征
LassoSparse model and feature selection 稀疏模型及特征选择Standardize; tune L1 penalty 特征标准化;调节L1惩罚Can select arbitrarily among correlated features 可能在相关特征间任意选择
Elastic Net 弹性网络High-dimensional correlated predictors 高维相关特征Tune L1/L2 mixture 调节L1/L2组合More tuning complexity 调参更复杂
Tree ensembles 树集成Nonlinear tabular prediction 非线性表格预测Sufficient examples; validation and leakage control 足够样本;严格验证和防泄漏Poor extrapolation beyond observed range 通常不擅长超出训练范围外推
Support Vector RegressionMedium-sized nonlinear regression 中型非线性回归Scale features/target; tune kernel 特征及目标缩放;调节核函数Poor scaling to large data 大数据扩展性差
Neural-network regressionComplex, high-dimensional inputs 复杂高维输入Large data/pretraining; regularization; stable targets 大数据/预训练;正则化;目标稳定High cost and lower interpretability 成本高且解释性低
Quantile regression 分位数回归Prediction intervals and asymmetric risk 预测区间及非对称风险Enough data at relevant quantiles; evaluate coverage 相关分位数有足够数据;评估覆盖率Multiple quantiles may require extra constraints 多分位数可能需要额外约束

Common metrics include MAE, MSE, RMSE, (R^2), MAPE, and pinball loss. MAPE becomes unstable when actual values are zero or close to zero. (R^2) alone does not prove accuracy, causality, or operational usefulness.

常见指标包括MAE、MSE、RMSE、(R^2)、MAPE及Pinball Loss。真实值为零或接近零时,MAPE会失真;单独的(R^2)不能证明模型准确、具有因果性或具备业务价值。

3.3 Ranking / 排序学习

Ranking predicts relative order rather than a standalone category. It is useful for contract-opportunity prioritization, search, recommendations, candidate retrieval, and risk triage.

排序学习预测对象的相对顺序,而不是单独类别。适用于合同机会优先级、搜索、推荐、候选对象检索及风险排序。

Common models include RankNet, LambdaRank, LambdaMART, pairwise ranking, and boosted-tree ranking. Training requires query/user/task groups and relevance or preference labels. Evaluate with NDCG, MAP, or MRR. Historical click data require correction for exposure and position bias.

常用模型包括RankNet、LambdaRank、LambdaMART、成对排序及提升树排序。训练需要查询、用户或任务分组,以及相关性或偏好标签。通常使用NDCG、MAP或MRR评估;历史点击数据还要控制曝光偏差和位置偏差。

3.4 Time-series forecasting / 时间序列预测

Time order must be preserved. Typical applications include budget execution, expenditure, inventory, demand, staffing, and server-load forecasts.

时间顺序必须保留。典型应用包括预算执行、支出、库存、需求、人员及服务器负载预测。

Model 模型Appropriate use 适用情况Conditions 条件
Naive/seasonal naive 朴素/季节朴素Mandatory baseline 必须建立的基线Persistence or seasonality exists 存在持续性或季节性
Exponential smoothing 指数平滑Level, trend, seasonal components 水平、趋势及季节成分Patterns are reasonably stable 模式相对稳定
ARIMA/SARIMALinear autocorrelation and seasonality 线性自相关及季节性Stationarity assumptions handled; residuals checked 处理平稳性并检查残差
ProphetInterpretable trend, multiple seasonalities, holidays 可解释趋势、多季节性及节假日Useful structure and enough history; must beat baselines 结构合适且历史足够;必须与基线比较
Gradient boosting 梯度提升Many external predictors and engineered lags 多个外部变量及滞后特征Leakage-free lag/rolling/calendar features 无泄漏的滞后、滚动及日历特征
LSTM/GRU/TransformersLarge multi-series or complex sequence settings 大规模多序列或复杂序列Enough independent sequences, compute, and careful backtesting 足够独立序列、算力及严格回测

Use walk-forward or rolling-origin validation. A random row split usually leaks temporal information. Every feature must be available at the actual forecast time. More complex deep models do not automatically beat seasonal baselines or boosted trees.

应使用Walk-forward或Rolling-origin验证。随机拆分行通常造成时间泄漏。所有特征必须在真实预测时点可获得。复杂深度模型不会自动优于季节基线或提升树。

3.5 Other supervised tasks / 其他监督任务

  • Survival analysis / 生存分析: predicts time to an event while handling censored observations; examples include equipment failure, attrition, and project delay. Models include Cox regression and random survival forests.
  • Structured prediction / 结构化预测: produces sequences or structured outputs, such as named entities, translations, speech transcripts, image segmentation, or document fields. Models include CRFs, transformers, and U-Net-style architectures.
  • Count modeling / 计数建模: predicts event counts with Poisson, negative-binomial, or related models when ordinary regression assumptions are unsuitable.

4. Unsupervised learning / 无监督学习

Unsupervised learning discovers structure without human-provided targets. Results generally require stronger domain interpretation because there is no definitive label-based accuracy score.

无监督学习在没有人工目标标签的情况下发现结构。由于不存在天然的标签准确率,结果通常更依赖领域解释。

4.1 Clustering / 聚类

Algorithm 算法Best fit 最适合情况Required conditions 关键条件Limitation 局限
K-meansRoughly compact, similar-scale clusters 近似紧凑且尺度相近的群组Numeric scaling; choose K; manage outliers 数值缩放;选择K;处理异常值Poor for irregular shapes, unequal density, categorical data 不适合不规则形状、密度差异或类别数据
Hierarchical clustering 层次聚类Smaller datasets and hierarchy 小型数据及层级关系Meaningful distance/linkage; scaling 合理距离和连接方法;缩放Expensive at large scale 大数据计算昂贵
DBSCANIrregular clusters with noise 含噪声的不规则群组Meaningful neighborhood radius; comparable density 合理邻域半径;密度较接近Difficult with varying density or high dimension 密度差异或高维数据困难
HDBSCANVariable-density structure and noise 密度变化及噪声Meaningful local density; sufficient samples 合理局部密度;样本足够More complex interpretation 解释较复杂
Gaussian mixture 高斯混合Overlapping probabilistic clusters 重叠的概率群组Distributional approximation and component selection 分布近似合理并选择成分数Sensitive to initialization and outliers 对初始化和异常值敏感
K-modes/K-prototypesCategorical or mixed data 类别型或混合数据Suitable dissimilarity and feature weighting 合理差异度与特征权重Requires cluster count and careful weighting 需要预设群数并谨慎加权

Silhouette, Davies–Bouldin, and Calinski–Harabasz scores assess geometric properties, not whether the clusters are real business segments. Validate stability, interpretability, reproducibility, and downstream usefulness.

Silhouette、Davies–Bouldin及Calinski–Harabasz衡量的是几何结构,不能证明群组是真实业务分群。还必须验证稳定性、可解释性、可重复性及下游价值。

4.2 Dimensionality reduction / 降维

Method 方法Use 用途Important caution 重要注意事项
PCALinear compression and decorrelation 线性压缩及去相关Scale when units differ; components may be hard to interpret 单位不同时需缩放;主成分解释较难
Truncated SVDSparse text matrices 稀疏文本矩阵Often used without centering 通常不中心化
t-SNELocal-neighborhood visualization 局部邻域可视化Distances and cluster sizes in the plot are not globally reliable 图中全局距离和群组大小不一定可靠
UMAPVisualization and nonlinear embeddings 可视化和非线性嵌入Results depend on neighbors, distance, and random seed 结果依赖邻居数、距离及随机种子
Autoencoder 自动编码器Nonlinear compression 非线性压缩Needs enough data and validation of representation usefulness 需要足够数据并验证表示是否有用

4.3 Anomaly detection / 异常检测

Anomaly detection is a task, not exclusively an unsupervised paradigm. It may be:

异常检测是一种任务,并不专属于无监督学习。它可以是:

  • supervised, when reliable anomaly labels exist;
  • semi-supervised or one-class, when mostly normal examples are available;
  • unsupervised, when labels do not exist.
Method 方法Suitable use 适用情况Requirement 要求
Z-score/IQRSimple univariate screening 简单单变量筛查Stable, understood distribution 稳定且可理解的分布
Isolation ForestTabular anomalies 表格异常Rare anomalies separable by random partition 异常稀少且易被随机分割隔离
One-Class SVMBoundary of normal cases 正常样本边界Scaled data and manageable size 缩放后的中小规模数据
Local Outlier FactorLocal-density anomalies 局部密度异常Meaningful neighborhoods 合理邻域定义
AutoencoderComplex images/sequences/patterns 复杂图像、序列及模式Abundant representative normal data 大量且有代表性的正常数据

An unusual record is not automatically fraud, error, or wrongdoing. The model flags deviation; investigation establishes meaning.

异常记录并不自动等于欺诈、错误或违规。模型只负责发现偏离,业务调查才能确定含义。

4.4 Association rules and topic discovery / 关联规则与主题发现

Association-rule methods such as Apriori and FP-Growth identify frequent co-occurrence. Key measures are support, confidence, and lift:

Apriori、FP-Growth等关联规则方法识别高频共现。关键指标包括支持度、置信度和提升度:

[ Support(A\rightarrow B)=P(A\cap B) ]

[ Confidence(A\rightarrow B)=P(B|A) ]

[ Lift(A\rightarrow B)=\frac{P(B|A)}{P(B)} ]

Association is not causation. High-confidence rules can simply reflect a very common item.

关联不等于因果。高置信度规则可能只是因为某项目本身非常常见。

Topic discovery methods include LDA, NMF, BERTopic, and embedding-plus-clustering pipelines. Good tokenization, sufficient documents, multilingual support, stable topics, and expert interpretation are required.

主题发现可采用LDA、NMF、BERTopic或“嵌入+聚类”。需要良好分词、足够文档、多语言支持、稳定主题及专家解释。


5. Semi-supervised and self-supervised learning / 半监督与自监督学习

Semi-supervised learning / 半监督学习

Use it when labels are expensive but unlabeled data are abundant and come from a distribution similar to deployment data. Methods include pseudo-labeling, self-training, label propagation, consistency regularization, FixMatch, and MixMatch.

当标签昂贵、无标签数据丰富且与部署数据分布相近时,可使用半监督学习。常用方法包括伪标签、自训练、标签传播、一致性正则化、FixMatch及MixMatch。

Success requires:

  1. A representative labeled seed set / 有代表性的初始标签集。
  2. A fully human-labeled holdout test set / 完全由人工标注的独立测试集。
  3. Confidence thresholds and class-balance checks / 置信度阈值与类别平衡检查。
  4. Monitoring for confirmation bias / 监控确认偏差。
  5. Similarity between unlabeled and deployment distributions / 无标签数据与部署数据分布相似。

Self-supervised learning / 自监督学习

Self-supervised learning creates targets from raw data: next-token prediction, masked-token reconstruction, contrastive learning, masked-image reconstruction, or speech-segment prediction. It powers much of modern LLM, vision, and speech pretraining.

自监督学习从原始数据自动构造训练目标,例如下一Token预测、遮挡Token重建、对比学习、遮挡图像重建或语音片段预测,是现代LLM、视觉及语音预训练的重要基础。

Effective pretraining requires broad, representative, cleaned data; a suitable objective; sufficient model capacity and compute; deduplication; and privacy, copyright, bias, and safety controls. The pretrained representation still needs task-specific evaluation and often prompting, retrieval, adapters, or fine-tuning.

有效预训练需要广泛、代表性强且经过清理的数据,合适的训练目标,足够的模型容量与算力,数据去重,以及隐私、版权、偏见和安全控制。预训练后仍需进行具体任务评估,并可能配合提示、检索、适配器或微调。


6. Reinforcement learning / 强化学习

Reinforcement learning learns a policy through interaction. It is most appropriate when actions affect future states and rewards—not merely when a labeled prediction is needed.

强化学习通过与环境交互学习策略。只有当行动会影响未来状态和奖励时才特别适合;如果只需要有标签预测,通常无需强化学习。

Core concepts are agent, environment, state, action, reward, policy, value, exploration, and exploitation. The objective is commonly a discounted return:

核心概念包括智能体、环境、状态、动作、奖励、策略、价值、探索和利用。目标通常是最大化折扣累计回报:

[ G_t=\sum_{k=0}^{\infty}\gamma^k r_{t+k+1} ]

Algorithm family 算法家族Appropriate scenario 适用场景
Multi-armed/contextual bandits 多臂/上下文老虎机Repeated selection with limited state effects 重复选择且行动对长期状态影响有限
Q-learning/SARSASmall discrete state-action spaces 小型离散状态—动作空间
DQNHigh-dimensional state, discrete actions 高维状态、离散动作
Policy gradients/Actor–CriticStochastic or continuous policies 随机或连续策略
PPOGeneral policy optimization, including some LLM post-training 通用策略优化及部分LLM后训练
SACContinuous control 连续控制
Model-based RLPlanning with a known or learned dynamics model 使用已知或学习到的动力学模型进行规划
Offline RLLearning from fixed historical trajectories 从固定历史轨迹学习

Effective RL needs a well-defined state/action/reward system, adequate exploration or representative offline coverage, safe experimentation or a realistic simulator, reliable reward attribution, and guardrails against reward hacking. In high-stakes domains, off-policy evaluation, uncertainty analysis, and human oversight are essential.

有效强化学习需要清晰定义状态、动作和奖励,需要充分探索或有代表性的离线覆盖,需要安全试验环境或逼真模拟器,并需要可靠的奖励归因及防止奖励投机。在高风险领域,还必须进行离线策略评估、不确定性分析及人工监督。


7. Transfer, active, online, federated, and graph learning / 迁移、主动、在线、联邦及图学习

Transfer learning / 迁移学习

  • Feature extraction / 特征提取: freeze a pretrained encoder and train a smaller task model.
  • Prompting / 提示: use existing model capability without changing weights.
  • RAG / 检索增强生成: retrieve current or internal knowledge without encoding all facts into weights.
  • LoRA/QLoRA: parameter-efficient adaptation.
  • Full fine-tuning / 全量微调: update most or all weights when enough data, compute, and justification exist.

If the problem is missing or changing knowledge, RAG is often preferable. If the problem is persistent behavior, format, terminology, or domain adaptation, fine-tuning may help. These approaches can be combined.

如果问题是缺少知识或知识经常变化,通常优先考虑RAG;如果问题是稳定的行为、格式、术语或领域适配,微调可能更有效。两者可以组合使用。

Active learning / 主动学习

The model selects samples whose labels would be most informative. Use uncertainty sampling, query-by-committee, diversity sampling, or core-set selection. It works only when an expert labeling loop exists. Uncertainty alone may repeatedly select noise, so representativeness and diversity are also needed.

模型选择最有信息价值的样本请求人工标注。可以采用不确定性采样、委员会查询、多样性采样或核心集选择。它要求存在专家标注闭环;仅选择最不确定样本可能不断抽到噪声,因此还需考虑代表性和多样性。

Online learning / 在线学习

Online models update as data arrive. They require delayed-label tracking, drift detection, versioning, rollback, poisoning defenses, and clear retraining rules. Not every production model needs continuous weight updates; periodic batch retraining is often safer.

在线模型随数据到达持续更新,需要跟踪延迟标签、检测漂移、管理版本与回滚、防止数据投毒并制定重训规则。并非所有生产模型都需要实时更新权重;定期批量重训通常更安全。

Federated learning / 联邦学习

Federated learning keeps raw data distributed while sharing model updates. It does not automatically guarantee privacy. Secure aggregation, differential privacy, identity/access control, participant trust, communication efficiency, and non-IID data handling may still be required.

联邦学习让原始数据保持分散,只共享模型更新,但它并不会自动保证隐私。仍可能需要安全聚合、差分隐私、身份与访问控制、参与方信任、通信效率及非独立同分布数据处理。

Graph machine learning / 图机器学习

Graph methods are useful when relationships carry information: supplier–contract–agency networks, transaction graphs, supply chains, recommendations, knowledge graphs, and cyberattack paths.

当关系本身包含重要信息时,应考虑图机器学习,例如供应商—合同—机构网络、交易网络、供应链、推荐、知识图谱及网络攻击路径。

Tasks include node classification, link prediction, community detection, graph classification, and knowledge-graph completion. Models include PageRank, Node2Vec, GraphSAGE, GCN, GAT, and graph transformers. Accurate entity resolution and leakage-safe temporal or structural splits are crucial.

任务包括节点分类、链接预测、社区发现、整图分类及知识图谱补全。模型包括PageRank、Node2Vec、GraphSAGE、GCN、GAT及图Transformer。准确的实体解析以及避免泄漏的时间或结构拆分非常关键。


8. Generative modeling / 生成式建模

Generative models learn aspects of a data distribution and generate text, code, images, audio, video, or synthetic records.

生成模型学习数据分布的某些特征,并生成文本、代码、图像、音频、视频或合成记录。

Family 家族Main uses 主要用途
Autoregressive transformers 自回归TransformerText, code, audio 文本、代码、音频
Variational autoencoders 变分自动编码器Latent representations and generation 潜在表示及生成
GANs 生成对抗网络Image and synthetic-data generation 图像及合成数据
Diffusion models 扩散模型High-quality image, video, and audio generation 高质量图像、视频及音频
Normalizing flows 归一化流Exact-density and scientific applications 精确密度与科学应用

Evaluation must be task-specific. Fluency or visual quality alone does not establish factuality, usefulness, safety, privacy, or absence of bias. For deployed generative systems, test task success, groundedness, hallucination rate, safety, latency, cost, and human acceptance.

评估必须针对具体任务。语言流畅或视觉质量高并不能证明事实准确、有用、安全、保护隐私或不存在偏见。生产生成系统还应测试任务成功率、依据性、幻觉率、安全性、延迟、成本及用户接受度。


9. Universal conditions for effective training / 有效训练的共同条件

9.1 Define the decision, not only the prediction / 定义决策,而不仅是预测

Clarify the prediction target, prediction time, user, downstream action, and costs of false positives and false negatives. A technically accurate model can still be useless if nobody can act on it.

必须明确预测目标、预测时间、使用者、后续行动以及误报和漏报成本。即使技术准确,如果无人能够据此行动,模型仍然没有价值。

9.2 Reliable labels / 可靠标签

Check label definitions, annotator agreement, missing labels, delayed outcomes, historical policy effects, and whether the label actually represents the business objective. Label noise often limits performance more than algorithm choice.

检查标签定义、标注者一致性、缺失标签、延迟结果、历史政策影响,以及标签是否真正代表业务目标。标签噪声对性能的限制往往大于算法选择。

9.3 Representative data / 代表性数据

Training data should cover the future population, periods, agencies, regions, classes, edge cases, and policy or market regimes. More data do not fix systematic sampling bias.

训练数据应覆盖未来人群、时间段、机构、地区、类别、边缘案例以及政策或市场环境。增加数据量无法修复系统性采样偏差。

9.4 Adequate sample size / 足够样本量

There is no universal sample-size rule. Requirements depend on dimensionality, noise, model capacity, effect size, class rarity, desired confidence, and use of pretrained representations. Learning curves and uncertainty intervals are more defensible than a fixed “samples per feature” rule.

不存在通用样本量规则。需求取决于维度、噪声、模型容量、效应大小、少数类稀有程度、置信要求及是否采用预训练表示。学习曲线和不确定性区间比固定的“每特征多少样本”规则更可靠。

9.5 Feature availability and leakage control / 特征可获得性与防止泄漏

Every feature must exist at prediction time. Leakage occurs when future outcomes, post-decision fields, duplicates, group identity, or preprocessing information crosses the train/test boundary.

所有特征必须在真实预测时点可获得。如果未来结果、决策后字段、重复记录、群组身份或预处理信息跨越训练/测试边界,就会发生数据泄漏。

9.6 Correct splitting / 正确数据拆分

Data structure 数据结构Appropriate split 合适拆分
Independent observations 独立样本Random, preferably stratified 随机拆分,最好分层
Time-dependent data 时间相关数据Chronological or rolling 按时间或滚动拆分
Repeated users/customers/patients 重复用户/客户/患者Grouped split 按实体分组拆分
Geographic or agency generalization 地区或机构泛化Hold out regions/agencies 保留地区或机构作为测试
Graph data 图数据Structural or temporal split 结构或时间拆分

Fit scalers, imputers, feature selection, resampling, and target encoding inside each training fold—not on the complete dataset.

缩放、缺失填补、特征选择、重采样和目标编码必须在每个训练折内部拟合,不能先在完整数据集上完成。

9.7 Imbalance and decision thresholds / 类别不平衡与决策阈值

Use class weights, appropriate sampling, focal loss, anomaly methods, or threshold adjustment where justified. SMOTE is not automatically beneficial and must be applied only inside training folds. Preserve realistic prevalence in validation/test data when estimating operational performance.

可以根据需要使用类别权重、适当采样、Focal Loss、异常检测或阈值调整。SMOTE并非自动有效,而且只能在训练折内部使用。验证集和测试集应尽量保持真实发生率,以估计实际表现。

9.8 Preprocessing appropriate to the algorithm / 与算法匹配的预处理

  • Scaling is important for SVM, KNN, PCA, regularized linear models, and neural networks.

  • Tree models usually do not require scaling.

  • Missingness may itself carry information, but handling must reflect deployment.

  • Categorical encoding must avoid target leakage.

  • Text, image, and audio augmentation must preserve the label.

  • SVM、KNN、PCA、正则化线性模型及神经网络通常需要缩放。

  • 树模型通常不需要缩放。

  • 缺失本身可能包含信息,但处理方式必须与部署一致。

  • 类别编码必须防止目标泄漏。

  • 文本、图像及音频增强不能改变真实标签。

9.9 Underfitting and overfitting / 欠拟合与过拟合

Underfitting means poor training and validation performance. Overfitting means training performance is much better than performance on unseen data. Control complexity through regularization, pruning, early stopping, data augmentation, feature reduction, more representative data, or a simpler model.

欠拟合表现为训练和验证性能都差;过拟合表现为训练性能远好于未见数据。可以通过正则化、剪枝、早停、数据增强、减少特征、增加代表性数据或使用更简单模型来控制复杂度。

9.10 Calibration and uncertainty / 校准与不确定性

Probability calibration asks whether events predicted at 70% occur about 70% of the time. Use reliability diagrams, expected calibration error, Brier score, Platt scaling, isotonic regression, or temperature scaling as appropriate. Also quantify uncertainty from limited data, model instability, and distribution shift.

概率校准检查“预测70%的事件是否大约70%会发生”。可以使用可靠性图、期望校准误差、Brier分数、Platt缩放、等距回归或温度缩放。同时还要量化小样本、模型不稳定及分布变化带来的不确定性。

9.11 Explainability, causality, and fairness / 可解释性、因果与公平性

Feature importance, SHAP, LIME, and partial-dependence plots explain model behavior, not causal effects. If the question is “What action will change the outcome?”, causal inference or experimentation may be required.

特征重要性、SHAP、LIME及部分依赖图解释的是模型行为,而不是因果效应。如果问题是“采取什么行动会改变结果”,可能需要因果推断或实验。

Fairness evaluation should compare relevant error rates, calibration, access, and downstream impact across legally and operationally meaningful groups. Fairness definitions can conflict, so the correct criterion depends on context and policy.

公平性评估应比较具有法律及业务意义群体之间的错误率、校准、机会获得及下游影响。不同公平标准可能冲突,因此必须结合具体环境和政策选择。

9.12 Deployment, drift, and feedback loops / 部署、漂移与反馈闭环

Monitor input quality, missingness, prediction distributions, latency, cost, real outcomes, subgroup performance, data drift, concept drift, and feedback effects. Define alert thresholds, ownership, retraining triggers, rollback plans, and model retirement criteria before deployment.

应监控输入质量、缺失情况、预测分布、延迟、成本、真实结果、群体表现、数据漂移、概念漂移及反馈效应。在部署前就应明确告警阈值、责任人、重训触发条件、回滚方案及模型退役标准。


10. Practical problem-to-model map / 实用的问题—模型映射

Question 问题Task 任务Strong starting point 推荐起点
Will it happen? 会不会发生?Binary classification 二分类Logistic regression, boosted trees 逻辑回归、提升树
Which category? 属于哪一类?Multiclass/multilabel classification 多分类/多标签Linear baseline, tree ensemble, pretrained model 线性基线、树集成、预训练模型
How much? 数值是多少?Regression 回归Linear baseline, random forest, boosting 线性基线、随机森林、提升树
What happens over time? 未来如何变化?Forecasting 预测Seasonal baseline, ETS/ARIMA, boosting 季节基线、ETS/ARIMA、提升树
What should come first? 谁应排在前面?Ranking 排序LambdaMART or task-specific ranking LambdaMART或专用排序模型
Which items are similar? 哪些对象相似?Clustering/representation 聚类/表示K-means, HDBSCAN, embeddings K-means、HDBSCAN、嵌入
What is unusual? 哪些不正常?Anomaly detection 异常检测Rules plus Isolation Forest or supervised model 规则结合Isolation Forest或监督模型
What usually occurs together? 哪些经常共同出现?Association rules 关联规则FP-Growth, Apriori
What action maximizes long-term reward? 什么行动使长期收益最大?Reinforcement learning 强化学习Bandit, offline RL, or policy optimization 组合老虎机、离线RL或策略优化
Relationships drive the outcome? 关系是否决定结果?Graph learning 图学习Graph features first, then GNN if justified 先使用图特征,再视需要采用GNN
Need new text/image/audio/code? 需要生成内容?Generative modeling 生成建模Pretrained transformer or diffusion model 预训练Transformer或扩散模型

11. Recommended modeling sequence / 推荐建模顺序

  1. Define the decision and error costs. / 定义决策及错误成本。
  2. Audit labels, sampling, timing, and leakage. / 审查标签、抽样、时间及泄漏。
  3. Build a naive baseline. / 建立朴素基线。
  4. Train a simple interpretable model. / 训练简单且可解释的模型。
  5. Add a strong task-appropriate model. / 增加适合任务的强模型。
  6. Use cross-validation or backtesting that matches deployment. / 使用与部署环境一致的交叉验证或回测。
  7. Compare accuracy, calibration, stability, fairness, latency, and cost. / 比较准确性、校准、稳定性、公平性、延迟及成本。
  8. Pilot inside the real workflow. / 在真实工作流程中试点。
  9. Monitor outcomes and feedback loops. / 监控真实结果及反馈闭环。
  10. Retrain, revise, or retire under predefined rules. / 按预定规则重训、修订或退役。

For most contract, financial, operational, and government tabular problems, begin with logistic/linear regression and boosted trees. Deep learning becomes compelling when raw text, image, audio, graph, massive-scale, or representation-learning requirements justify the added complexity.

对于大多数合同、财务、运营及政府表格数据问题,应优先从逻辑/线性回归及提升树开始。当任务涉及原始文本、图像、音频、图结构、超大规模数据或表示学习时,深度学习的额外复杂性才更有价值。


12. Final validated takeaway / 最终复核结论

The original framework was fundamentally sound. The crucial refinements are:

原框架基本正确,关键修订如下:

  1. Learning paradigms, tasks, and algorithms are different layers. / 学习范式、任务和算法属于不同层次。
  2. Paradigms can overlap within one system lifecycle. / 一个系统生命周期可以同时采用多种范式。
  3. Anomaly detection is not exclusively unsupervised. / 异常检测并不专属于无监督学习。
  4. Time-series validation must preserve time. / 时间序列验证必须保持时间顺序。
  5. Clustering scores do not prove business truth. / 聚类指标不能证明业务分群真实。
  6. No universal sample-size rule exists. / 不存在通用样本量规则。
  7. Explainability does not establish causality. / 可解释性不等于因果性。
  8. Deployment quality depends as much on data, validation, workflow, and monitoring as on the algorithm. / 生产质量不仅取决于算法,也同样取决于数据、验证、工作流程及监控。

The practical formula is:

实用公式是:

[ Useful\ ML = Good\ Problem + Representative\ Data + Reliable\ Labels + Proper\ Validation + Operational\ Integration ]

[ 有效机器学习 = 正确问题 + 代表性数据 + 可靠标签 + 正确验证 + 业务流程集成 ]

Source: Machine_Learning_Bilingual_Validated_Guide.md

Learning map

🗺️ 机器学习系统化成长地图

🔹 第一阶段:核心认知解构

  • 区分模型层次:清晰界定「学习范式」(如监督/无监督)与「任务类型」(分类/回归/聚类),避免概念混淆。
  • 定义决策而非仅预测:明确业务决策目标、错误成本及真实使用场景,使技术投入与业务价值对齐。

🔹 第二阶段:数据工程与验证规范

  • 严格的数据审计:检查标签质量与系统采样偏差,确认是否有充足的样本来支撑模型复杂度需求。
  • 防泄漏与正确拆分:根据数据结构(时序、分组或独立样本)执行防泄漏拆分,确保所有特征在预测时间点上可获取。

🔹 第三阶段:算法选型与建模策略

  • 表格数据路线:优先从逻辑回归/线性模型建立基线,随后采用梯度提升树(XGBoost/LightGBM)捕捉非线性关系。
  • 高维与非结构化数据:在具备足够算力和数据的前提下,结合预训练模型、RAG或深度神经网络处理文本与图像。

🔹 第四阶段:评估指标与生产化闭环

  • 多维业务评估:超越单一的准确率,引入 F1-score、AUC 及概率校准等综合考量模型在实际部署中的表现。
  • 持续监控与迭代:设定明确的漂移监测阈值与重训机制(如定期批量重训或在线学习),保障长期鲁棒性。

Get hands-on — step by step

  1. 明确业务定义与目标:清晰表述需要通过模型解决的实际决策问题,并量化误报和漏报带来的具体经济或业务成本。
  2. 检查数据特征与环境:审查标签的一致性与真实分布;识别数据中的泄漏源及缺失值模式,确认训练样本是否足以覆盖所有边缘案例。
  3. 执行防御性数据拆分:根据时间序列、分组实体等数据结构建立防泄漏的训练/测试集,并在训练折内完成所有缩放与编码预处理。
  4. 从零构建基线模型:使用逻辑回归或简单的决策树快速跑通流程,验证特征是否具备基本的预测力并作为后续评估的客观基准。
  5. 迭代复杂模型与调参:根据任务类型(如结构化数据用 Tree Ensembles、文本用 Transformer)提升模型复杂度,并严格控制正则化以防止过拟合。
  6. 结合业务多维评估与试点:使用合适的指标检验校准度,并在内部小范围工作流中测试延迟与实际可用性。

Top 3 sources

  1. 1
    Hands-On Machine Learning with Scikit-Learn, Keras & TensorFlow

    涵盖从基础算法原理到实战部署的全面指南,提供了大量基于现实世界的代码实践与防避坑经验。

    https://github.com/ageron/handson-ml2

  2. 2
    Google ML Crash Course

    Google 官方提供的机器学习速成课,用直观的图表和简明语言清晰解释了各种范式与算法的核心概念。

    https://developers.google.com/machine-learning/crash-course

  3. 3
    Practical Deep Learning for Coders (fast.ai)

    旨在以实战优先的方式快速建立深度学习直觉,非常适合理解模型选择与生产环境中如何正确落地。

    https://github.com/fastai/fastbook

Links are AI-suggested — worth a quick sanity check before diving in.