Machine learning basics: 50 cards on models, training and metrics
Machine learning flashcards: supervised vs unsupervised learning, overfitting, bias-variance, regularization, gradient descent, common models and metrics.
Practice now
Study without an account
Scheduled with the default Askesis timings. Progress is saved in this browser.
All 50 cards
- 1Supervised vs unsupervised learningSupervised learning trains on labeled examples (inputs with known answers) to predict labels for new inputs; unsupervised learning finds structure, such as clusters, in unlabeled data
- 2Classification vs regressionClassification predicts a category (spam or not spam); regression predicts a continuous number (a house price)
- 3Reinforcement learningAn agent learns by taking actions in an environment and receiving rewards, aiming to maximize its total reward over timeUsed for game-playing agents, robotics, and fine-tuning language models from human feedback (RLHF).
- 4Features and labelsFeatures are the input variables a model uses; the label (or target) is the value it learns to predictPredicting house prices: size and location are features, the sale price is the label.
- 5Parameters vs hyperparametersParameters, such as weights, are learned from the data during training; hyperparameters (learning rate, tree depth, k in k-NN) are set before training and tuned on validation data
- 6Train, validation and test setsThe training set fits the model, the validation set guides tuning and model selection, and the test set gives a final, unbiased estimate of performance on unseen dataCommon splits are 70/15/15 or 80/10/10; cross-validation can replace a fixed validation set.
- 7Why keep the test set untouched until the end?Every decision made by looking at test scores leaks information into the model, so the test score becomes optimistic and no longer predicts real-world performance
- 8Split data 80/20 in scikit-learn, keeping class proportionspython
from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.2, stratify=y, random_state=42 )stratify=ykeeps the same class balance in both sets;random_statemakes the split reproducible. - 9Data leakageInformation that wouldn’t be available at prediction time sneaks into training, so validation scores look far better than real performanceExamples: fitting a scaler on the full dataset before splitting, a feature computed from the target, or random splits of time-series data that let the model see the future.
- 10Scale features without leaking validation data into trainingpython
from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LogisticRegression model = make_pipeline(StandardScaler(), LogisticRegression()) model.fit(X_train, y_train)Inside a pipeline the scaler is fitted only on the training data, or on the training folds during cross-validation. - 11OverfittingThe model memorizes noise and quirks of the training data: training error is low but validation error is much higher
- 12UnderfittingThe model is too simple to capture the pattern: error is high on both the training and the validation data
- 13Training accuracy 99%, validation accuracy 72%. Diagnosis?Overfitting (high variance): the model fits the training data far better than new dataTry more data, a simpler model, stronger regularization or early stopping.
- 14Bias vs varianceBias is error from overly simple assumptions (underfitting); variance is error from sensitivity to the particular training sample (overfitting). More complex models usually lower bias but raise variance
- 15Bias-variance decomposition of expected squared erroris irreducible noise: no model can remove it.
- 16Common ways to reduce overfittingGet more data, simplify the model, add regularization, stop training early, use dropout, augment the data, or drop noisy featuresEarly stopping halts training when the validation loss stops improving.
- 17RegularizationAdding a penalty for model complexity, usually large weights, to the loss so the model is discouraged from fitting noise
- 18L1 vs L2 regularizationL1 (lasso) adds and drives some weights to exactly zero; L2 (ridge) adds and shrinks all weights smoothlyL1 doubles as feature selection. Elastic net combines both penalties.
- 19What happens as you increase the regularization strength?The model gets simpler: variance falls and bias rises. Too much regularization underfitsIn scikit-learn’s
LogisticRegressionand SVMs,Cis the inverse of the strength: a smallerCmeans stronger regularization. - 20DropoutDuring training, randomly zeroes a fraction of a layer’s outputs on each step so the network can’t rely on any single neuron; it is switched off at inferenceTypical rates are 0.1 to 0.5.
- 21Loss functionA function that measures how far predictions are from the true values; training adjusts the parameters to minimize itMean squared error for regression, cross-entropy (log loss) for classification.
- 22Mean squared error (MSE)
- 23Binary cross-entropy (log loss)It punishes confident wrong predictions heavily.
- 24Gradient descent update ruleEach step moves the parameters against the gradient of the loss; is the learning rate.
- 25Learning rate too high vs too lowToo high: updates overshoot, so the loss oscillates or diverges. Too low: training converges very slowly or stalls
- 26Batch vs stochastic vs mini-batch gradient descentBatch uses the whole dataset for each update, stochastic (SGD) a single example, and mini-batch a small batch such as 32 to 256 examples, the usual compromiseOne epoch is one full pass over the training data.
- 27Linear regressionPredicts a number as a weighted sum of the features plus a bias, , fitted by minimizing squared error
- 28Logistic regressionA classifier that passes a linear score through the sigmoid to get a probability between 0 and 1Despite the name, it is used for classification.
- 29Decision treeSplits the data with a sequence of if/else questions on feature values, choosing the splits that best separate the targetsEasy to interpret, but deep trees overfit; limit
max_depthor prune them. - 30Random forestAn ensemble of decision trees, each trained on a bootstrap sample of the data with a random subset of features considered at each split; predictions are averaged or votedThis is bagging: averaging many independently trained trees reduces variance.
- 31Gradient boostingBuilds trees one after another, each fitting the remaining errors (the loss gradients) of the ensemble so farBoosting mainly reduces bias. XGBoost, LightGBM and CatBoost are popular implementations and often win on tabular data.
- 32k-nearest neighbors (k-NN)Predicts from the k closest training examples: a majority vote for classification, an average for regressionThere is no real training step, but prediction is slow on large datasets and features must be scaled.
- 33Support vector machine (SVM)Finds the decision boundary with the widest margin between the classes; kernels such as RBF allow non-linear boundaries
- 34k-means clusteringUnsupervised: picks k centroids, then repeatedly assigns each point to its nearest centroid and moves each centroid to the mean of its pointsYou choose k yourself, often with the elbow method or the silhouette score.
- 35Principal component analysis (PCA)Unsupervised dimensionality reduction that projects the data onto the orthogonal directions of greatest varianceUsed to compress features, speed up training and plot high-dimensional data in 2D.
- 36Which models need feature scaling?Distance- and gradient-based ones: k-NN, k-means, SVMs, neural networks and regularized linear models. Tree-based models don’t need itStandardization: , with and computed on the training set only.
- 37One-hot encodingTurns a categorical feature into one binary column per category, so models don’t read a false order into category codesA
colorcolumn with red, green and blue becomesis_red,is_greenandis_blue. - 38Confusion matrixA table of predicted against actual classes, giving the counts of true positives, false positives, true negatives and false negatives
- 39Why can accuracy mislead?With imbalanced classes a useless model scores high: if 99% of transactions are legitimate, always predicting “legitimate” is 99% accurate and catches no fraud
- 40Precision: of the items predicted positive, the share that really are positive
- 41Recall (sensitivity): of the actual positives, the share the model foundAlso called the true positive rate.
- 42F1 scoreThe harmonic mean of precision and recall:It is high only when both precision and recall are high.
- 43Cancer screening vs spam filter: favor precision or recall?Screening favors recall, because a missed case is costly; a spam filter favors precision, because losing a real email to the spam folder is costlyRaising the decision threshold usually increases precision and lowers recall.
- 44ROC curve and ROC-AUCThe ROC curve plots the true positive rate against the false positive rate across all thresholds; AUC is the area under it, where 0.5 means random guessing and 1.0 a perfect rankingAUC equals the probability that a random positive is ranked above a random negative. On heavily imbalanced data, the precision-recall curve is often more informative.
- 45k-fold cross-validationSplit the data into k folds, train on k − 1 of them and validate on the remaining one, rotate k times, then average the scorespython
from sklearn.model_selection import cross_val_score scores = cross_val_score(model, X, y, cv=5, scoring="f1") - 46MAE vs RMSEBoth measure regression error in the target’s units; RMSE squares errors before averaging, so it penalizes large errors more than MAE does
- 47What does a single artificial neuron compute?A weighted sum of its inputs plus a bias, passed through an activation function:
- 48Why do neural networks need non-linear activation functions?Without them, any stack of layers collapses into a single linear function, so extra layers add nothingReLU, , is the usual default for hidden layers.
- 49BackpropagationComputes the gradient of the loss with respect to every weight by applying the chain rule backward from the output layer; an optimizer such as SGD or Adam then updates the weights
- 50SoftmaxTurns a vector of scores (logits) into probabilities that sum to 1:Used in the output layer of multi-class classifiers.
Frequently asked questions
Do I need a lot of math for this deck?
Basic algebra is enough for most cards. A few formulas, such as the gradient descent update and log loss, are shown in LaTeX next to a plain-language explanation.
Does it cover deep learning?
Only the basics: neurons, activation functions, backpropagation, softmax and dropout. The focus is on concepts that apply to every model, from linear regression to neural networks.
Which library do the code examples use?
scikit-learn, the standard Python library for classic machine learning. The ideas carry over to any framework.
Is it useful for data science interviews?
Yes. Overfitting, the bias-variance tradeoff, precision vs recall, ROC-AUC and cross-validation are among the most common interview questions.
More in Data & AI
Data analysis
Data analysis flashcards: summary statistics, data cleaning, joins and group-by in pandas and SQL, pivot tables, chart choices, A/B tests and causation.
50 cardsPrompt engineering
Prompt engineering flashcards: tokens, context windows, temperature, few-shot and chain-of-thought prompting, structured output, RAG and prompt injection.
50 cards