All questions
Showing of 56What are the assumptions behind linear regression, and why do they matter?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Linear regression rests on a few assumptions about the data and the residuals. The relationship between the features and the target is linear. Observations are independent of each other. Residuals have constant variance across the fitted range. Residuals are roughly normal. And no feature is a perfect linear combination of the others.
They matter in two different ways. Linearity and independence affect the coefficients themselves, so breaking them makes the estimates wrong. Constant variance and normal residuals mostly affect the uncertainty around those estimates. The fitted line can look fine while every p-value and confidence interval quietly lies.
The cheapest check is a residual plot against the fitted values. A funnel shape means the variance grows with the prediction. A curve means you are forcing a straight line through a bend. Time-ordered or repeated-measure data usually breaks independence. That makes the model look far more confident than it deserves.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you interpret the coefficients of a linear regression model?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Each coefficient is the expected change in the target when that feature rises by one unit and the others stay fixed. The intercept is the prediction when every feature equals zero. That is often a meaningless point, because zero may sit far outside the observed data.
Units drive everything. A coefficient of 3200 on bedrooms means 3200 more dollars per extra bedroom. You cannot compare raw coefficients across features, because a variable measured in millimetres earns a tiny number. Standardize the features first if you want to rank them by influence.
The phrase "holding the others fixed" is where readings go wrong. When two features move together in reality, nobody can hold one still, so the number is not a causal effect. Signs can even flip when you add or remove a related feature. Always report a coefficient alongside the exact feature set it was fitted with.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is logistic regression, and how does it differ from linear regression?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Logistic regression predicts the probability of a class rather than a numeric quantity. It computes the same weighted sum of features that linear regression does. The difference is that the sum is passed through a squashing function, so the output stays between zero and one.
Three things change. The target is a category, not a continuous value. Fitting uses maximum likelihood with an iterative solver, not a closed-form least squares formula. The output is a probability, and you turn it into a label by comparing it against a threshold.
Running plain linear regression on zero-one labels is the mistake this fixes. That model happily predicts 1.4 or a negative probability, and neither can be acted on. Its errors also grow at the edges, so points far from the boundary drag the line around. Logistic regression keeps the readable linear score while making the output usable.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the sigmoid function, and why does logistic regression need it?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The sigmoid is the S-shaped function that maps any real number into the range zero to one. Large negative inputs land near zero, large positive inputs near one, and zero maps to exactly 0.5.
const sigmoid = z => 1 / (1 + Math.exp(-z));
sigmoid(0); // 0.5
sigmoid(2.2); // 0.900
Logistic regression needs it because a weighted sum of features is unbounded, while a probability is not. The sigmoid also preserves order, so ranking by raw score matches ranking by probability. It is smooth and differentiable everywhere, which is what lets gradient descent fit the weights.
The cost is saturation. Once a score sits far from zero, the curve is almost flat and the gradient nearly vanishes. A confidently wrong prediction then learns very slowly. Unscaled features push scores into that flat region, which is one reason training stalls.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a random forest, and how does it differ from one tree?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A random forest is a collection of many decision trees whose predictions get combined into one. Each tree sees a different random sample of rows and a different random subset of features at each split. For classification the trees vote; for regression their outputs are averaged.
The difference from one tree is stability. A single deep tree fits the noise in its training data, and swapping a few rows can change its whole structure. Averaging many trees that each err in different directions cancels most of that noise. The forest usually beats the single tree on unseen data by a wide margin.
You pay for that in two ways. Hundreds of trees cost more memory and more prediction time than one. You also lose the readable if-then path and get ranked feature importances instead. Training parallelises easily, since the trees never depend on each other.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is KNN, and why is it called a lazy, non-parametric learner?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
K-nearest neighbours (KNN) stores the training rows and predicts by finding the k closest ones to a new point. Classification takes the majority label among those neighbours.
It is lazy because there is no real training step. Fitting just keeps the data in memory, and all the work happens at prediction time. A naive scan costs about O(nd) distance computations per query, with n rows and d features.
It is non-parametric because no fixed set of parameters is ever learned. The shape of the decision boundary comes from the data itself, so it can bend any way the classes require. That is the appeal: you assume nothing about linearity or about the distribution of the features. The cost is that the whole dataset must be kept and searched for every single prediction.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Which distance metrics can KNN use to measure similarity between points?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Euclidean distance is the default choice, but the right metric depends on what the features mean.
- Euclidean, the straight-line distance. Fine for continuous features that share comparable scales.
- Manhattan, the sum of absolute differences along each axis. It holds up better in high dimensions and with grid-like or count data.
- Minkowski, the general form with a parameter p. Setting p to 1 gives Manhattan and setting it to 2 gives Euclidean.
- Cosine, the angle between two vectors. It ignores magnitude, which suits text and sparse counts where document length varies.
- Hamming, the count of positions where two rows differ. Use it for binary or categorical features.
The metric is a real hyperparameter, not a detail. Change it and the neighbour set changes, so the prediction changes with it. Mixed numeric and categorical data usually needs a combined measure such as Gower distance, since no single formula fits both types.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Can KNN be used for regression, and how would the prediction work?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Yes, and the change is small: instead of voting on labels, k-nearest neighbours (KNN) averages the target values of the k nearest neighbours. Predicting a house price means taking the mean price of the k most similar houses.
A common refinement weights each neighbour by the inverse of its distance. Closer points then pull the prediction harder, which smooths out the jumps you see when k is large.
Two costs are worth knowing. The prediction surface is a staircase rather than a smooth curve, because a whole region shares the same neighbour set. And the model cannot extrapolate at all. Feed it an input beyond the training range and it returns the average of the same edge neighbours, flat forever. That makes it a poor fit for trending data such as prices over time.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the separating hyperplane in an SVM, and what are support vectors?
What does Naive Bayes assume, and why is that assumption called naive?
What is overfitting, and how does regularization help prevent it?
What is cross-entropy loss, and what exactly does it measure?
What is K-Means, and what happens in its assignment and update steps?
How does agglomerative hierarchical clustering build clusters from the bottom up?
What is DBSCAN, and what do the eps and minPts parameters control?
What is principal component analysis, and how does it reduce dimensionality?
What is the curse of dimensionality, and why does it hurt models?
How does a decision tree choose a split, and when is a node pure?
How do bagging and feature randomness decorrelate the trees in a random forest?
What is out-of-bag error, and why does each bootstrap sample miss a third?
How does gradient boosting build a model by fitting the previous errors?
How do random forests and gradient boosted trees differ, and when pick each?
How do you improve a gradient boosting model through learning rate and tuning?
How do you choose K in KNN, and why prefer an odd value?
Does KNN require feature scaling, and what goes wrong without it?
Why is KNN a poor choice on very large datasets?
What is the margin in an SVM, and why does maximizing it help?
What is the kernel trick, and what does it let an SVM do?
How do hard margin and soft margin SVMs differ, and what are slack variables?
What is Laplace smoothing in Naive Bayes, and what breaks without it?
What are log-odds, and how do you read a coefficient as an odds ratio?
How does ordinary least squares fit a line, and when use gradient descent?
What is multicollinearity, how do you detect it, and how do you handle it?
What is the difference between L1 and L2 regularization, and when use each?
What is Elastic Net, and what problem does it solve that Lasso cannot?
How do you choose the regularization strength lambda for your model?
Why is cross-entropy preferred over mean squared error for classification problems?
How does class imbalance change what a model actually learns during training?
How do One-vs-Rest and One-vs-One differ, and when is One-vs-One better?
How do you choose the number of clusters k, and how reliable is the elbow?
How does centroid initialization affect K-Means, and what does K-Means++ fix?
Where does K-Means fail, on odd cluster shapes and on outliers?
How does K-Means compare with hierarchical clustering, and when do you choose each?
How do single, complete, average and Ward linkage differ in agglomerative clustering?
When would you prefer DBSCAN over K-Means, and how does it treat noise?
What do eigenvalues and eigenvectors of the covariance matrix mean in PCA?
How many principal components should you keep, and how do you decide?
Why should you standardize your features before applying PCA?
How does high dimensionality distort distance, and why does that break KNN?
How does t-SNE differ from PCA, and why treat it as visualization only?
Compare resampling, SMOTE, class weighting and threshold moving for handling class imbalance
How would you build a classifier when the positive class is under one percent?
How do you cross-validate an imbalanced dataset without leaking resampled rows?
How does XGBoost differ from plain gradient boosting, and why is it faster?
Why are bagging and boosting both robust when one cuts variance and one bias?
What is singular value decomposition, and how does it relate to PCA?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Classical ML Algorithms cheatsheet
- 30-second picker01
- Linear and logistic regression02
- Regularization03
- Trees and ensembles04
- KNN05
- SVM06
- Naive Bayes07
- Loss functions and class imbalance08
- Clustering09
- Dimensionality reduction10
- Cost quick-reference11
- Leakage and reporting pitfalls12
- + 6 more inside
48 of 56 Classical ML Algorithms answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.