Robot AI -- AI Algorithms

Memory tricks that make search, optimization and classic AI click

From A-star search to genetic algorithms -- these memory tricks lock in the classical AI algorithms, optimization methods, and ensemble techniques that power modern AI systems.

Community
📋
AI Algorithms Forum
Ask questions · Share tricks
💬
AI Algorithms Study Room
Live · Study together now

Or continue to the sub-topics below for more specialized Study Rooms and Forums

AI Algorithms

Memory Tricks

Proven Mnemonics & Acronyms — fast to learn, hard to forget.

🎥 How Flashcards Work
A quick walkthrough of tap-to-flip, rating, and how card colors track what you're struggling with.
← Back Next →
Algorithms deck1 of 20
Tap to flip
← →
How well do YOU think you know this?
Easy Medium Hard Harder
Tap to flip back
Algorithms deck
Easy0
Medium0
Hard0
Harder0
Search Algorithms
A* = g(n) + h(n) -- actual cost PLUS heuristic estimate to goal
BFS AND DFS AND UNIFORM COST AND A-STAR
A-star is optimal if the heuristic is admissible -- never overestimates the true cost
BFS (queue, level-by-level): complete and optimal for unweighted graphs. DFS (stack, goes deep first): memory efficient but not optimal. Uniform Cost Search: optimal for weighted graphs. A* Search: f(n) = g(n) + h(n). g(n) = actual cost from start. h(n) = heuristic estimate to goal. Optimal if heuristic is admissible (never overestimates). Used in GPS navigation and game pathfinding.
BFS
Queue (FIFO), level-by-level, complete, optimal for unweighted
DFS
Stack (LIFO), memory efficient, NOT optimal
A* f(n)=g(n)+h(n)
Optimal if heuristic admissible (never overestimates)
Admissible examples
Straight-line distance, misplaced tiles in 8-puzzle
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Search Algorithms
A* search — what is f(n), and when is it optimal?
Tap to flip
🃏 Answer
A* = g(n) + h(n) -- actual cost PLUS heuristic estimate to goal
BFSQueue (FIFO), level-by-level, complete, optimal for unweighted
DFSStack (LIFO), memory efficient, NOT optimal
A* f(n)=g(n)+h(n)Optimal if heuristic admissible (never overestimates)
Admissible examplesStraight-line distance, misplaced tiles in 8-puzzle
Tap to flip back
Minimax
MINIMAX -- MAXimize your score, MINimize opponent score at alternating levels
ASSUMES OPTIMAL OPPONENT -- ALWAYS PLAN FOR WORST CASE
Alpha-beta pruning eliminates branches that cannot affect the final decision -- free speed
Minimax for two-player zero-sum games (chess, tic-tac-toe). MAX player (you) chooses action maximizing score. MIN player (opponent) minimizes your score. Alternate MAX and MIN levels. Alpha-Beta Pruning: prune branches where alpha is >= beta -- same result, dramatically fewer nodes. Reduces from O(b^d) to O(b^(d/2)) in best case. AlphaZero: minimax plus deep learning plus self-play -- beat world champions.
Minimax
Alternate MAX (your move) and MIN (opponent move) levels
Alpha-beta pruning
Prune when alpha >= beta -- same result, far fewer nodes
AlphaZero
Minimax + deep learning + self-play -- beat Go, chess, shogi
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Minimax
Minimax — how does it work, and what does alpha-beta pruning add?
Tap to flip
🃏 Answer
MINIMAX -- MAXimize your score, MINimize opponent score at alternating levels
MinimaxAlternate MAX (your move) and MIN (opponent move) levels
Alpha-beta pruningPrune when alpha >= beta -- same result, far fewer nodes
AlphaZeroMinimax + deep learning + self-play -- beat Go, chess, shogi
Tap to flip back
CSP
CSP = Variables, Domains, Constraints must all be satisfied simultaneously
SUDOKU AND MAP COLORING AND SCHEDULING ARE ALL CSPs
MRV heuristic -- assign the most constrained variable first -- fails early and saves time
Variables (cells, regions), Domains (digits 1-9, colors), Constraints (no repeats, adjacent regions differ). Backtracking: assign one variable at a time, backtrack when constraint violated. MRV (Minimum Remaining Values): assign most constrained variable first. AC-3 Arc Consistency: preprocessing that removes domain values with no compatible assignment.
Variables
What needs to be assigned (cells, regions, time slots)
Domains
Possible values for each variable
Constraints
Rules that must hold (no repeats, adjacency, order)
MRV heuristic
Assign most constrained variable first -- catches failures early
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 CSP
Constraint satisfaction (CSP) — the three parts, and the MRV heuristic?
Tap to flip
🃏 Answer
CSP = Variables, Domains, Constraints must all be satisfied simultaneously
VariablesWhat needs to be assigned (cells, regions, time slots)
DomainsPossible values for each variable
ConstraintsRules that must hold (no repeats, adjacency, order)
MRV heuristicAssign most constrained variable first -- catches failures early
Tap to flip back
Genetic Algorithms
SELECT, CROSS, MUTATE -- evolution as an optimization algorithm
POPULATION AND FITNESS AND SELECTION AND CROSSOVER AND MUTATION
Mutation maintains diversity -- without it the population converges to a local optimum
Population: candidate solutions. Fitness function: evaluate solution quality. Selection: fitter solutions more likely to reproduce. Crossover: combine two parents to produce offspring. Mutation: randomly alter part of a solution -- maintains diversity, avoids local optima. Repeat for many generations. Used when search space is huge or gradient is unavailable.
Population
Set of candidate solutions
Fitness function
Evaluates how good each solution is
Crossover
Combine parents -- offspring inherits from both
Mutation
Random change -- prevents convergence to local optima
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Genetic Algorithms
Genetic algorithms — the key steps?
Tap to flip
🃏 Answer
SELECT, CROSS, MUTATE -- evolution as an optimization algorithm
PopulationSet of candidate solutions
Fitness functionEvaluates how good each solution is
CrossoverCombine parents -- offspring inherits from both
MutationRandom change -- prevents convergence to local optima
Tap to flip back
Bayesian Networks
BAYES NET -- probabilistic graphical model where ARROWS MEAN CAUSES
DIRECTED ACYCLIC GRAPH WITH CONDITIONAL PROBABILITY TABLES
Given its parents, a node is conditionally independent of all non-descendants
Directed Acyclic Graph (DAG). Nodes = random variables. Edges = direct probabilistic influence (X to Y means X directly influences Y). Each node stores a Conditional Probability Table (CPT) given its parents. Applications: medical diagnosis, spam filtering, fault diagnosis. Inference: given evidence, compute probability of query variable. Inference is NP-hard in general.
Nodes
Random variables (symptoms, diseases, sensor readings)
Edges
X to Y means X directly influences Y
CPT
P(node|parents) -- conditional probability table at each node
Inference
Given evidence, compute P(query) -- NP-hard in general
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Bayesian Networks
Bayesian network — what do the nodes and arrows mean?
Tap to flip
🃏 Answer
BAYES NET -- probabilistic graphical model where ARROWS MEAN CAUSES
NodesRandom variables (symptoms, diseases, sensor readings)
EdgesX to Y means X directly influences Y
CPTP(node|parents) -- conditional probability table at each node
InferenceGiven evidence, compute P(query) -- NP-hard in general
Tap to flip back
Gradient Descent
GRADIENT DESCENT goes DOWNHILL -- like a ball rolling to the lowest point
BATCH AND SGD AND MINI-BATCH AND ADAM -- FOUR VARIANTS
Learning rate is the most critical hyperparameter -- too high diverges, too low is very slow
Batch GD: gradient on entire dataset -- stable, slow. SGD: gradient on one example -- fast, very noisy. Mini-batch (32-256 samples): standard in deep learning -- best of both worlds. Adam: adaptive per-parameter learning rate -- most popular optimizer, works with defaults (lr=0.001). Momentum: adds inertia, avoids oscillation, escapes saddle points.
Batch GD
Entire dataset per update -- stable but slow
SGD
One example per update -- fast, noisy, can escape local optima
Mini-batch (32-256)
Standard in deep learning -- best compromise
Adam
Adaptive per-parameter LR -- use by default, start lr=0.001
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Gradient Descent
Gradient descent — batch vs SGD vs mini-batch vs Adam?
Tap to flip
🃏 Answer
GRADIENT DESCENT goes DOWNHILL -- like a ball rolling to the lowest point
Batch GDEntire dataset per update -- stable but slow
SGDOne example per update -- fast, noisy, can escape local optima
Mini-batch (32-256)Standard in deep learning -- best compromise
AdamAdaptive per-parameter LR -- use by default, start lr=0.001
Tap to flip back
Ensemble Methods
BAG and BOOST -- Bagging = parallel, Boosting = sequential error correction
RANDOM FOREST (BAGGING) AND XGBOOST (BOOSTING) AND STACKING
Ensembles consistently outperform single models -- they win Kaggle competitions
Bagging: parallel independent models on random subsets, average predictions -- reduces variance. Random Forest = bagging of decision trees. Boosting: sequential, each model corrects previous errors -- reduces bias. XGBoost and LightGBM = gradient boosting. Stacking: meta-model learns to combine base model outputs. No Free Lunch: try ensembles before complex single models.
Bagging
Parallel, independent -- reduces variance (overfitting)
Boosting
Sequential, corrects prior errors -- reduces bias (underfitting)
Random Forest
Bagging of decision trees -- reliable off-the-shelf algorithm
XGBoost
Gradient boosting -- most powerful for tabular data
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Ensemble Methods
Bagging vs boosting — how do they differ?
Tap to flip
🃏 Answer
BAG and BOOST -- Bagging = parallel, Boosting = sequential error correction
BaggingParallel, independent -- reduces variance (overfitting)
BoostingSequential, corrects prior errors -- reduces bias (underfitting)
Random ForestBagging of decision trees -- reliable off-the-shelf algorithm
XGBoostGradient boosting -- most powerful for tabular data
Tap to flip back
PCA
PCA finds the DIRECTIONS OF MAXIMUM VARIANCE in the data
REDUCE DIMENSIONS WHILE PRESERVING THE MOST IMPORTANT STRUCTURE
Always standardize data before PCA -- large-scale features will otherwise dominate
PCA finds orthogonal directions (principal components) of maximum variance. PC1: greatest variance direction. Project data onto top k components. Scree plot: variance explained vs k -- choose where curve elbows (~95% variance kept). Always standardize first. t-SNE and UMAP: nonlinear alternatives for visualization only.
PC1
Direction of greatest variance in the data
Scree plot
Variance explained vs k -- pick the elbow (~95% total)
Standardize first
Large-scale features dominate without standardization
t-SNE and UMAP
Nonlinear -- visualization only, not for feature extraction
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 PCA
PCA — what does it find, and how do you choose k?
Tap to flip
🃏 Answer
PCA finds the DIRECTIONS OF MAXIMUM VARIANCE in the data
PC1Direction of greatest variance in the data
Scree plotVariance explained vs k -- pick the elbow (~95% total)
Standardize firstLarge-scale features dominate without standardization
t-SNE and UMAPNonlinear -- visualization only, not for feature extraction
Tap to flip back
Monte Carlo
SAMPLE then AVERAGE -- Monte Carlo estimates by running many random simulations
LAW OF LARGE NUMBERS: RANDOM SAMPLE AVERAGE CONVERGES TO TRUE VALUE
Error decreases as 1 over sqrt(N) -- quadruple samples to halve the error
Run many random simulations, average results -- converges to true value as samples increase. Monte Carlo Tree Search (MCTS): simulate random game playouts from each position to guide search -- used in AlphaGo. MCMC (Markov Chain Monte Carlo): sample from complex probability distributions -- used in Bayesian inference.
Core idea
Many random samples, take average, converges to true value
MCTS
Game AI -- simulate playouts to estimate position value
MCMC
Sample from complex distributions -- Bayesian inference
Error rate
Decreases as 1/sqrt(N) -- 4x samples to halve error
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Monte Carlo
Monte Carlo methods — the core idea and uses?
Tap to flip
🃏 Answer
SAMPLE then AVERAGE -- Monte Carlo estimates by running many random simulations
Core ideaMany random samples, take average, converges to true value
MCTSGame AI -- simulate playouts to estimate position value
MCMCSample from complex distributions -- Bayesian inference
Error rateDecreases as 1/sqrt(N) -- 4x samples to halve error
Tap to flip back
Association Rules
SUPPORT, CONFIDENCE, LIFT -- the three metrics that make bread-to-butter meaningful
MARKET BASKET ANALYSIS -- ITEMS THAT FREQUENTLY APPEAR TOGETHER
Apriori uses anti-monotonicity -- if A,B is infrequent then A,B,C must also be infrequent
Support: how often do X and Y appear together? Confidence (A to B): P(B given A). Lift: is the relationship stronger than chance? Lift greater than 1 = positive association beyond chance. Apriori: uses anti-monotonicity to prune itemset search efficiently. Applications: recommendations, fraud detection, drug interactions.
Support
Frequency of itemset -- how common is the pair?
Confidence (A to B)
P(B|A) -- given A, how often is B also present?
Lift greater than 1
Items appear together more than expected by chance
Apriori
Prune by anti-monotonicity -- efficient frequent itemset mining
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Association Rules
Association rules — support, confidence, lift?
Tap to flip
🃏 Answer
SUPPORT, CONFIDENCE, LIFT -- the three metrics that make bread-to-butter meaningful
SupportFrequency of itemset -- how common is the pair?
Confidence (A to B)P(B|A) -- given A, how often is B also present?
Lift greater than 1Items appear together more than expected by chance
AprioriPrune by anti-monotonicity -- efficient frequent itemset mining
Tap to flip back
Dynamic Programming
DIVIDE into subproblems, STORE solutions, REUSE -- never solve the same subproblem twice
OPTIMAL SUBSTRUCTURE PLUS OVERLAPPING SUBPROBLEMS = USE DP
Viterbi algorithm uses DP for HMMs -- speech recognition and POS tagging both use it
DP solves complex problems by breaking into overlapping subproblems, solving each once, storing results (memoization). Two conditions: optimal substructure and overlapping subproblems. Top-down (memoization): recursive with caching. Bottom-up (tabulation): iterative. Viterbi algorithm: DP for finding most likely sequence in a Hidden Markov Model -- used in speech recognition and POS tagging.
Optimal substructure
Optimal solution contains optimal sub-solutions
Overlapping subproblems
Same subproblems solved repeatedly in naive recursion
Memoization
Store results -- top-down recursive approach
Viterbi
DP for HMM sequences -- speech recognition and POS tagging
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Dynamic Programming
Dynamic programming — the core idea, and Viterbi?
Tap to flip
🃏 Answer
DIVIDE into subproblems, STORE solutions, REUSE -- never solve the same subproblem twice
Optimal substructureOptimal solution contains optimal sub-solutions
Overlapping subproblemsSame subproblems solved repeatedly in naive recursion
MemoizationStore results -- top-down recursive approach
ViterbiDP for HMM sequences -- speech recognition and POS tagging
Tap to flip back
🎯 Exam Favorite
K-NN = Ask your K NEAREST NEIGHBORS and go with the majority vote
DEMOCRACY BY DISTANCE
K-Nearest Neighbors — the simplest classifier
K-NN is beautifully simple: to classify a new point, find the K training examples closest to it (by distance) and let them vote. Majority wins. K=1 means one nearest neighbor decides. K=5 means the 5 closest points vote. Large K = smoother boundary (less overfit). Small K = jagged boundary (more overfit). No training phase — just store all data and compute distances at prediction time. Lazy learning at its finest.
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🎯 Exam Favorite
K-NN
Tap to flip
🃏 Answer
K-NN = Ask your K NEAREST NEIGHBORS and go with the majority vote
DEMOCRACY BY DISTANCE
Tap to flip back
🧠 Vivid Story
SVM = Finding the WIDEST STREET between two neighborhoods
MAXIMUM MARGIN HYPERPLANE
Support Vector Machine — the widest street metaphor
SVM finds the boundary line (hyperplane) that separates two classes with the maximum margin — the widest possible street between the two neighborhoods. The data points closest to the boundary are called support vectors (the houses on the edge of the street). Wider street = more confident separation = better generalization. The kernel trick lets SVM handle data that can't be separated by a straight line by projecting it into higher dimensions.
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🧠 Vivid Story
SVM — what does it look for?
Tap to flip
🃏 Answer
SVM = Finding the WIDEST STREET between two neighborhoods
MAXIMUM MARGIN HYPERPLANE
Tap to flip back
🔑 Key Distinction
CLASSIFICATION predicts a CATEGORY — REGRESSION predicts a NUMBER
CAT OR NUMBER — THE FUNDAMENTAL OUTPUT TYPE
Classification vs Regression — never confuse them again
The output type determines which algorithm you need. Classification: output is a discrete category — spam/not spam, cat/dog, disease/healthy. Regression: output is a continuous number — house price, temperature tomorrow, patient age. Same input data, completely different question. Logistic regression (confusingly named) is a classifier. Linear regression predicts numbers. Always ask: am I predicting a category or a value?
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🔑 Key Distinction
Classification vs regression — what does each predict?
Tap to flip
🃏 Answer
CLASSIFICATION predicts a CATEGORY — REGRESSION predicts a NUMBER
CAT OR NUMBER — THE FUNDAMENTAL OUTPUT TYPE
Tap to flip back
💡 Concept Anchor
DECISION TREE = Playing 20 QUESTIONS — each question splits the possibilities
ASK · SPLIT · REPEAT UNTIL PURE
Decision trees — the 20 questions algorithm
A decision tree asks a series of yes/no questions about features, splitting the data at each step. Each split is chosen to maximize information gain — making the resulting groups as pure as possible. Terminal nodes (leaves) contain the final prediction. It's exactly like 20 Questions: "Is it alive? Does it have legs? Does it bark?" The tree stops when leaves are pure or a depth limit is reached. Interpretable but prone to overfitting without pruning.
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 💡 Concept Anchor
Decision tree — how does it decide?
Tap to flip
🃏 Answer
DECISION TREE = Playing 20 QUESTIONS — each question splits the possibilities
ASK · SPLIT · REPEAT UNTIL PURE
Tap to flip back
📅 Quick Reference
K-MEANS = Assign to nearest CENTROID, move centroid, repeat until stable
THREE STEPS: ASSIGN · UPDATE · CONVERGE
K-means clustering — the three-step dance
K-means finds K clusters in unlabeled data: Step 1 — randomly place K centroids. Step 2 — assign every point to its nearest centroid. Step 3 — move each centroid to the average position of its assigned points. Repeat steps 2–3 until centroids stop moving. The algorithm converges to stable clusters. You must choose K in advance (a weakness). Great for customer segmentation, document grouping, and image compression.
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 📅 Quick Reference
K-means — the steps?
Tap to flip
🃏 Answer
K-MEANS = Assign to nearest CENTROID, move centroid, repeat until stable
THREE STEPS: ASSIGN · UPDATE · CONVERGE
Tap to flip back
⭐ Most Important
CHOOSE YOUR WEAPON — Classification, Regression, Clustering, or Dimensionality Reduction?
MATCH THE ALGORITHM TO THE TASK TYPE
The algorithm selection framework every student needs
Before choosing any algorithm, identify the task type. Classification: predict a discrete category (spam/not spam). Regression: predict a continuous number (house price). Clustering: group unlabeled data by similarity (K-means). Dimensionality Reduction: compress features while keeping structure (PCA). Getting this wrong means applying the wrong family of algorithms entirely. Always ask: What type of output do I need?
Classification
Discrete output — logistic regression, decision tree, SVM, K-NN, random forest
Regression
Continuous output — linear regression, ridge, lasso, gradient boosting
Clustering
Group unlabeled data — K-means, DBSCAN, hierarchical clustering
Dim reduction
Compress features — PCA, t-SNE, UMAP
🐍 Code
from sklearn.linear_model import LogisticRegression, LinearRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
# Pick based on task type — not familiarity
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 ⭐ Most Important
Choosing an algorithm — the four task families?
Tap to flip
🃏 Answer
CHOOSE YOUR WEAPON — Classification, Regression, Clustering, or Dimensionality Reduction?
ClassificationDiscrete output — logistic regression, decision tree, SVM, K-NN, random forest
RegressionContinuous output — linear regression, ridge, lasso, gradient boosting
ClusteringGroup unlabeled data — K-means, DBSCAN, hierarchical clustering
Dim reductionCompress features — PCA, t-SNE, UMAP
🐍 Codefrom sklearn.linear_model import LogisticRegression, LinearRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
# Pick based on task type — not familiarity
Tap to flip back
🎯 Exam Favorite
PCA = Find the AXES OF MAXIMUM SPREAD and project data onto them
PRINCIPAL COMPONENT ANALYSIS — COMPRESS WITHOUT LOSING SHAPE
PCA for dimensionality reduction — the exam staple
PCA finds the directions (principal components) along which the data varies the most, then projects the data onto those axes. PC1 captures the most variance, PC2 the next most (perpendicular to PC1), and so on. You then keep only the top K components, discarding the rest. Use case: 500 features → 10 principal components that capture 95% of variance. Speeds up training, reduces overfitting, enables visualization in 2D/3D.
PC1
Direction of maximum variance in the data
PC2
Direction of second-most variance, perpendicular to PC1
n_components
How many PCs to keep — choose by explained variance ratio
🐍 Code
from sklearn.decomposition import PCA
pca = PCA(n_components=0.95) # keep 95% of variance
X_reduced = pca.fit_transform(X_scaled)
print(pca.explained_variance_ratio_) # variance per component
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🎯 Exam Favorite
PCA — what are PC1 and PC2?
Tap to flip
🃏 Answer
PCA = Find the AXES OF MAXIMUM SPREAD and project data onto them
PC1Direction of maximum variance in the data
PC2Direction of second-most variance, perpendicular to PC1
n_componentsHow many PCs to keep — choose by explained variance ratio
🐍 Codefrom sklearn.decomposition import PCA
pca = PCA(n_components=0.95) # keep 95% of variance
X_reduced = pca.fit_transform(X_scaled)
print(pca.explained_variance_ratio_) # variance per component
Tap to flip back
🔑 Key Distinction
DBSCAN finds BLOBS OF ANY SHAPE — K-means only finds ROUND BLOBS
DENSITY-BASED vs CENTROID-BASED CLUSTERING
When to use DBSCAN instead of K-means
K-means assumes clusters are roughly spherical and requires you to specify K upfront. DBSCAN (Density-Based Spatial Clustering) finds clusters of any shape — it groups points that are densely packed and labels sparse outliers as noise. No need to specify K. Perfect for: geographic data (cities form irregular shapes), anomaly detection (outliers labeled automatically), real-world messy clusters. Weakness: sensitive to the epsilon (neighborhood radius) hyperparameter.
K-means
Round blobs, must specify K, no outlier detection
DBSCAN
Any shape, auto-detects K, automatically labels outliers
Use DBSCAN when
Clusters are irregular shapes, or you need outlier detection
🐍 Code
from sklearn.cluster import DBSCAN, KMeans
dbscan = DBSCAN(eps=0.5, min_samples=5)
labels = dbscan.fit_predict(X)
# labels == -1 means OUTLIER — automatically detected
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 🔑 Key Distinction
DBSCAN vs K-means — what can DBSCAN do that K-means can't?
Tap to flip
🃏 Answer
DBSCAN finds BLOBS OF ANY SHAPE — K-means only finds ROUND BLOBS
K-meansRound blobs, must specify K, no outlier detection
DBSCANAny shape, auto-detects K, automatically labels outliers
Use DBSCAN whenClusters are irregular shapes, or you need outlier detection
🐍 Codefrom sklearn.cluster import DBSCAN, KMeans
dbscan = DBSCAN(eps=0.5, min_samples=5)
labels = dbscan.fit_predict(X)
# labels == -1 means OUTLIER — automatically detected
Tap to flip back
💡 Concept Anchor
NAIVE BAYES = Fast, Simple, Surprisingly Powerful — especially for text
BAYES THEOREM APPLIED TO CLASSIFICATION
Why Naive Bayes works despite its naive assumption
Naive Bayes classifies by applying Bayes theorem, assuming all features are conditionally independent given the class. This assumption is almost never true — hence "naive." Yet it works remarkably well for text classification (spam filtering, sentiment analysis) because word frequencies are approximately independent. Training is instant — just count frequencies. Prediction is a few multiplications. Accuracy often rivals far more complex models on text data. Always try it as a baseline.
Assumption
All features independent given class — almost never true, often works anyway
Best for
Text classification — spam, sentiment, document categorization
Advantage
Extremely fast to train, works well with small data, handles high dimensions
🐍 Code
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer
vec = CountVectorizer()
X = vec.fit_transform(texts)
nb = MultinomialNB().fit(X, labels)
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 💡 Concept Anchor
Naive Bayes — the assumption, and what it's best for?
Tap to flip
🃏 Answer
NAIVE BAYES = Fast, Simple, Surprisingly Powerful — especially for text
AssumptionAll features independent given class — almost never true, often works anyway
Best forText classification — spam, sentiment, document categorization
AdvantageExtremely fast to train, works well with small data, handles high dimensions
🐍 Codefrom sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer
vec = CountVectorizer()
X = vec.fit_transform(texts)
nb = MultinomialNB().fit(X, labels)
Tap to flip back
🎓 Common Exam Questions
0
Correct
0
Wrong
0
Remaining
🔗 Related Sub-Subjects
📊 Machine Learning
The ML framework that all these algorithms fit into — supervised, unsupervised, training pipelines.
Machine Learning →
📈 Model Evaluation
How to know if your algorithm choice worked — precision, recall, cross-validation.
Model Evaluation →
🔬 Deep Learning
When classical algorithms are not enough — the neural network architectures that go further.
Deep Learning →