Classical MLbeginnermust-know4 min

Bias–Variance Tradeoff

How to fix a model that makes bad predictions using simple error tuning.

When a machine learning model makes mistakes, the errors come from three main sources. First, bias happens when a model is too simple and misses the real pattern completely. Second, variance happens when a model is too complex and memorizes random noise instead of learning general patterns. Third, irreducible noise comes from unavoidable random mistakes in the data itself. Finding the right balance means tweaking model size until predictions are accurate on new data.

Classical MLbeginnermust-know3 min

Overfitting vs Underfitting

Everyone can define it. Fewer can diagnose it from a learning curve.

Overfitting is learning the training set's noise as if it were signal — training error keeps dropping while validation error rises. Underfitting is failing to learn the signal at all — both errors stay high and close together. Detect it by tracking both curves as a function of training set size and epochs. Fix overfitting with more data, regularization, augmentation and early stopping; fix underfitting with capacity, features and longer training.

Classical MLbeginnermust-know4 min

Linear Regression

Simple on paper, brutal in interviews. Most candidates stumble on the assumptions.

Linear Regression models continuous targets as y = Xβ + ε. Ordinary Least Squares (OLS) minimizes squared residuals, yielding the closed-form solution β = (XᵀX)⁻¹Xᵀy. Under the Gauss-Markov assumptions, OLS is the Best Linear Unbiased Estimator (BLUE). Key interview topics include closed-form derivation, assumption validation, multicollinearity, and OLS vs Gradient Descent trade-offs.

Classical MLbeginnermust-know4 min

Logistic Regression

The baseline classifier every ML candidate is expected to derive on a whiteboard.

Logistic regression predicts the probability that something belongs to a class, like whether an email is spam. It adds up the features with weights, just like linear regression, then squashes the result through an S-shaped curve so the output always lands between 0 and 1. It is trained with log loss, which punishes confident wrong answers heavily. The weights are easy to read, since each one says how much a feature raises or lowers the odds. Despite its name, it is used for classification.

Classical MLbeginnermust-know5 min

Cross-Validation Done Right

Why one train-test split is luck, and how k-fold fixes it.

Cross Validation evaluates how a machine learning model generalizes to unseen test data by partitioning training datasets into multiple validation splits. Standard K-Fold splits data into K equal folds. Stratified K-Fold preserves class label proportions across folds, essential for imbalanced classification. Group K-Fold prevents data leakage by ensuring all samples from a specific subject or user stay in the same fold. Time Series Split respects temporal causality, using past data to predict future time steps.

Classical MLintermediatemust-know5 min

L1 vs L2 Regularization

Two penalties that stop overfitting, and only one of them deletes features.

Both stop a model from overfitting by adding a penalty for large weights to the loss. L1, also called Lasso, penalises the sum of the absolute weights. That pushes unhelpful weights all the way to zero, so it quietly removes useless features for you. L2, also called Ridge, penalises the sum of the squared weights. That shrinks every weight smoothly but almost never to zero, and it copes better when features are closely related. Use L1 to pick features, and L2 to calm everything down.

Classical MLintermediatemust-know4 min

Gradient Descent & Its Variants

Whole dataset, one example, or a small batch per step, and why batches won.

Gradient descent trains a model by repeatedly nudging its weights downhill on the loss. The variants differ in how much data they look at per nudge. Batch gradient descent uses the whole dataset each time, which is accurate but slow. Stochastic gradient descent uses a single example each time, which is fast but jumpy. Mini-batch, using around 32 to 256 examples per step, is what everyone actually uses. It fits GPUs well, and its slight noise even helps the model escape poor spots.

Classical MLintermediatemust-know5 min

Bagging vs Boosting

Bagging fixes a model that is too complex. Boosting fixes one that is too simple.

Bagging and Boosting are the two dominant ensemble learning paradigms in machine learning. Bagging (Bootstrap Aggregating) trains independent complex base models in parallel on random data subsets to reduce variance (Random Forest). Boosting trains simple weak base models sequentially, focusing each new model on errors made by previous models to reduce bias (AdaBoost, XGBoost).

