datawhalechina/statistical-learning-method-solutions-manual: a chapter-by-chapter answer key for Li Hang's textbook, built in notebooks
机器学习方法习题解答,在线阅读地址:https://datawhalechina.github.io/statistical-learning-method-solutions-manual
At a glance
- What is it?
- This repository collects worked solutions to the exercises in Li Hang's Statistical Learning Methods and Machine Learning Methods, with Python code for the algorithms. It is an Alpha build, and the README says so. The judgement: useful as a study companion and as a source of small from-scratch implementations, not as a reference implementation.
- Who is it for?
- Adopt it if you are working through Li Hang's book and want a second opinion on the exercises, or if you want short from-scratch implementations of perceptron, kd-trees, AdaBoost, GMM or SVD to read alongside the derivations. Do not adopt it as a production library or as an authority on the textbook's correctness: the README labels the whole thing an Alpha internal build that may contain errors, and chapter 26 is still marked in progress.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 131 days ago.
- What is it written in?
- Mainly Jupyter Notebook, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The gap this fills: exercises with no published answers
Li Hang's Statistical Learning Methods and its successor Machine Learning Methods are standard entry points for Chinese-speaking machine learning students, and the exercises at the end of each chapter are where the material actually gets tested. The book does not ship a solutions manual. This project is an attempt to produce one, chapter by chapter, covering supervised learning (perceptron through conditional random fields), unsupervised learning (clustering, SVD, PCA, latent semantic analysis, PLSA, MCMC, LDA, PageRank) and deep learning (feedforward networks through GANs). The stated audience is three groups: beginners working through the book, engineers who want Python implementations of the algorithms, and people revising for exams or interviews. The README also lists prerequisites, and they are not trivial: partial derivatives, Lagrange multipliers, eigenvalues, SVD, Bayes' theorem, maximum likelihood. If that list reads as unfamiliar, the solutions will not help, because they assume it.
Notebooks first, markdown second: the actual authoring pipeline
The collaboration rules in the README describe a two-stage pipeline rather than a single source of truth. Solutions are written as Jupyter notebooks under notebook/notes, because the answers need code and execution output, then exported to markdown and copied over the corresponding chapter under docs. That docs tree is what VitePress serves at the online reading address. The consequence is worth stating plainly: the notebook is the working copy and the markdown is a derived artifact. If a fix lands in one and not the other, the published site and the runnable notebook disagree, and nothing in the described process reconciles them automatically. Alongside the notebooks there is a codes directory organised by chapter, holding standalone scripts rather than notebooks: perceptron.py for exercise 2.2, kd_tree_demo.py and my_kd_tree.py for chapter 3, my_decision_tree.py and my_least_squares_regression_tree.py for chapter 5, maxent_dfp.py for the DFP algorithm on the maximum entropy model, three_coin_EM.py and my_gmm.py for chapter 9, the three hidden Markov scripts (forward-backward, backward, Viterbi) for chapter 10, my_svd.py and outer_product_expansion.py for chapter 15, and so on. Several chapters deliberately ship two versions of the same exercise, one calling scikit-learn and one written from scratch, which is the most useful thing in the repository: it lets you compare your own derivation against a library call.
Getting the notebooks to run: uv, graphviz, PyTorch, VitePress
The README pins the environment to Python 3.12 or later and Node 18.20.4 or later, and uses uv rather than plain pip for dependency resolution. The sequence it gives is: install uv with pip install uv, optionally point it at a mirror with set UV_INDEX=https://mirrors.aliyun.com/pypi/simple, then run uv sync --python 3.12 --all-extras to install the Python dependencies. Decision tree visualisation needs graphviz installed separately, and the README links to an external blog post for that rather than documenting it, which is the first sign that the setup instructions assume a reader who can fill gaps. PyTorch is installed outside the sync, with a version pinned in the example: uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio torchviz --index https://download.pytorch.org/whl/cu118. That index URL is the CUDA 11.8 wheel channel, so copying it verbatim on a machine without a compatible GPU, or on Apple silicon, will not do what you want; the README tells you to pick the right build from the PyTorch site instead. You then start jupyter notebook for the notebooks, and npm run docs:dev for the VitePress site. Note the split: the Python side is managed by uv, the site by npm, and nothing described here unifies them into one command.
Coverage is uneven, and the repository says so
The progress table is the most honest thing in the README. Almost every listed chapter is marked complete, but chapter 26, sequence-to-sequence models, carries an in-progress marker. The gaps are more interesting than that. The table jumps from chapter 11 to chapter 14, then runs 14 through 21, then jumps again to 23 and continues to 28. Chapters 12, 13 and 22 are absent from the table entirely, and the README does not explain whether they are out of scope, unstarted, or simply missing from the listing. If you are working through the book linearly, that is a hole you will hit without warning. The table also names a lead author and a set of reviewers per chapter, which is the only quality signal the project publishes, and it is a social one rather than a technical one. There are no tests, no CI description, and no comparison of outputs against the textbook's expected answers.
The Alpha warning is not boilerplate
The README opens with a caution block stating that this is an early internal build, incomplete, and possibly containing errors, and asks readers to file issues. Treat that as the operating condition rather than a formality. Three failure modes follow from it. First, a solution can be mathematically wrong in a way that is hard to spot if you are learning the material, which is exactly the audience the project targets. Second, the notebook-to-markdown export means the site can lag the notebook, so a corrected solution may not be the one you read online. Third, the environment is pinned to specific versions (Python 3.12, torch 2.7.1, torchvision 0.22.1) and the README offers no guidance on what breaks if you deviate. This is not the tool for someone who wants a vetted reference. It is a study aid whose value depends on you checking the work, and the repository provides no mechanism to do that checking for you.
What it is not: a library, and not a replacement for the textbook
If you want a maintained implementation of these algorithms, the sensible alternative is scikit-learn for the classical methods and a framework such as PyTorch or TensorFlow for the neural ones. The difference in approach is structural, not a matter of quality. scikit-learn exposes stable estimators with a consistent fit and predict interface, versioned releases, and a test suite; this repository exposes per-exercise scripts named after the exercise they answer, with no API, no releases, and no compatibility promise. That naming is the point: my_kd_tree.py exists to show how a kd-tree is built, not to be imported. The repository partially acknowledges this by shipping both, for example a script that calls sklearn's DecisionTreeClassifier with C4.5 and a separate self-written C4.5 implementation for the same exercise, and an AdaBoost pair on the same pattern. The honest framing is that the from-scratch files are teaching artifacts and the sklearn files are the ones you would actually use. Choosing this repository over scikit-learn for anything beyond reading is a category error.
Licence and the cost of keeping it current
The repository metadata reports the licence as NOASSERTION, which means no standard licence could be identified from the repository contents. The README says nothing about licensing at all. Before you copy code from codes/ or the notebooks into your own work, or mirror the docs site, establish the actual terms from the repository itself by reading its LICENSE file if one exists; I cannot state them from the material available here, and this is not legal advice. On maintenance, the material supports only a limited reading. The last push is dated 2026-05-08, so the project is active, and the progress table shows chapter 26 still in progress, which implies ongoing work rather than a frozen snapshot. There are no releases, so there is no versioned artifact to pin against and no changelog to consult when a solution changes. The dependency pins in the README (Python 3.12, torch 2.7.1) will age, and because the notebooks are the source and the markdown is generated, an environment drift shows up as failing cells rather than as a broken build you would notice.
Editorial conclusion
Adopt it if you are working through Li Hang's book and want a second opinion on the exercises, or if you want short from-scratch implementations of perceptron, kd-trees, AdaBoost, GMM or SVD to read alongside the derivations. Do not adopt it as a production library or as an authority on the textbook's correctness: the README labels the whole thing an Alpha internal build that may contain errors, and chapter 26 is still marked in progress. Before relying on any chapter, open the corresponding notebook under notebook/notes or the matching docs page, run it under the pinned environment, and check the chapter against the 2022 first edition of the book, because the table lists a reviewer for every chapter and that review is the only quality signal the repository publishes.
Community notes