| title | Combinatorics - The Art of Counting | ||||||
|---|---|---|---|---|---|---|---|
| sidebar_label | Combinatorics | ||||||
| description | Mastering permutations, combinations, and counting principles essential for understanding probability, feature engineering, and model complexity. | ||||||
| tags |
|
Combinatorics is the study of counting, arrangement, and combination of elements within sets. In Machine Learning, we use combinatorics to estimate the size of a hypothesis space, calculate probabilities, and understand the complexity of feature interactions.
Before diving into complex formulas, we must understand the two basic rules that govern all counting.
If one task can be performed in
ML Example: If you have 3 types of optimizers and 4 different learning rates to test, you have
If one task can be performed in
The factorial of a non-negative integer
The most important distinction in combinatorics is whether the order of selection matters.
A permutation is an arrangement of items where the sequence is important. The number of ways to choose
Example: Selecting a "First Place" and "Second Place" winner from a group of 10.
A combination is a selection of items where the sequence is irrelevant. The number of ways to choose
ML Example (Feature Selection): If you have 10 available features and you want to select a subset of 3 to train your model, there are
When performing a Grid Search, the number of models you need to train is the product of the number of values for each hyperparameter. If you have 5 hyperparameters with 10 values each, you are searching a space of
In Random Forests, we often select a random subset of features for each split in a tree. Combinatorics allows us to calculate how many unique trees can be generated from a given feature set.
When calculating the Confusion Matrix (Precision, Recall), we are essentially counting occurrences of discrete events (True Positives, False Positives), which is rooted in combinatorial counting.
The more "complex" a model is, the larger its Hypothesis Space (the set of all possible functions it can learn). Combinatorics helps quantify this space. If a decision tree has many possible splits, the number of possible tree structures grows factorially, increasing the risk of overfitting.
The combination formula
With the ability to count possibilities, we can now move to Graph Theory to see how these discrete elements can be connected to form complex networks.