fengdu78/lihang-code
《统计学习方法》的代码实现
What is this?
fengdu78/lihang-code is a companion code repository for Li Hang's classic machine learning textbook Statistical Learning Methods (2nd edition). It provides Python implementations of the algorithms covered in each of the book's 22 chapters.
What does it do?
The repo contains one code file (or set of files) per chapter, demonstrating that chapter's algorithm in action. The coverage spans the full arc of classical machine learning:
- Supervised methods: perceptron, k-nearest neighbors, naive Bayes, decision trees, logistic regression, support vector machines, boosting, EM algorithm, hidden Markov models, conditional random fields
- Unsupervised methods: clustering, singular value decomposition (SVD), principal component analysis (PCA), latent semantic analysis, probabilistic latent semantic analysis, Markov chain Monte Carlo (MCMC), latent Dirichlet allocation (LDA), PageRank
The code is a curated and reorganized collection contributed by multiple people, assembled by the "Machine Learning Beginners" (机器学习初学者) WeChat account, with links to the original sources.
Why does it matter?
Li Hang's book is widely regarded as the entry point to machine learning in Chinese-speaking communities, and its content frequently appears in tech-company interview questions. Having working code alongside each chapter helps readers bridge the gap between the book's mathematical derivations and actual implementation — turning abstract formulas into runnable examples.
Who is it for?
Students and self-learners working through the textbook who want concrete code to experiment with, as well as anyone preparing for ML interviews who wants quick, runnable references for classical algorithms.
Caveats
This is a companion code collection, not a maintained software library. The README gives no information about dependencies, installation, or code quality, and since contributions come from many authors, style and rigor likely vary across chapters.
Related
- Project
- Project
- Project
- Project