Statistical-Learning-Method_Code README

The project's README from github.com/Dod-o/Statistical-Learning-Method_Code. As one markdown file: README.md.

【广告位-AI 工具推荐】学术研究必备 - GreatRouter 大模型 API 服务

正在用 大模型 做研究?论文写作、代码调试、数据分析都需要 AI 辅助?

GreatRouter 提供更实惠的 大模型 API 服务:

→ 立即试用


前言

力求每行代码都有注释,重要部分注明公式来源。具体会追求下方这样的代码,学习者可以照着公式看程序,让代码有据可查。

image

如果时间充沛的话,可能会试着给每一章写一篇博客。先放个博客链接吧:传送门。

注:其中Mnist数据集已转换为csv格式,由于体积为107M超过限制,改为压缩包形式。下载后务必先将Mnist文件内压缩包直接解压。

【Updates】

书籍出版:目前已与人民邮电出版社签订合同,未来将结合该repo整理出版机器学习实践相关书籍。同时会在book分支中对代码进行重构,欢迎在issue中提建议!同时issue中现有的问题也会考虑进去。(Feb 12 2022)

线下培训:女朋友计划近期开办ML/MLP/CV线下培训班,地点北上广深杭,目标各方向快速入门,正在筹备。这里帮她打个广告,可以添加微信15324951814(备注线下培训)。本人也会被拉过去义务评估课程质量。。。(Feb 12 2022)

无监督部分更新:部分无监督算法已更新!!! 该部分由Harold-Ran提供,在此感谢! 有其他算法补充的同学也欢迎添加我微信并pr!(Jan 27 2021)

实现

监督部分

第二章 感知机:

博客:统计学习方法|感知机原理剖析及实现
实现:perceptron/perceptron_dichotomy.py

第三章 K近邻:

博客:统计学习方法|K近邻原理剖析及实现
实现:KNN/KNN.py

第四章 朴素贝叶斯:

博客:统计学习方法|朴素贝叶斯原理剖析及实现
实现:NaiveBayes/NaiveBayes.py

第五章 决策树:

博客:统计学习方法|决策树原理剖析及实现
实现:DecisionTree/DecisionTree.py

第六章 逻辑斯蒂回归与最大熵模型:

博客:逻辑斯蒂回归:统计学习方法|逻辑斯蒂原理剖析及实现
博客:最大熵:统计学习方法|最大熵原理剖析及实现

实现:逻辑斯蒂回归:Logistic_and_maximum_entropy_models/logisticRegression.py
实现:最大熵:Logistic_and_maximum_entropy_models/maxEntropy.py

第七章 支持向量机:

博客:统计学习方法|支持向量机(SVM)原理剖析及实现
实现:SVM/SVM.py

第八章 提升方法:

实现:AdaBoost/AdaBoost.py

第九章 EM算法及其推广:

实现:EM/EM.py

第十章 隐马尔可夫模型:

实现:HMM/HMM.py

无监督部分

第十四章 聚类方法

实现:K-means_Clustering.py

实现:Hierachical_Clustering.py

第十六章 主成分分析

实现:PCA.py

第十七章 潜在语意分析

实现:LSA.py

第十八章 概率潜在语意分析

实现:PLSA.py

第二十章 潜在狄利克雷分配

实现:LDA.py

第二十一章 PageRank算法

实现:Page_Rank.py

许可 / License

本项目内容许可遵循Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)。

The content of this project itself is licensed under the Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

联系

欢迎pr,有疑问也可通过issue、微信或邮件联系。
此外如果有需要MSRA实习内推的同学,欢迎骚扰。
Wechat: lvtengchao(备注“blog-学校/单位-姓名”)
Email: [email protected]

项目历史

Star History Chart

Statistical-Learning-Method_Code (Dod-o/Statistical-Learning-Method_Code)

Searching Database…

What is this?A from-scratch Python implementation of every algorithm covered in Li Hang's book 'Statistical Learning Method' (统计学习方法), with heavily commented code that maps directly to the formulas in the book.
Is this a library I import, or standalone example scripts?It's a collection of standalone scripts, one folder per algorithm/chapter (e.g. SVM/SVM.py, HMM/HMM.py), not a packaged library you pip-install.
How do I run one of the algorithm implementations?Clone the repo and run the corresponding script directly with Python, for example python perceptron/perceptrondichotomy.py; each chapter's code lives in its own folder.
Do I need to do anything with the dataset before running the scripts?Yes — the included Mnist dataset is shipped as a compressed csv (because the uncompressed file is 107MB), so you must unzip the archive inside the Mnist folder before running scripts that use it.
Can I reuse this code commercially?No — the project content is licensed under CC BY-NC-SA 4.0, which is non-commercial, so you can share and adapt it but not sell or use it commercially.
Is this meant for production use or for learning?It's a learning companion to the book — each implementation favors clarity and formula traceability over performance, aimed at students studying classic statistical learning methods.
Which algorithms from the book are implemented?Supervised: Perceptron, KNN, Naive Bayes, Decision Tree, Logistic Regression, Maximum Entropy, SVM, AdaBoost, EM, and HMM. Unsupervised: K-means, Hierarchical Clustering, PCA, LSA, PLSA, LDA, and PageRank.
Is there more explanation than just code comments?Yes, the author wrote companion blog posts walking through the theory for most chapters (e.g. 'Statistical Learning Method | SVM principle analysis and implementation'), linked directly in the README.
Is this project still being actively developed?The author mentioned a book deal (with People's Posts and Telecommunications Press) and plans to refactor the code in a separate 'book' branch as of a Feb 2022 update, but updates have otherwise been sporadic.
Creator
Dod-o
Size
97.9 MB
Stars
11.6K
Updated
CommitNov 25
Age
7y
Commits · 90 Days