MLG 012 Shallow Algos 1
Shallow learning algorithms like k-nearest neighbors, k-means, Apriori, PCA and decision trees solve many problems with far less compute than deep learning. Also covers supervised, unsupervised and reinforcement learning, random forests, gradient boosting and where to learn them. Links Notes and resources at ocdevel.com/mlg/12 Join the free MLG group: listen to my other AI shows, ask me questions, and talk with other listeners Shallow learning vs deep learning Shallow learning is every algorithm that isn't a layered neural network. Deep learning (MLG 009) isn't a silver bullet, and a shallow algorithm that fits saves time and compute. Pedro Domingos's The Master Algorithm (MLG 004) follows the search for one algorithm to replace hundreds. This episode covers five; MLG 013 and MLG 014 cover more. Supervised, unsupervised and reinforcement learning Supervised: the data comes labeled, with the answer in the spreadsheet's last column. Classification predicts a class, regression a number. Reinforcement: the model gets a goal, rewards and penalties, and learns the rules by acting (MLG 029). Unsupervised: no labels. The model finds structure itself. K-nearest neighbors (KNN) KNN is supervised but doesn't train (instance-based learning): a new point gets the majority label of its k nearest stored rows, or their average for regression. k is the number of neighbors that vote; the classes come from the labels. MLG 032 covers distance metrics. K-means clustering In k-means you choose k, the number of clusters, and it learns where their centers (centroids) go: Drop k centroids (team captains) at random. Each point joins its nearest centroid. Each centroid moves to the middle of its points. Repeat until no point switches. The elbow method and silhouette scores help choose k (MLA 011). Association rules and the Apriori algorithm Market basket analysis (association rule learning) finds what goes together: marshmallows and graham crackers suggest chocolate. A rule needs support (the items often appear together) and confidence (those baskets usually include chocolate). Apriori (Agrawal and Srikant, 1994) uses the fact that every subset of a frequent itemset is frequent: it grows itemsets one item at a time from frequent ones and prunes any candidate with an infrequent subset. Principal component analysis (PCA) PCA reduces many features to a few, as a GPA stands in for grades and attendance. Its principal components are new axes, weighted combinations of the original features ordered by the variance they keep, and you keep the first few. They come from the covariance matrix's eigenvectors, and unlike regression there's no target. Decision trees A learned flowchart of if-else questions. Training picks the best-splitting question, then repeats on each branch: lives in the sea? → yes: fish; no: number of legs? → two: human, four: cat Classification trees predict classes, regression trees numbers. The classic algorithms are CART, ID3, C4.5 and C5.0; scikit-learn uses an optimized CART. A small tree can show why a loan was denied, and US law (Regulation B, under the Equal Credit Opportunity Act) requires lenders to give, or provide on request, the specific principal reasons for a denial. Random forests and gradient boosting A single deep tree tends to overfit (MLG 015). Random forest: many trees, each trained on a bootstrap sample of rows with random feature subsets at each split, then averaged or voted. Gradient boosting: shallow trees built in sequence, each fitting the previous trees' errors. XGBoost, LightGBM and CatBoost are the standard libraries. Tree ensembles still often beat deep learning on tabular data. Shallow learning resources Andrew Ng's Machine Learning Specialization on Coursera. Course 2 teaches decision trees and tree ensembles; Course 3, k-means and anomaly detection. Machine Learning with R by Brett Lantz (4th edition, 2023) covers what Ng skips: KNN, naive Bayes and Apriori, plus decision trees and k-means, in R. Jason Brownlee's A Tour of Machine Learning Algorithms. scikit-learn's Choosing the right estimator flowchart; scikit-learn is still the library for these algorithms. For later, two theory textbooks that teach why the recipes in MLG 008's cooking analogy work: The Elements of Statistical Learning (2nd edition, 2009), a free PDF from the authors. Christopher Bishop's Pattern Recognition and Machine Learning (2006), free from Microsoft Research. More in the resources.
Embed this episode
No transcript yet.