Classical MLintermediatemust-know5 min

Principal Component Analysis

Fewer features, most of the information kept. The classic way to shrink data.

PCA reduces the number of features while keeping as much information as possible. It finds the directions along which your data varies the most, and rotates the data to line up with them. The first direction captures the most spread, the second the next most, and so on, each at right angles to the rest. Keep the top few and drop the others, and you have fewer features that still describe the data well. Always scale your features first, or the largest-unit feature dominates.

Classical MLintermediatemust-know5 min

Handling Imbalanced Datasets

When 99 percent of your data is one class, accuracy stops meaning anything.

Class Imbalance occurs when majority classes dominate minority target classes (e.g. 99.9% non-fraud vs 0.1% fraud). Standard models achieve 99.9% dummy accuracy by predicting majority class everywhere while completely missing minority events. Solutions include Resampling (Random Undersampling, SMOTE oversampling), Cost Sensitive Learning (class weighting, Focal Loss), and evaluating via PR-AUC and F1-Score rather than raw Accuracy.

Classical MLadvancedmust-know5 min

Gradient Boosting (XGBoost/LightGBM)

Each new tree fixes the last one's mistakes. It wins most tabular competitions.

Gradient boosting builds decision trees one after another, where each new tree tries to fix the mistakes the earlier trees are still making. Instead of reweighting examples like AdaBoost, each tree is trained directly on the leftover errors. A learning rate scales down every tree's contribution, so the model improves in small, careful steps. Tuned well, it is usually the most accurate method on tabular data. XGBoost, LightGBM and CatBoost are the popular versions, and they win most tabular competitions.

Classical MLbeginner4 min

Supervised, Unsupervised & Self-Supervised

Learning with answers, without answers, and from the data itself.

Supervised Learning trains models on labeled input-output pairs (X, Y) for classification and regression. Unsupervised Learning finds inherent structural patterns, clusters, or lower-dimensional representations in unlabeled data (X). Self-Supervised Learning bridges the gap by automatically generating pseudo-labels from raw data structure (e.g. Next-Token Prediction, Masked Autoencoders), serving as the foundational engine for modern Foundation Models and LLMs.

Classical MLbeginner5 min

Decision Trees

A model that predicts by asking a series of yes-or-no questions.

A decision tree predicts by asking a series of yes-or-no questions, like is income above 50,000, then is age below 30. At each step it picks the question that best separates the classes, judged by how mixed each group is after the split. Trees handle curved patterns and mixed data types, need no feature scaling, and are easy to explain. Their weakness is overfitting: left to grow, a tree memorises the training data, so you limit its depth or prune it back.

Classical MLbeginner4 min

k-Nearest Neighbours

A model that does no training at all and just asks the nearest neighbours.

K-nearest neighbours does no real training at all. It simply stores every training example. To make a prediction, it finds the k examples closest to the new one, then takes a majority vote for classification or an average for regression. It is easy to understand and copes with odd-shaped boundaries. The downsides are speed and scale: every prediction compares against the whole dataset, distances need features on the same scale, and with many features distances stop being meaningful.

Classical MLbeginner4 min

Naive Bayes

A fast classifier built on an assumption that is almost always wrong, and still works.

Naive Bayes classifies by asking which class makes the observed features most likely, using Bayes' theorem. It is called naive because it assumes every feature is independent of the others once you know the class, which is almost never true. That shortcut makes it extremely fast and able to learn from very little data, and its rankings are often right even when its probabilities are off. It works well for text, like spam filtering. Smoothing stops one unseen word from forcing a probability to zero.

Classical MLbeginner5 min

k-Means Clustering

Grouping unlabelled data into k clusters by moving centres back and forth.

