Skip to content
MLG 013 Shallow Algos 2 episode artwork

Apr 9, 2017 55 min

MLG 013 Shallow Algos 2

from Machine Learning Guide

Support vector machines and naive Bayes are shallow learning algorithms for classification: an SVM draws the widest margin between classes, and naive Bayes applies Bayes' theorem to word counts. Also covers the kernel trick, conditional probability, choosing an algorithm and text classification. Links Notes and resources at ocdevel.com/mlg/13 Join the free MLG group: listen to my other AI shows, ask me questions, and talk with other listeners How to choose a machine learning algorithm Narrow by task: supervised or unsupervised, classification or regression. Narrow by data and limits: numeric or categorical features, missing values, number of examples, memory and time. scikit-learn's Choosing the right estimator flowchart asks these questions. Train the shortlist and keep whichever scores best on held-out data (MLG 015). Support vector machines (SVM) An SVM draws a decision boundary like logistic regression (MLG 007), but as wide as it can. That width is the margin, and the training points on its edges are the support vectors. A wide margin generalizes better; a soft margin (the C parameter) lets an outlier sit inside it rather than tilt the boundary. The kernel trick A plain SVM is linear. A kernel measures how similar two points are as if they had been mapped into more dimensions, where a flat boundary can separate them, without computing that mapping. Blue dots ringed by red dots can't be split by a line, but add each point's distance from the center as a dimension and a flat cut separates them. Common kernels are radial basis function (RBF, scikit-learn's default), polynomial and sigmoid. With an SVM you choose the kernel; a neural network learns the nonlinearity itself, at more cost in data, time and memory. Joint and conditional probability Joint probability, P(A and B): how often both happen. For independent events, like two coin flips, multiply: 0.5 × 0.5 = 0.25. Cloudy and rainy days are dependent, so their joint probability is the measured overlap. Conditional probability, P(B | A): the chance of B once you know A. P(rain | cloudy) = P(rain and cloudy) / P(cloudy) Bayes' theorem Conditional probabilities don't reverse: clouds given rain is far likelier than rain given clouds. Bayes' theorem converts one into the other: P(A | B) = P(B | A) × P(A) / P(B) Naive Bayes classifier For spam, drop stop words (the, is), count how often each word appears in spam and in legitimate email, and note how much email is spam. Bayes' theorem then gives a new email's P(spam | its words). The naive assumption treats the words as independent given the class, which keeps the math tractable but ignores grammar and word order: a bag of words. Naive Bayes is fast, light on memory, needs little data and tolerates missing values. Spam filtering is its classic use; weather forecasting runs on numerical models and, increasingly, machine learning ones such as Google DeepMind's GraphCast. MLG 019 applies naive Bayes to language. Naive Bayes vs deep learning for text classification Text classification moved from recurrent neural networks (MLG 022), which read text in order, to transformers (MLG 033). BERT-style models label an email in well under a second, so speed no longer rules deep learning out for spam. Naive Bayes still fits where data or compute is scarce. Where to learn SVMs and naive Bayes Andrew Ng's Machine Learning Specialization covers neither. His Stanford CS229 lectures (Autumn 2018) do: Lecture 5 for naive Bayes, 6 and 7 for SVMs and kernels. Machine Learning with R by Brett Lantz (4th edition, 2023), a chapter on each. The Great Courses' Mathematical Decision Making, Lecture 20 on Bayesian analysis. Khan Academy Statistics for Bayes' theorem. Next: MLG 014, on anomaly detection, recommenders and Markov chains.

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

MLG 013 Shallow Algos 2

0:00 55:25

No transcript yet.

Requests help us decide what to transcribe next.

Frequently asked questions

How long is this episode of Machine Learning Guide?

This episode is 55 minutes long.

When was this Machine Learning Guide episode published?

This episode was published on April 9, 2017.

Can I download this Machine Learning Guide episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.