Decision Trees: Entropy, Information Gain and Gini, With Python and C++
Grow a CART decision tree in Python, see Gini and entropy disagree, choose the depth honestly and run the trained tree in C++ at 16 ns per row.
These tutorials teach machine learning and artificial intelligence algorithms the way MYCPLUS teaches sorting and data structures: the idea first, then the math, then code you can run. Each algorithm is implemented from scratch in Python, checked against a standard library such as scikit-learn or PyTorch, and tested on a real dataset. The code and tests are in the MYCPLUS Python examples repository on GitHub, and how we test machine learning code explains the seeds, splits and baselines behind every result.
Start here: What Is Machine Learning? explains supervised, unsupervised and reinforcement learning and trains a first model end to end. New to Python for data work? Set up first with Python for machine learning, then NumPy and pandas.
Minimax and alpha-beta pruning and other search algorithms are in the algorithms section, with code in C, C++, Java and Python. For running trained models from C++, see machine learning with C++.
Grow a CART decision tree in Python, see Gini and entropy disagree, choose the depth honestly and run the trained tree in C++ at 16 ns per row.
Build k-nearest neighbors in Python and C++, see why one unscaled feature ruins it, choose k honestly and compare five implementations for speed.
Build logistic regression two ways in NumPy, match scikit-learn, pick a decision threshold properly and see why separable data needs regularization.
Derive linear regression, build it in NumPy two ways, match scikit-learn to 1e-13 and see why gradient descent needs scaled features, with data.