K-means groups data into k clusters without any labels. It places k centre points, assigns every point to its nearest centre, then moves each centre to the middle of the points assigned to it, repeating until nothing changes. It is fast and simple, but you must choose k yourself, a bad starting position can give a poor result, which the k-means++ starting method largely fixes, and it assumes clusters are roughly round and similar in size.

Classical MLbeginner4 min

Missing Data & Imputation

Why the reason data is missing decides how you should fill it.

Missing data degrades model quality and causes pipeline failures if unhandled. Missingness falls into three mechanisms: Missing Completely at Random (MCAR), Missing at Random (MAR), and Missing Not at Random (MNAR). Imputation techniques range from simple Mean/Median/Mode insertion and indicator flags to Iterative MICE (Multivariate Imputation by Chained Equations) and KNN imputation. Modern GBDTs (XGBoost, LightGBM) handle missing values natively during split finding.

Classical MLintermediate5 min

Assumptions of Linear Regression

The conditions linear regression needs, and what breaks when they fail.

Linear Regression using Ordinary Least Squares (OLS) relies on key statistical assumptions for valid parameter inference. Core assumptions include Linearity between features and target, Independence of error residuals, Homoscedasticity (constant residual variance), and Normality of residuals. Violating these assumptions introduces coefficient bias, invalidates p-values and confidence intervals, and requires diagnostic fixes like log transforms or Robust Standard Errors.

Classical MLintermediate4 min

Multicollinearity & VIF

When features overlap so much that the model cannot tell them apart.

Multicollinearity occurs when two or more predictor features in a linear model are highly correlated with each other. While multicollinearity does not reduce overall model predictive power, it inflates coefficient standard errors, flips parameter signs, and makes individual feature importance uninterpretable. Multicollinearity is diagnosed using the Variance Inflation Factor (VIF) and resolved via feature removal, PCA, or L2 Ridge Regularization.

Classical MLintermediate4 min

Elastic Net

Lasso and Ridge combined, for when your features come in related groups.

Elastic Net mixes the L1 and L2 penalties into one. Lasso, the L1 penalty, is great at dropping useless features, but when several features are strongly related it tends to keep one at random and throw away the rest. Adding a little of the L2 penalty fixes that, so related features rise or fall together as a group. Elastic Net is the safe choice when you have more features than samples, as in genetics, or when many of your features overlap.

Classical MLintermediate4 min

Normal Equation vs Gradient Descent

Solve linear regression in one formula, or step toward it? It depends on size.

Linear regression can be solved two ways. The normal equation is a single formula that gives the exact best weights in one go, with no learning rate to tune. The catch is that it inverts a matrix whose size grows with the number of features, and that cost explodes, roughly cubing as features grow. Gradient descent instead takes many small steps toward the answer. It is approximate, but it scales to millions of features and rows, which is why big models always use it.

Classical MLintermediate4 min

Gini Impurity vs Entropy

Two ways a tree decides which split is best, and why it rarely matters.

Gini Impurity and Entropy are mathematical metrics used to measure node impurity when building Decision Trees. Gini Impurity measures the probability of misclassifying a randomly chosen sample if labeled according to class distributions in the node. Entropy measures Information Disorder in bits using logarithmic scaling. In practice, Gini Impurity and Entropy yield nearly identical decision tree structures 98 percent of the time, but Gini is faster because it avoids logarithm calculations.

Classical MLintermediate4 min

Pruning & Tree Regularization

Cutting a tree back so it stops memorising the training data.

Tree Pruning removes non critical branches from Decision Trees to prevent overfitting and improve generalization on unseen test data. Pre Pruning (Early Stopping) halts tree growth during training using stopping rules like max depth or min samples per leaf. Post Pruning (Cost Complexity Pruning) grows a fully deep tree first, then collapses subtrees that add excessive complexity relative to validation accuracy gain.

Classical MLintermediate5 min

Random Forests

Hundreds of trees that each go wrong differently, so their errors cancel out.

