机器学习:中英双语指南 II
2026/8/3 20:43:12 · 更新于 2026/8/3 20:47:14
This comprehensive bilingual guide provides advanced machine learning best practices covering transfer, active, online, federated and graph learning with practical insights on effective training, model selection, and deployment considerations.
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 自回归Transformer | Text, 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 / 推荐建模顺序
- Define the decision and error costs. / 定义决策及错误成本。
- Audit labels, sampling, timing, and leakage. / 审查标签、抽样、时间及泄漏。
- Build a naive baseline. / 建立朴素基线。
- Train a simple interpretable model. / 训练简单且可解释的模型。
- Add a strong task-appropriate model. / 增加适合任务的强模型。
- Use cross-validation or backtesting that matches deployment. / 使用与部署环境一致的交叉验证或回测。
- Compare accuracy, calibration, stability, fairness, latency, and cost. / 比较准确性、校准、稳定性、公平性、延迟及成本。
- Pilot inside the real workflow. / 在真实工作流程中试点。
- Monitor outcomes and feedback loops. / 监控真实结果及反馈闭环。
- 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:
原框架基本正确,关键修订如下:
- Learning paradigms, tasks, and algorithms are different layers. / 学习范式、任务和算法属于不同层次。
- Paradigms can overlap within one system lifecycle. / 一个系统生命周期可以同时采用多种范式。
- Anomaly detection is not exclusively unsupervised. / 异常检测并不专属于无监督学习。
- Time-series validation must preserve time. / 时间序列验证必须保持时间顺序。
- Clustering scores do not prove business truth. / 聚类指标不能证明业务分群真实。
- No universal sample-size rule exists. / 不存在通用样本量规则。
- Explainability does not establish causality. / 可解释性不等于因果性。
- 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
学习地图
- Foundations
- Understand key ML paradigms: supervised/unsupervised/reinforcement learning
- Learn about data types (tabular, text, image audio, graphs)
- Learning Methods Deep Dive
- Transfer learning: Feature extraction, LoRA/QLoRA, RAG
- Active learning approaches and challenges
- Online/Federated/Gragh learning architectures
- Model Implementation Framework
- Universal training conditions (9 factors)
- Data preparation requirements
- Validation methods for different problem types
- Practical Application Process
- Problem-to-model mapping techniques
- Recommended modeling sequence
- Effective deployment and monitoring strategies
动手实践——分步指南
- Start by defining your specific decision task: 'What question are you trying to answer with machine learning?'
- Map this problem to the appropriate category using the practical problem-to-model guide (binary classification for "will it happen?"); regression for numerical prediction).
- Evaluate if your labels and data represent the real-world situation by checking for missingness, leakage risk, and business relevance.
- Begin with simple models like logistic regression or tree ensembles as baseline to establish reasonable performance expectations.
- Experiment with transfer learning approaches when you have limited labeled data: either use feature extraction from a pretrained model (option A) or apply parameter-efficient methods like LoRA (option B).
- Verify your model's accuracy, calibration, and fairness across different user groups before deployment.
三大推荐资源
- 1Scikit-learn Documentation
Comprehensive guide to machine learning in Python, covering the most popular ML algorithms with detailed examples and use cases.
https://scikit-learn.org/stable/user_guide.html
- 2TensorFlow Learning Resources
Official TensorFlow resources for implementing machine learning models including tutorials, guides, and code samples for various tasks from regression to generative modeling.
https://www.tensorflow.org/learn
- 3Dive into Deep Learning
Free open-source book covering deep learning with practical examples using MXNet, PyTorch, TensorFlow, and JAX frameworks.
https://d2l.ai/
链接由 AI 推荐——使用前建议快速核实。