LearnThatStack Ace your next interview
Machine Learning & Data Science
Classical ML Algorithms.
Change topic Change
Practice · Questions

All questions

Showing of 56
Beginner 17
01

What are the assumptions behind linear regression, and why do they matter?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

How do you interpret the coefficients of a linear regression model?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is logistic regression, and how does it differ from linear regression?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What is the sigmoid function, and why does logistic regression need it?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What is a random forest, and how does it differ from one tree?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What is KNN, and why is it called a lazy, non-parametric learner?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

Which distance metrics can KNN use to measure similarity between points?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

Can KNN be used for regression, and how would the prediction work?

Beginner ·

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:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

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.

Rewriting in plainer words…

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 ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

What is the separating hyperplane in an SVM, and what are support vectors?

Part of Pro
10

What does Naive Bayes assume, and why is that assumption called naive?

Part of Pro
11

What is overfitting, and how does regularization help prevent it?

Part of Pro
12

What is cross-entropy loss, and what exactly does it measure?

Part of Pro
13

What is K-Means, and what happens in its assignment and update steps?

Part of Pro
14

How does agglomerative hierarchical clustering build clusters from the bottom up?

Part of Pro
15

What is DBSCAN, and what do the eps and minPts parameters control?

Part of Pro
16

What is principal component analysis, and how does it reduce dimensionality?

Part of Pro
17

What is the curse of dimensionality, and why does it hurt models?

Part of Pro
Intermediate 33
18

How does a decision tree choose a split, and when is a node pure?

Part of Pro
19

How do bagging and feature randomness decorrelate the trees in a random forest?

Part of Pro
20

What is out-of-bag error, and why does each bootstrap sample miss a third?

Part of Pro
21

How does gradient boosting build a model by fitting the previous errors?

Part of Pro
22

How do random forests and gradient boosted trees differ, and when pick each?

Part of Pro
23

How do you improve a gradient boosting model through learning rate and tuning?

Part of Pro
24

How do you choose K in KNN, and why prefer an odd value?

Part of Pro
25

Does KNN require feature scaling, and what goes wrong without it?

Part of Pro
26

Why is KNN a poor choice on very large datasets?

Part of Pro
27

What is the margin in an SVM, and why does maximizing it help?

Part of Pro
28

What is the kernel trick, and what does it let an SVM do?

Part of Pro
29

How do hard margin and soft margin SVMs differ, and what are slack variables?

Part of Pro
30

What is Laplace smoothing in Naive Bayes, and what breaks without it?

Part of Pro
31

What are log-odds, and how do you read a coefficient as an odds ratio?

Part of Pro
32

How does ordinary least squares fit a line, and when use gradient descent?

Part of Pro
33

What is multicollinearity, how do you detect it, and how do you handle it?

Part of Pro
34

What is the difference between L1 and L2 regularization, and when use each?

Part of Pro
35

What is Elastic Net, and what problem does it solve that Lasso cannot?

Part of Pro
36

How do you choose the regularization strength lambda for your model?

Part of Pro
37

Why is cross-entropy preferred over mean squared error for classification problems?

Part of Pro
38

How does class imbalance change what a model actually learns during training?

Part of Pro
39

How do One-vs-Rest and One-vs-One differ, and when is One-vs-One better?

Part of Pro
40

How do you choose the number of clusters k, and how reliable is the elbow?

Part of Pro
41

How does centroid initialization affect K-Means, and what does K-Means++ fix?

Part of Pro
42

Where does K-Means fail, on odd cluster shapes and on outliers?

Part of Pro
43

How does K-Means compare with hierarchical clustering, and when do you choose each?

Part of Pro
44

How do single, complete, average and Ward linkage differ in agglomerative clustering?

Part of Pro
45

When would you prefer DBSCAN over K-Means, and how does it treat noise?

Part of Pro
46

What do eigenvalues and eigenvectors of the covariance matrix mean in PCA?

Part of Pro
47

How many principal components should you keep, and how do you decide?

Part of Pro
48

Why should you standardize your features before applying PCA?

Part of Pro
49

How does high dimensionality distort distance, and why does that break KNN?

Part of Pro
50

How does t-SNE differ from PCA, and why treat it as visualization only?

Part of Pro
Expert 6
51

Compare resampling, SMOTE, class weighting and threshold moving for handling class imbalance

Part of Pro
52

How would you build a classifier when the positive class is under one percent?

Part of Pro
53

How do you cross-validate an imbalanced dataset without leaking resampled rows?

Part of Pro
54

How does XGBoost differ from plain gradient boosting, and why is it faster?

Part of Pro
55

Why are bagging and boosting both robust when one cuts variance and one bias?

Part of Pro
56

What is singular value decomposition, and how does it relate to PCA?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Classical ML Algorithms? Send them this set.
Pro · $10/mo

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.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git