A random forest trains hundreds of decision trees and averages their answers. Each tree learns from a different random sample of the data, and at every split it may only consider a random handful of features. That double randomness makes the trees go wrong in different ways, so their errors cancel out when combined. A single deep tree overfits badly, but the forest is far more stable, and adding more trees never makes it overfit more. It is a strong, low-effort baseline for tabular data.

Classical MLintermediate4 min

AdaBoost

Turning many weak, tiny trees into one strong classifier.

AdaBoost builds a strong classifier out of many very weak ones, usually tiny trees with a single split. It trains them one after another. After each round, the examples the model got wrong are given more weight, so the next tiny tree concentrates on the hard cases. At the end every tree votes, and the more accurate trees get a louder vote. It was the first boosting method to work well in practice, and its ideas led directly to gradient boosting.

Classical MLintermediate5 min

Support Vector Machines

Finding the widest possible gap between two classes.

A support vector machine separates two classes with the widest possible gap between them. Rather than just any dividing line, it finds the one furthest from the nearest points on each side, and those nearest points, called support vectors, are the only ones that decide where the line goes. Real data is messy, so a setting called C sets the trade-off: a small C allows some mistakes for a wider gap, a large C fits the training data tightly. Kernels let it draw curved boundaries.

Classical MLintermediate5 min

Choosing k: Elbow & Silhouette

How to decide how many clusters your data actually has.

Choosing the optimal number of clusters k is a central challenge in unsupervised learning algorithms like k-Means. The Elbow Method plots Inertia against k, searching for an elbow bend point where marginal inertia reduction levels off. Silhouette Analysis measures how well separated clusters are by comparing mean intra-cluster distance a(i) to mean nearest-neighbor cluster distance b(i), outputting scores between minus 1 and plus 1.

Classical MLintermediate4 min

Hierarchical Clustering

Clustering into a family tree, without choosing the number of groups first.

Hierarchical Clustering constructs a nested tree of clusters called a Dendrogram. Agglomerative (bottom-up) starts with N individual clusters and iteratively merges the closest pair of clusters until 1 root remains. Divisive (top-down) starts with 1 root cluster and recursively splits. Distance between clusters depends on Linkage criteria: Single (minimum distance), Complete (maximum distance), Average, or Ward's (minimum variance increase).

Classical MLintermediate4 min

DBSCAN & Density Clustering

Clustering that finds odd-shaped groups and flags the outliers for you.

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) groups points based on spatial density rather than centroids. Given neighborhood radius ε (eps) and minimum points minPts, points are categorized as Core Points, Border Points, or Noise Outliers. DBSCAN discovers clusters of arbitrary shapes (concentric rings, spirals), handles noise natively, and does not require specifying k upfront.

Classical MLintermediate4 min

Generative vs Discriminative Models

Learn the boundary between classes, or learn what each class looks like?

These are two ways of building a classifier. A discriminative model learns the boundary between classes directly: given these features, which class is it? Logistic regression, SVMs and BERT classifiers work this way, and they are usually more accurate when all you need is to classify. A generative model learns what each class looks like, meaning how its data is produced, and uses that to classify. Naive Bayes, GANs and GPT are generative, which is why they can also create brand-new examples.

Classical MLintermediate5 min

Hyperparameter Tuning Strategies

Grid, random or Bayesian search, and why random usually beats grid.

Hyperparameters are the settings you choose before training, like learning rate or tree depth. Grid search tries every combination from a list, which wastes time on settings that barely matter. Random search tries random combinations and usually wins on the same budget, because only a few settings tend to matter and random sampling covers each of them more thoroughly. Bayesian optimisation learns from earlier trials to guess which settings look promising next, so it needs far fewer expensive training runs.

Classical MLintermediate5 min

Outlier & Anomaly Detection

Spotting the strange points that are either errors or exactly what you are looking for.

Outlier and Anomaly Detection identifies observations that deviate significantly from expected normal data distributions. Statistical methods use Z-score thresholds or Interquartile Range (IQR bounds: Q1 - 1.5·IQR, Q3 + 1.5·IQR). Unsupervised ML algorithms include Isolation Forest (isolating anomalies via random splits), One-Class SVM (fitting tight decision boundaries around normal points), Local Outlier Factor (LOF), and Autoencoder reconstruction error thresholds.

Classical MLintermediate5 min

Time Series Forecasting Basics

Predicting the future from trend, seasonality and the recent past.

Time Series Forecasting predicts future observations y_{t+h} given historical observations y_1, ..., y_t. Time series data decomposes into Trend T_t, Seasonality S_t, Cyclical patterns C_t, and Residual Noise I_t. Classical statistical approaches (ARIMA, Exponential Smoothing) rely on stationarity and autocorrelation. Modern Machine Learning approaches (XGBoost, Prophet, DeepAR, Temporal Fusion Transformers) frame forecasting as supervised regression using lagged features and rolling window statistics.

Classical MLintermediate4 min

Stationarity & Differencing

Classic forecasting models need data that behaves the same over time. Most data does not.

Stationarity is a fundamental requirement for classical time series models (ARIMA, Vector Autoregression). A time series is Strictly Stationary if its joint distribution is invariant to time shifts. It is Weakly (Strictly Weak/Second-Order) Stationary if its Mean E[Y_t] = μ is constant over time, Variance Var(Y_t) = σ² is constant, and Autocovariance Cov(Y_t, Y_{t+k}) depends only on lag k. Non-stationary series containing trends or seasonal shifts are transformed into stationary series via First Differencing (ΔY_t = Y_t - Y_{t-1}) or Log Transforms.

Classical MLintermediate4 min

The No Free Lunch Theorem

Why no single algorithm is best at everything.

The no free lunch theorem says that no single algorithm is best for every problem. Averaged over every possible kind of data, all methods perform equally. Every algorithm works by making assumptions about the data, such as smooth curves or neighbouring pixels mattering, and those assumptions help on some problems and hurt on others. A model built for images will do poorly on spreadsheets. So the real skill is matching an algorithm's built-in assumptions to the problem, and testing rather than trusting.

Classical MLadvanced5 min

XGBoost vs LightGBM vs CatBoost

Three gradient boosting libraries, and when to pick each one.

XGBoost, LightGBM, and CatBoost are the three dominant gradient boosting libraries for tabular data. XGBoost introduced second order Hessian optimization, exact pre sorted greedy splits, and hardware regularization. LightGBM introduced Leaf Wise tree growth, Histogram Binning, and GOSS (Gradient-based One-Side Sampling), running 10 times faster with lower memory usage. CatBoost introduced Ordered Boosting and Target Encoding to handle high cardinality categorical features without target leakage.

Classical MLadvanced5 min

Stacking & Blending

Combining several models so the team beats any single player.

Ensembling combines predictions from multiple machine learning models to improve overall generalization accuracy. Simple ensembling uses Voting (majority rule for classification) or Weighted Averaging (scaling outputs by validation accuracy). Stacking (Stacked Generalization) trains a second stage Meta Learner model on out of fold predictions generated by diverse base Level 0 models, leveraging complementary strengths across distinct algorithms.

Classical MLadvanced5 min

The Kernel Trick

Drawing curved boundaries by pretending your data has extra dimensions.

The Kernel Trick allows linear algorithms like Support Vector Machines to operate in high dimensional non linear feature spaces. Instead of explicitly transforming inputs phi(x) into high dimensional space, Kernel Functions compute inner dot products K(x, z) = <phi(x), phi(z)> directly in raw low dimensional input space. Popular kernels include Polynomial Kernel and Radial Basis Function (RBF / Gaussian) Kernel, which implicitly projects data into infinite dimensional Hilbert space.

Classical MLadvanced5 min

Gaussian Mixtures & EM

Soft clustering, where each point can partly belong to several groups.

Gaussian Mixture Models (GMMs) model complex data distributions as a weighted sum of K multivariate Gaussian components. Unlike k-Means which assigns hard cluster memberships (0/1), GMM provides soft probabilistic assignments P(Component k | x_i). Parameters (means μ_k, covariance matrices Σ_k, mixing weights π_k) are estimated via the Expectation-Maximization (EM) algorithm, alternating between computing responsibility probabilities (E-step) and updating Gaussian parameters (M-step).

Classical MLadvanced5 min

LDA for Dimensionality Reduction

Shrinking features in the way that best keeps the classes apart.

Linear discriminant analysis reduces features using the class labels, unlike PCA, which ignores them. PCA keeps the directions where data spreads the most, even if that spread does nothing to separate the classes. LDA instead looks for directions that push the class groups far apart while keeping each group tight. With C classes it can keep at most C minus one dimensions. It works best when each class is roughly bell-shaped with a similar spread, and it doubles as a simple classifier.

Classical MLadvanced5 min

t-SNE vs UMAP

Squashing high-dimensional data onto a flat picture you can actually look at.

t-SNE and UMAP are non linear dimensionality reduction techniques designed for 2D and 3D data visualization. t-SNE maps pairwise high dimensional Gaussian similarities to low dimensional Student t distributions, resolving crowding issues but sacrificing global distance structure. UMAP uses Riemannian geometry and fuzzy simplicial sets to preserve both local cluster neighborhoods and global inter cluster relationships, running much faster than t-SNE.

Classical MLadvanced5 min

Bayesian Optimization for HPO

Tuning expensive models by learning which settings to try next.

Bayesian Optimization is a sequential strategy for optimizing expensive black box functions (such as hyperparameter tuning for deep neural networks). It builds a probabilistic Surrogate Model (Gaussian Process) to estimate the objective function mean and uncertainty across hyperparameter space. An Acquisition Function (Expected Improvement or Upper Confidence Bound) balances Exploration (sampling high uncertainty regions) against Exploitation (sampling near current best parameters).

Classical MLadvanced5 min

ARIMA vs Prophet vs Gradient Boosting

Three ways to forecast a time series, and when each one wins.

These are three ways to forecast a time series. ARIMA is a classic statistical model that predicts the next value from recent values and recent errors, after removing the trend, and it suits short, steady series. Prophet, from Meta, fits a smooth trend plus weekly and yearly patterns and holiday effects, and is easy to use on business data. Gradient boosting treats forecasting as ordinary tabular prediction using lagged and rolling features, and often wins when you have many related series.

Classical MLadvanced5 min

Survival Analysis

Predicting how long until something happens, when many cases have not happened yet.

Survival analysis predicts how long until something happens, like a customer cancelling or a machine failing. The tricky part is that, for many people in your data, the event has not happened yet when the study ends. You know they lasted at least this long, but not how long in total. That is called censoring, and ordinary regression gets it wrong. The Kaplan-Meier curve estimates the share still surviving over time, and the Cox model measures how each factor raises or lowers the risk.

Classical MLadvanced5 min

Semi-Supervised Learning

Getting value from huge amounts of unlabelled data plus a few labels.

Semi Supervised Learning combines a small dataset of labelled samples with a large pool of unlabelled samples. Because manual data annotation is expensive, semi-supervised techniques extract structural data geometry from unlabelled samples to improve decision boundaries. Key paradigms include Pseudo Labeling (Self Training), Consistency Regularization (FixMatch), and Generative Pretraining followed by Fine Tuning.

Classical MLadvanced5 min

Active Learning

Letting the model choose which examples are worth paying a human to label.

Active Learning is a subfield of machine learning where the algorithm interactively queries a human annotator (Oracle) to label specific unlabelled samples. Instead of labeling data at random, Active Learning uses Query Strategies (Uncertainty Sampling, Query By Committee, Expected Model Change) to select the single most informative data points. This achieves high model accuracy using up to 90 percent fewer human annotation labels.

SCROLL · SAVE · TAP TO GO DEEPER