Title: Machine Learning Programming — LearnCoachAssist

Q: What is supervised learning?
A: Supervised learning is a type of machine learning where the model is trained on labeled data, meaning each training example includes an input and its corresponding correct output. The algorithm learns a mapping from inputs to outputs, which it then uses to make predictions on unseen data. Common tasks include classification and regression.

Q: What is unsupervised learning?
A: Unsupervised learning is a type of machine learning where the model is trained on unlabeled data and must discover hidden patterns or structures on its own. Common tasks include clustering (grouping similar data points), dimensionality reduction, and anomaly detection. Examples include k-means clustering and PCA.

Q: What is the difference between classification and regression?
A: Classification predicts a discrete label (e.g., spam or not spam), while regression predicts a continuous value (e.g., house price). Classification outputs categories, whereas regression outputs numerical quantities. Both are supervised learning tasks.

Q: What is linear regression?
A: Linear regression is a supervised learning algorithm that models the relationship between a dependent variable and one or more independent variables by fitting a straight line (or hyperplane). The model minimizes the sum of squared residuals between predicted and actual values. In scikit-learn, it is implemented as LinearRegression().

Q: What is logistic regression?
A: Logistic regression is a supervised learning algorithm used for binary classification despite its name containing "regression." It uses the sigmoid function to map predictions to probabilities between 0 and 1. A threshold (typically 0.5) is applied to convert probabilities into class labels.

Q: What is a decision tree?
A: A decision tree is a supervised learning model that makes predictions by learning if-then-else rules from the data, forming a tree-like structure of decisions. Each internal node represents a test on a feature, each branch represents an outcome, and each leaf represents a class label or value. They are easy to interpret but prone to overfitting.

Q: What is a random forest?
A: A random forest is an ensemble learning method that constructs multiple decision trees during training and outputs the mode (classification) or mean (regression) of the individual trees' predictions. It reduces overfitting by using bagging (bootstrap aggregating) and random feature selection. In scikit-learn: RandomForestClassifier().

Q: What is a Support Vector Machine (SVM)?
A: An SVM is a supervised learning algorithm that finds the optimal hyperplane that maximally separates classes in feature space. The data points closest to the hyperplane are called support vectors. SVMs can handle non-linear boundaries using the kernel trick (e.g., RBF, polynomial kernels). In scikit-learn: SVC().

Q: What is k-means clustering?
A: K-means is an unsupervised learning algorithm that partitions data into k clusters by iteratively assigning each point to the nearest centroid and then updating centroids to the mean of assigned points. It requires the number of clusters k to be specified in advance. In scikit-learn: KMeans(n_clusters=k).

Q: What is gradient descent?
A: Gradient descent is an optimization algorithm used to minimize the loss function by iteratively updating model parameters in the direction of the negative gradient. The learning rate controls the step size of each update. Variants include batch, stochastic (SGD), and mini-batch gradient descent.

Q: What is overfitting in machine learning?
A: Overfitting occurs when a model learns the noise and details of the training data too well, resulting in high accuracy on training data but poor performance on unseen data. Signs include a large gap between training and validation accuracy. Remedies include regularization, cross-validation, pruning, and using more training data.

Q: What is underfitting in machine learning?
A: Underfitting occurs when a model is too simple to capture the underlying patterns in the data, resulting in poor performance on both training and test data. This often happens when using an overly simple model or insufficient features. Remedies include using a more complex model, adding features, or reducing regularization.

Q: What is cross-validation?
A: Cross-validation is a technique for evaluating model performance by splitting data into multiple folds, training on some folds and testing on the remaining fold, then rotating. K-fold cross-validation is the most common variant. In scikit-learn: cross_val_score(model, X, y, cv=5). It provides a more robust estimate than a single train/test split.

Q: What is feature engineering?
A: Feature engineering is the process of creating, transforming, or selecting features (input variables) to improve model performance. Techniques include:
- Creating interaction features
- Binning continuous variables
- Encoding categorical variables (one-hot, label encoding)
- Extracting date/time components
Good feature engineering often has a bigger impact than algorithm choice.

Q: What is scikit-learn?
A: Scikit-learn is a popular open-source Python library for machine learning, built on NumPy, SciPy, and matplotlib. It provides simple and efficient tools for classification, regression, clustering, dimensionality reduction, and model evaluation. Models follow a consistent API: fit(), predict(), and transform().

Q: What is accuracy as a model evaluation metric?
A: Accuracy is the ratio of correct predictions to total predictions: accuracy = (TP + TN) / (TP + TN + FP + FN). While intuitive, accuracy can be misleading with imbalanced datasets—for example, a model predicting the majority class always can have high accuracy but be useless. Use precision, recall, or F1-score for imbalanced data.

Q: What is precision in classification?
A: Precision measures the proportion of positive predictions that are actually correct: precision = TP / (TP + FP). High precision means the model has a low false positive rate. Precision is important when the cost of false positives is high, such as in spam detection or medical diagnoses.

Q: What is recall (sensitivity) in classification?
A: Recall measures the proportion of actual positives that are correctly identified: recall = TP / (TP + FN). High recall means the model has a low false negative rate. Recall is critical when missing a positive case is costly, such as detecting cancer or fraud.

Q: What is the F1-score?
A: The F1-score is the harmonic mean of precision and recall: F1 = 2 * (precision * recall) / (precision + recall). It provides a single metric that balances both precision and recall, making it useful when you need a balance between the two and when dealing with imbalanced datasets. The F1-score ranges from 0 to 1.

Q: What is the bias-variance tradeoff?
A: The bias-variance tradeoff describes the tension between two sources of error:
- Bias: error from overly simple assumptions (underfitting)
- Variance: error from sensitivity to small fluctuations in training data (overfitting)
The goal is to find a model complexity that minimizes total error, which is the sum of bias², variance, and irreducible error.

Q: What is regularization in machine learning?
A: Regularization is a technique that adds a penalty term to the loss function to discourage overly complex models and prevent overfitting. L1 (Lasso) adds the sum of absolute weights and can produce sparse models. L2 (Ridge) adds the sum of squared weights and shrinks coefficients. Elastic Net combines both.

Q: What is an ensemble method?
A: An ensemble method combines multiple models to produce a stronger overall prediction than any individual model. Key approaches include:
- Bagging: trains models on random subsets (e.g., Random Forest)
- Boosting: trains models sequentially, focusing on errors (e.g., XGBoost, AdaBoost)
- Stacking: uses a meta-model to combine base model outputs

Q: What is hyperparameter tuning?
A: Hyperparameter tuning is the process of finding the optimal configuration settings that are set before training begins (not learned from data). Common methods include:
- Grid Search: exhaustive search over specified values
- Random Search: random sampling of parameter space
- Bayesian Optimization: informed search using past results
In scikit-learn: GridSearchCV() and RandomizedSearchCV().

Q: What is a confusion matrix?
A: A confusion matrix is a table that summarizes classification performance by showing counts of true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN). It helps visualize where the model makes errors. In scikit-learn: confusion_matrix(y_true, y_pred). From it, you can derive accuracy, precision, recall, and F1.

Q: What is an ROC curve?
A: An ROC (Receiver Operating Characteristic) curve plots the True Positive Rate (recall) against the False Positive Rate at various classification thresholds. A perfect classifier hugs the top-left corner. The diagonal line represents a random classifier. In scikit-learn: roc_curve(y_true, y_scores).

Q: What is AUC (Area Under the Curve)?
A: AUC measures the entire area under the ROC curve and provides an aggregate measure of classifier performance across all thresholds. An AUC of 1.0 indicates a perfect model, while 0.5 indicates a random classifier. AUC is threshold-independent and useful for comparing models. In scikit-learn: roc_auc_score(y_true, y_scores).

Q: What is backpropagation?
A: Backpropagation is the algorithm used to train neural networks by computing the gradient of the loss function with respect to each weight using the chain rule of calculus. Gradients are propagated backward from the output layer to the input layer, and weights are then updated using gradient descent. It is the foundation of deep learning training.

Q: What are activation functions in neural networks?
A: Activation functions introduce non-linearity into neural networks, enabling them to learn complex patterns. Common activation functions include:
- ReLU: max(0, x) — most widely used in hidden layers
- Sigmoid: outputs between 0 and 1 — used for binary classification output
- Tanh: outputs between -1 and 1
- Softmax: outputs probabilities for multi-class classification

Q: What is a loss function?
A: A loss function (or cost function) measures how far the model's predictions are from the actual values. The model is trained to minimize this function. Common loss functions include:
- MSE (Mean Squared Error) for regression
- Cross-Entropy for classification
- Hinge Loss for SVMs
The choice of loss function depends on the task.

Q: What is train/test split?
A: Train/test split is the practice of dividing a dataset into separate subsets for training and evaluation. A common split is 80/20 or 70/30. The model learns from the training set and is evaluated on the unseen test set to estimate generalization. In scikit-learn: train_test_split(X, y, test_size=0.2, random_state=42).

Q: What is the difference between normalization and standardization?
A: Normalization (Min-Max scaling) rescales features to a range of [0, 1]: (x - min) / (max - min). Standardization (Z-score scaling) transforms features to have mean 0 and standard deviation 1: (x - mean) / std. Use normalization when bounds matter, and standardization when the data follows a Gaussian distribution.

Q: What is PCA (Principal Component Analysis)?
A: PCA is an unsupervised dimensionality reduction technique that transforms data into a new set of orthogonal variables called principal components, ordered by the amount of variance they explain. It reduces the number of features while preserving as much variance as possible. In scikit-learn: PCA(n_components=2).fit_transform(X).

Q: What is a neural network?
A: A neural network is a computational model inspired by the brain, consisting of layers of interconnected nodes (neurons). It typically has an input layer, one or more hidden layers, and an output layer. Each connection has a weight that is adjusted during training. Neural networks can learn complex non-linear relationships in data.

Q: What is the kernel trick in SVM?
A: The kernel trick allows SVMs to operate in a high-dimensional feature space without explicitly computing the coordinates in that space. It replaces dot products with a kernel function (e.g., RBF, polynomial, sigmoid), enabling SVMs to find non-linear decision boundaries. In scikit-learn: SVC(kernel='rbf').

Q: What is gradient boosting?
A: Gradient boosting is an ensemble technique that builds models sequentially, where each new model corrects errors made by the previous ones by fitting to the residual errors. Popular implementations include XGBoost, LightGBM, and CatBoost. It typically achieves high accuracy but is prone to overfitting without proper tuning.

Q: What is the learning rate in gradient descent?
A: The learning rate is a hyperparameter that controls the step size during weight updates in gradient descent. A learning rate that is too large can cause the algorithm to overshoot the minimum, while one that is too small leads to slow convergence. Common practice is to start with values like 0.01 or 0.001 and use learning rate schedules.

Q: What is one-hot encoding?
A: One-hot encoding is a technique for converting categorical variables into binary vectors. Each category becomes a new binary feature column with a 1 indicating the presence of that category and 0 otherwise. For example, colors [red, blue, green] become three columns. In scikit-learn: OneHotEncoder() or in pandas: pd.get_dummies().

Q: What is the difference between bagging and boosting?
A: Bagging trains multiple models independently in parallel on random subsets of data and combines them (e.g., Random Forest). Boosting trains models sequentially, with each model focusing on the errors of the previous one (e.g., AdaBoost, XGBoost). Bagging reduces variance, while boosting reduces bias.

Q: What is k-nearest neighbors (KNN)?
A: KNN is a lazy learning algorithm that classifies a data point based on the majority class of its k nearest neighbors in feature space. It requires no training phase and stores the entire dataset. Distance metrics like Euclidean or Manhattan are used. In scikit-learn: KNeighborsClassifier(n_neighbors=5).

Q: What is the purpose of a validation set?
A: A validation set is a portion of the data used to tune hyperparameters and evaluate model performance during training, separate from both training and test sets. It helps in model selection and preventing overfitting to the test set. A typical split is 60% train, 20% validation, 20% test. Cross-validation can replace a fixed validation set.

Q: What is feature scaling and why is it important?
A: Feature scaling is the process of normalizing or standardizing input features so they are on a comparable scale. It is critical for algorithms that rely on distance calculations (KNN, SVM) or gradient-based optimization (neural networks, logistic regression). Without scaling, features with larger magnitudes can dominate the learning process.

Q: What is the sigmoid function?
A: The sigmoid function maps any real number to a value between 0 and 1 using the formula: σ(x) = 1 / (1 + e^(-x)). It is commonly used as the activation function in the output layer for binary classification and in logistic regression. A drawback is the vanishing gradient problem for very large or small inputs.

Q: What is ReLU (Rectified Linear Unit)?
A: ReLU is the most widely used activation function in neural networks, defined as f(x) = max(0, x). It outputs the input directly if positive, otherwise outputs zero. ReLU helps mitigate the vanishing gradient problem and enables faster training. A variant, Leaky ReLU, allows a small gradient for negative inputs: f(x) = max(0.01x, x).

Q: What is dropout in neural networks?
A: Dropout is a regularization technique that randomly sets a fraction of neuron outputs to zero during training, preventing the network from relying too heavily on specific neurons. A typical dropout rate is 0.2 to 0.5. This forces the network to learn more robust features. Dropout is disabled during inference (prediction).

Q: What is the difference between L1 and L2 regularization?
A: L1 regularization (Lasso) adds the sum of absolute weights to the loss, promoting sparsity by driving some weights to exactly zero (useful for feature selection). L2 regularization (Ridge) adds the sum of squared weights, which shrinks weights toward zero but rarely eliminates them entirely. L1 yields sparse models; L2 yields small but non-zero weights.

Q: What is mean squared error (MSE)?
A: MSE is a common loss function for regression that calculates the average of the squared differences between predicted and actual values: MSE = (1/n) * Σ(y_pred - y_actual)². It penalizes larger errors more heavily due to squaring. In scikit-learn: mean_squared_error(y_true, y_pred). A related metric is RMSE (root of MSE).

Q: What is cross-entropy loss?
A: Cross-entropy loss is the standard loss function for classification tasks. For binary classification: L = -[y·log(p) + (1-y)·log(1-p)]. It measures the difference between the predicted probability distribution and the actual labels. Lower values indicate better predictions. It is used with sigmoid (binary) or softmax (multi-class) output layers.

Q: What is the purpose of the softmax function?
A: The softmax function converts a vector of raw scores (logits) into a probability distribution where all values are between 0 and 1 and sum to 1. It is used in the output layer of multi-class classification neural networks. The formula is: softmax(z_i) = e^(z_i) / Σ(e^(z_j)). The class with the highest probability is the prediction.

Q: What is the elbow method in k-means clustering?
A: The elbow method helps determine the optimal number of clusters (k) by plotting the within-cluster sum of squares (WCSS) against different values of k. The optimal k is at the "elbow" point where adding more clusters no longer significantly reduces WCSS. It is a heuristic method and sometimes the elbow point is ambiguous.

Q: How do you handle missing data in machine learning?
A: Common strategies for handling missing data include:
- Removal: drop rows or columns with missing values
- Imputation: fill with mean, median, mode, or use algorithms like KNN imputation
- Indicator variables: add a binary column flagging missingness
In scikit-learn: SimpleImputer(strategy='mean'). The best approach depends on the amount and pattern of missingness.

Q: What is reinforcement learning?
A: Reinforcement learning is a machine learning paradigm where an agent learns to make decisions by performing actions in an environment to maximize a cumulative reward signal. The agent explores actions, receives feedback (reward or penalty), and updates its policy. Examples include game-playing AI (AlphaGo) and robotics control.

Q: What is semi-supervised learning?
A: Semi-supervised learning combines a small amount of labeled data with a large amount of unlabeled data during training. It is useful when labeling is expensive but unlabeled data is abundant. Common techniques include self-training, co-training, and graph-based label propagation. It often outperforms purely supervised learning when labels are scarce.

Q: What is a self-supervised learning?
A: Self-supervised learning is a paradigm where the model generates its own supervision signal from the input data, typically by predicting masked, missing, or transformed parts of the input. Examples include BERT (masked language modeling) and SimCLR (contrastive image representations). It bridges supervised and unsupervised learning and powers modern foundation models.

Q: What is multi-task learning?
A: Multi-task learning trains a single model to perform multiple related tasks simultaneously, sharing representations across them. By leveraging shared structure, it often improves generalization and reduces overfitting. Shared layers capture common features while task-specific heads produce distinct outputs. Common in NLP and computer vision.

Q: What is transfer learning?
A: Transfer learning is the practice of reusing a model pre-trained on one task as the starting point for a related task. It is especially powerful in deep learning where large pre-trained models (e.g., ResNet, BERT) are fine-tuned on smaller domain-specific datasets. It drastically reduces training time and data requirements.

Q: What is a perceptron?
A: A perceptron is the simplest artificial neuron, computing a weighted sum of inputs, adding a bias, and applying a step function as activation. It can only solve linearly separable problems (e.g., AND, OR) but cannot learn XOR. Stacking perceptrons in layers produces a multilayer perceptron (MLP).

Q: What is a multilayer perceptron (MLP)?
A: An MLP is a fully connected feedforward neural network with one or more hidden layers between the input and output layers. Each neuron applies a non-linear activation, enabling the network to learn complex non-linear mappings. MLPs are the foundation of deep learning and are trained with backpropagation.

Q: What is a convolutional neural network (CNN)?
A: A CNN is a neural network specialized for data with spatial structure (images, audio spectrograms). It uses convolutional layers with shared weights/kernels, pooling layers for downsampling, and fully connected layers at the end. CNNs dramatically reduce parameters versus MLPs and are state-of-the-art for image tasks.

Q: What is a recurrent neural network (RNN)?
A: An RNN is a neural network designed for sequential data where connections form directed cycles, allowing information to persist across timesteps. Hidden states act as memory. RNNs are used for time series, speech, and text, but suffer from vanishing/exploding gradients, motivating LSTM and GRU variants.

Q: What is an LSTM (Long Short-Term Memory)?
A: An LSTM is a type of RNN that uses gating mechanisms (input, forget, output gates) and a cell state to selectively remember or forget information over long sequences. It mitigates the vanishing gradient problem and captures long-range dependencies. LSTMs are widely used in NLP, speech recognition, and time-series forecasting.

Q: What is a GRU (Gated Recurrent Unit)?
A: A GRU is a simplified RNN variant that combines the forget and input gates of LSTM into a single update gate, and uses a reset gate. It has fewer parameters than LSTM, trains faster, and often performs comparably. GRUs are popular for smaller datasets and sequence-to-sequence tasks.

Q: What is the vanishing gradient problem?
A: The vanishing gradient problem occurs when gradients become extremely small during backpropagation through deep networks, causing early layers to learn very slowly or not at all. It is common with sigmoid/tanh activations and RNNs. Solutions include ReLU, batch normalization, residual connections, and LSTM/GRU architectures.

Q: What is the exploding gradient problem?
A: The exploding gradient problem occurs when gradients grow exponentially during backpropagation, causing unstable weight updates and divergence. Common in deep RNNs. The standard fix is gradient clipping, which caps gradient norms at a threshold. Proper weight initialization and learning rate scheduling also help.

Q: What is batch normalization?
A: Batch normalization is a technique that normalizes the inputs of each layer across a mini-batch to have roughly zero mean and unit variance, then applies learned scale and shift parameters. It stabilizes training, allows higher learning rates, and acts as a mild regularizer. Introduced by Ioffe & Szegedy in 2015.

Q: What is layer normalization?
A: Layer normalization normalizes activations across features within a single sample (rather than across the batch as in batch norm). It is independent of batch size, making it ideal for transformers, RNNs, and small-batch or online learning. It typically improves training stability.

Q: What is residual learning (ResNet)?
A: Residual learning introduces skip (shortcut) connections that let a layer learn a residual mapping F(x) added to the input: output = F(x) + x. This makes it easy for layers to learn identity mappings, enabling training of very deep networks (hundreds of layers). ResNet won ImageNet 2015.

Q: What is a transformer architecture?
A: A transformer is a neural network architecture based entirely on self-attention mechanisms, dispensing with recurrence and convolution. It processes all tokens in parallel and captures long-range dependencies efficiently. Transformers power BERT, GPT, T5, and most modern NLP/vision models. They scale well with data and compute.

Q: What is self-attention?
A: Self-attention is a mechanism where each token in a sequence computes a weighted sum of all tokens (including itself), with weights derived from learnable query, key, and value projections. It allows the model to dynamically focus on relevant context. The scaled dot-product form is: Attention(Q,K,V) = softmax(QKᵀ/√d) V.

Q: What is multi-head attention?
A: Multi-head attention runs multiple self-attention operations in parallel, each with its own learned projections, then concatenates and projects the results. It allows the model to attend to information from different representation subspaces simultaneously, capturing varied relationships. Most transformers use 8–16 heads.

Q: What is positional encoding?
A: Positional encoding adds information about token order to transformer inputs because self-attention is otherwise permutation-invariant. Common forms are fixed sinusoidal encodings (Vaswani et al.) and learned embeddings. Without it, the model cannot distinguish "dog bites man" from "man bites dog".

Q: What is BERT?
A: BERT (Bidirectional Encoder Representations from Transformers) is a transformer-based model pre-trained with masked language modeling and next sentence prediction. It reads text bidirectionally and excels at understanding tasks like classification, NER, and question answering. Fine-tuned BERT was state-of-the-art on many NLP benchmarks in 2018-2019.

Q: What is GPT?
A: GPT (Generative Pre-trained Transformer) is a decoder-only transformer model pre-trained with autoregressive language modeling (predicting the next token). Successive versions (GPT-2, GPT-3, GPT-4) scaled to hundreds of billions of parameters. GPT models are the basis for ChatGPT-style generative assistants.

Q: What is the encoder-decoder architecture?
A: An encoder-decoder (seq2seq) architecture maps an input sequence to an output sequence via two components: an encoder that compresses input into a context representation and a decoder that generates output tokens conditioned on that context. Used in machine translation, summarization, and image captioning. Transformers generalize this idea.

Q: What is tokenization in NLP?
A: Tokenization is the process of splitting raw text into smaller units called tokens (words, subwords, or characters). Modern NLP models commonly use subword tokenization schemes such as Byte-Pair Encoding (BPE), WordPiece, or SentencePiece, which balance vocabulary size with the ability to handle rare words and morphology.

Q: What is word embedding?
A: A word embedding is a dense, low-dimensional vector representation of words learned from text, where semantically similar words have similar vectors. Classic methods include Word2Vec and GloVe; modern approaches learn embeddings contextually inside transformers. Embeddings power most NLP downstream tasks.

Q: What is the difference between bag-of-words and TF-IDF?
A: Bag-of-words (BoW) represents a document by raw word counts, ignoring grammar and order. TF-IDF weights each term by its frequency in the document (TF) multiplied by the inverse of its frequency across documents (IDF), downweighting common words like "the". TF-IDF typically outperforms BoW for information retrieval and classical classification.

Q: What is Naive Bayes?
A: Naive Bayes is a probabilistic classifier based on Bayes' theorem with a (naive) assumption of feature independence. Despite the strong assumption, it works surprisingly well for text classification and spam filtering. Variants include Multinomial, Bernoulli, and Gaussian Naive Bayes.

Q: What is a Gaussian Mixture Model (GMM)?
A: A GMM assumes data is generated from a mixture of a finite number of Gaussian distributions with unknown parameters. It is fit via the Expectation-Maximization (EM) algorithm. GMMs generalize k-means by allowing soft, probabilistic cluster assignments and elliptical cluster shapes.

Q: What is DBSCAN?
A: DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a clustering algorithm that groups together points that are density-connected and marks points in low-density regions as outliers. Unlike k-means, it does not require specifying the number of clusters and can find arbitrarily shaped clusters.

Q: What is hierarchical clustering?
A: Hierarchical clustering builds a tree of clusters called a dendrogram. Agglomerative (bottom-up) starts with each point as its own cluster and merges the closest pairs iteratively. Divisive (top-down) starts with one cluster and splits. It does not require pre-specifying k but is computationally expensive: O(n²) memory.

Q: What is t-SNE?
A: t-SNE (t-Distributed Stochastic Neighbor Embedding) is a nonlinear dimensionality reduction technique primarily used for visualizing high-dimensional data in 2D or 3D. It preserves local neighborhoods by matching probability distributions over pairwise similarities. Use perplexity (typically 5–50) carefully; t-SNE is for visualization, not feature extraction.

Q: What is UMAP?
A: UMAP (Uniform Manifold Approximation and Projection) is a dimensionality reduction technique based on Riemannian geometry and topological data analysis. It is often faster and more global-structure-preserving than t-SNE and supports supervised and metric learning extensions. Outputs can also be used as features.

Q: What is the difference between generative and discriminative models?
A: Discriminative models learn the boundary between classes: P(y|x). Examples: logistic regression, SVMs, neural classifiers. Generative models learn the joint distribution P(x, y) or P(x|y), enabling them to sample new data. Examples: Naive Bayes, GANs, VAEs, language models.

Q: What is a GAN (Generative Adversarial Network)?
A: A GAN consists of two networks trained in opposition: a generator that creates fake samples from noise and a discriminator that tries to distinguish real from fake. Through adversarial training, the generator learns to produce increasingly realistic outputs. GANs power deepfakes, image synthesis (StyleGAN), and data augmentation.

Q: What is a VAE (Variational Autoencoder)?
A: A VAE is a generative model that learns a probabilistic latent space. The encoder maps input to a distribution (mean and variance), and the decoder reconstructs input from sampled latent codes. Trained by maximizing the ELBO (evidence lower bound). VAEs produce blurry but diverse samples and enable smooth latent-space interpolation.

Q: What is data augmentation?
A: Data augmentation artificially expands the training set by applying label-preserving transformations (rotations, flips, crops, color jitter for images; synonym replacement, back-translation for text). It reduces overfitting, improves generalization, and is essential when data is scarce. Modern pipelines use libraries like imgaug, albumentations, or torchvision.transforms.

Q: What is a learning curve?
A: A learning curve is a plot of a performance metric (loss or accuracy) on the y-axis against training iteration or dataset size on the x-axis. Comparing training vs. validation curves diagnoses bias/variance problems. A large gap signals overfitting; both curves plateaued at low performance signal underfitting.

Q: What is early stopping?
A: Early stopping is a regularization technique that halts training when validation performance stops improving for a specified number of epochs (patience). It prevents overfitting and saves compute. The best model checkpoint is usually restored. Most deep learning libraries (Keras, PyTorch Lightning) provide built-in early-stopping callbacks.

Q: What is the learning rate schedule?
A: A learning rate schedule adjusts the learning rate during training according to a predefined rule. Common strategies include step decay, exponential decay, cosine annealing, and warm restarts. Scheduling often yields faster convergence and better final performance than a fixed learning rate.

Q: What is the Adam optimizer?
A: Adam (Adaptive Moment Estimation) is an optimization algorithm that combines momentum (first moment) with RMSProp-style adaptive learning rates (second moment). It maintains per-parameter learning rates and works well across many deep learning tasks with default hyperparameters (lr=1e-3, beta1=0.9, beta2=0.999).

Q: What is SGD with momentum?
A: SGD with momentum adds a fraction of the previous update to the current gradient update: v = β·v + ∇L; θ -= lr·v. The momentum term β (typically 0.9) accelerates convergence through ravines, dampens oscillations, and helps escape shallow local minima. It often outperforms vanilla SGD and even Adam on some tasks.

Q: What is weight initialization?
A: Weight initialization sets the starting values of network parameters and significantly affects training. Poor initialization can cause vanishing/exploding gradients. Common schemes include Xavier/Glorot (for tanh/sigmoid) and He/Kaiming (for ReLU). Modern frameworks like PyTorch and TensorFlow apply appropriate defaults automatically.

Q: What is Xavier initialization?
A: Xavier (Glorot) initialization sets weights drawn from a distribution with variance 2 / (fan_in + fan_out), where fan_in and fan_out are the numbers of incoming and outgoing connections. It keeps activations and gradients at reasonable scales for tanh/sigmoid activations, helping deep networks train stably.

Q: What is He initialization?
A: He (Kaiming) initialization is designed for ReLU activations and sets weight variance to 2 / fan_in. It accounts for ReLU zeroing half the activations on average and is the default for ReLU-based CNNs and MLPs. It enables training of very deep networks like ResNets.

Q: What is the MAE (Mean Absolute Error)?
A: MAE is a regression metric equal to the average absolute difference between predictions and actuals: MAE = (1/n)·Σ|y_pred − y_actual|. Unlike MSE, MAE is less sensitive to outliers because errors are not squared. Reported in the same units as the target variable, making it intuitive to interpret.

Q: What is the R-squared metric?
A: R² (coefficient of determination) measures the proportion of variance in the target explained by the model: R² = 1 − SS_res / SS_tot. It ranges from -∞ to 1; 1 indicates perfect prediction, 0 means the model is no better than predicting the mean, and negative values indicate worse-than-mean predictions.

Q: What is the adjusted R-squared?
A: Adjusted R² modifies R² to penalize adding irrelevant features: 1 − (1−R²)·(n−1)/(n−p−1), where p is the number of predictors and n samples. Unlike R², it can decrease when unhelpful features are added, making it more honest for model comparison.

Q: What is the silhouette score?
A: The silhouette score measures clustering quality on a scale of -1 to 1. For each point, it combines cohesion (mean distance to points in its cluster) and separation (mean distance to nearest other cluster). Values near +1 indicate well-clustered points; near 0 indicates overlapping clusters; negative suggests mis-assignment.

Q: What is Cohen's Kappa?
A: Cohen's Kappa is a classification metric that adjusts accuracy for agreement that could occur by chance: κ = (p_o − p_e) / (1 − p_e). Values above 0.8 indicate strong agreement. It is especially useful for imbalanced classes where raw accuracy can be misleading.

Q: What is the log loss?
A: Log loss (logistic loss / cross-entropy) measures the negative log-likelihood of predicted probabilities: L = −(1/n)·Σ[y·log(p) + (1−y)·log(1−p)]. It heavily penalizes confident wrong predictions and is the standard training objective for probabilistic classifiers. Lower is better; 0 is perfect.

Q: What is the BLEU score?
A: BLEU (Bilingual Evaluation Understudy) measures the similarity between machine-generated and reference text by counting overlapping n-grams (typically 1–4) with a brevity penalty. It ranges 0–1 (or 0–100). It is the standard metric for machine translation, though it has known weaknesses for paraphrases.

Q: What is ROUGE?
A: ROUGE (Recall-Oriented Understudy for Gisting Evaluation) is a family of metrics for evaluating summarization and other text generation tasks. ROUGE-N measures n-gram recall; ROUGE-L uses longest common subsequence. Higher scores indicate greater overlap with reference summaries.

Q: What is perplexity?
A: Perplexity is a standard metric for language models: PPL = exp(−(1/n)·Σ log p(w_i)). It measures how well the model predicts the next token, with lower values indicating better performance. A perplexity of k means the model is as uncertain as choosing uniformly among k options.

Q: What is the BLEU vs ROUGE distinction?
A: BLEU measures precision — what fraction of generated n-grams appear in references — penalizing verbose outputs. ROUGE measures recall — what fraction of reference n-grams appear in the output — penalizing missing content. BLEU is standard for translation; ROUGE is standard for summarization.

Q: What is class imbalance and how do you handle it?
A: Class imbalance occurs when one class has far more samples than others, biasing models toward the majority class. Common remedies include resampling (oversample minority via SMOTE or undersample majority), class weighting in the loss, threshold tuning, and using metrics like F1/AUC instead of accuracy.

Q: What is SMOTE?
A: SMOTE (Synthetic Minority Over-sampling Technique) addresses class imbalance by creating synthetic minority samples along line segments joining existing minority instances and their k-nearest neighbors. It increases minority class representation without simple duplication, reducing overfitting compared to naive oversampling.

Q: What is feature selection?
A: Feature selection picks a subset of relevant features for modeling, reducing dimensionality, noise, and overfitting while improving interpretability and speed. Methods include filter (correlation, chi-square, mutual information), wrapper (recursive feature elimination, forward selection), and embedded (Lasso, tree importances).

Q: What is mutual information for feature selection?
A: Mutual information (MI) measures the non-linear dependency between a feature and the target, capturing relationships that correlation misses. In scikit-learn, SelectKBest(mutual_info_classif, k=10) selects the top-k features by MI. It works for both classification and regression tasks.

Q: What is recursive feature elimination (RFE)?
A: RFE is a wrapper feature selection method that recursively trains a model, removes the least important features (e.g., lowest coefficients or importances), and repeats until the desired number remains. It is computationally expensive but accurate. RFE(estimator, n_features_to_select=10) in scikit-learn.

Q: What is a pipeline in scikit-learn?
A: A scikit-learn Pipeline chains a sequence of transformers and a final estimator into a single object. It ensures that the same preprocessing steps (scaling, encoding, imputation) are consistently applied during training and prediction, preventing data leakage. make_pipeline is a convenience constructor.

Q: What is data leakage in machine learning?
A: Data leakage occurs when information from outside the training set leaks into the model, giving unrealistically good training/validation scores but poor real-world performance. Common causes include fitting preprocessing (scaling, imputation) on the full dataset before splitting, target leakage from future data, or duplicate rows across splits.

Q: What is the curse of dimensionality?
A: The curse of dimensionality describes problems that arise when data lives in high-dimensional spaces: distances become less meaningful, data becomes sparse, and the volume of space grows exponentially. Effects include degraded nearest-neighbor methods, overfitting, and the need for exponentially more data. Dimensionality reduction (PCA, UMAP) helps.

Q: What is the curse of dimensionality — practical implication for KNN?
A: In high dimensions, all points become roughly equidistant from a query, making KNN's notion of "nearest neighbor" unreliable. Performance of KNN degrades sharply beyond ~20 dimensions unless feature selection or embeddings reduce effective dimensionality. Scaling features is also crucial.

Q: What is a convolutional layer?
A: A convolutional layer applies learnable filters (kernels) that slide across the input, computing dot products to produce feature maps. Kernels share weights across spatial positions, drastically reducing parameters versus dense layers and exploiting translation equivariance. Common kernel sizes are 3×3 and 5×5.

Q: What is pooling in CNNs?
A: Pooling downsamples feature maps to reduce spatial size, computation, and overfitting. Max pooling takes the maximum value in each window (typically 2×2, stride 2). Average pooling takes the mean. Modern architectures sometimes use strided convolutions instead of pooling.

Q: What is a fully connected layer?
A: A fully connected (dense) layer connects every input neuron to every output neuron, multiplying by a weight matrix and adding a bias. It is typically used at the end of CNNs and MLPs to combine learned features for final prediction. The parameter count is large: in_features × out_features.

Q: What is the receptive field?
A: The receptive field is the region of the input that influences a particular neuron. In CNNs, deeper neurons have larger receptive fields, allowing them to capture more global patterns. Dilated convolutions and pooling can rapidly enlarge the receptive field without adding parameters.

Q: What is a generative pre-trained model?
A: A generative pre-trained model is first self-supervised on massive data (often predicting the next token or masked tokens) and then fine-tuned or prompted for downstream tasks. Examples include the GPT family and T5. They form the basis of foundation models that transfer broadly.

Q: What is in-context learning?
A: In-context learning is the ability of large language models to perform new tasks from examples given in the prompt without any weight updates. Given a few demonstrations, the model infers the pattern and continues. It is an emergent property of scale and differs from traditional fine-tuning.

Q: What is prompt engineering?
A: Prompt engineering is the practice of crafting inputs to a language model to elicit desired outputs. Techniques include few-shot examples, chain-of-thought reasoning ("let's think step by step"), role assignment, and structured output formatting. It is a key skill for using LLMs without fine-tuning.

Q: What is fine-tuning?
A: Fine-tuning takes a pre-trained model and continues training it on task-specific labeled data to specialize its behavior. Full fine-tuning updates all weights; parameter-efficient methods like LoRA only update small adapter matrices, dramatically reducing compute and storage costs.

Q: What is LoRA?
A: LoRA (Low-Rank Adaptation) fine-tunes large models by freezing the original weights and injecting trainable low-rank matrices into transformer layers. It reduces the number of trainable parameters by 10×–10000× while matching full fine-tuning quality. Multiple LoRA adapters can be swapped for different tasks.

Q: What is the difference between fine-tuning and RAG?
A: Fine-tuning updates model weights to bake knowledge or style into the model — expensive and static. RAG (Retrieval-Augmented Generation) keeps the model fixed and instead retrieves relevant documents at inference, feeding them into the prompt. RAG is cheap, up-to-date, and reduces hallucination.

Q: What is RAG?
A: RAG (Retrieval-Augmented Generation) augments an LLM's answers by retrieving external documents (typically via vector search) and including them in the prompt. It grounds responses in up-to-date, verifiable sources, reducing hallucination. Common components: chunking, embedding, vector store, retriever, generator.

Q: What is a vector database?
A: A vector database stores and indexes high-dimensional embeddings for efficient similarity search (usually nearest neighbor via cosine or dot product). Examples include FAISS, Pinecone, Weaviate, Milvus, and Qdrant. They power semantic search, RAG, recommendation systems, and image retrieval.

Q: What is cosine similarity?
A: Cosine similarity measures the angle between two vectors, ignoring magnitude: cos(A,B) = (A·B) / (‖A‖·‖B‖). It ranges from -1 to 1. It is widely used for comparing text embeddings and recommender systems because it focuses on directional similarity rather than absolute values.

Q: What is approximate nearest neighbor (ANN) search?
A: ANN search trades exactness for massive speedups in finding nearest neighbors in high-dimensional spaces. Algorithms include HNSW, IVF, and LSH. Vector databases implement ANN to support billion-scale retrieval in milliseconds, at the cost of slightly reduced recall.

Q: What is HNSW?
A: HNSW (Hierarchical Navigable Small World) is a graph-based ANN algorithm that builds a multi-layer proximity graph. Queries greedily traverse from coarse top layers to fine bottom layers. It offers excellent speed/recall trade-offs and is the default in many vector databases (e.g., Qdrant, Weaviate, pgvector).

Q: What is embedding fine-tuning?
A: Embedding fine-tuning adjusts pre-trained embeddings (e.g., BERT, sentence-transformers) on a domain-specific dataset so they better reflect task-relevant similarity. Contrastive losses like InfoNCE are commonly used. It is essential for domain-specific RAG and semantic search where off-the-shelf embeddings miss nuance.

Q: What is contrastive learning?
A: Contrastive learning trains representations by pulling similar pairs together and pushing dissimilar pairs apart in embedding space. Losses include InfoNCE, triplet loss, and SupCon. It is the foundation of modern self-supervised methods (SimCLR, MoCo, CLIP) and metric-learning systems like face recognition.

Q: What is CLIP?
A: CLIP (Contrastive Language-Image Pre-training) trains an image encoder and text encoder jointly to align images with their captions using a contrastive InfoNCE loss on a huge image-text dataset. The aligned space enables zero-shot image classification from natural-language prompts and powers text-to-image systems like DALL·E.

Q: What is diffusion model?
A: A diffusion model is a generative model that learns to reverse a gradual noising process. During training, real data is corrupted with noise step by step; the model learns to predict and remove the noise. At inference, it generates samples by denoising from pure noise. Stable Diffusion and DALL·E 2 are diffusion-based image generators.

Q: What is the difference between VAE, GAN, and diffusion?
A: VAEs maximize a variational lower bound; produce blurry but diverse samples; fast sampling. GANs use adversarial training; produce sharp samples but can be unstable and mode-collapse prone. Diffusion models iteratively denoise; produce high-quality, diverse samples but require many sampling steps. Diffusion currently leads in image synthesis.

Q: What is a Boltzmann machine?
A: A Boltzmann machine is a network of symmetrically connected stochastic units that learn a probability distribution over inputs by adjusting weights via energy-based learning. The restricted Boltzmann machine (RBM) has only visible/hidden connections (no intra-layer), enabling efficient contrastive divergence training. RBMs were foundational for deep belief nets.

Q: What is word2vec?
A: Word2Vec is a family of shallow neural embedding models (CBOW and Skip-gram) trained on large text corpora to produce dense word embeddings. Skip-gram predicts context words from a center word and famously captures relationships like king − man + woman ≈ queen. It popularized geometric reasoning over word meanings.

Q: What is GloVe?
A: GloVe (Global Vectors for Word Representation) learns word embeddings by factorizing the global co-occurrence matrix of words. It combines the strengths of global matrix factorization and local context-window methods (like Word2Vec), producing embeddings that capture both semantic and syntactic analogies efficiently.

Q: What is the difference between stemming and lemmatization?
A: Stemming crudely chops word endings to a rough root (e.g., "running" → "run", "flies" → "fli"). Lemmatization uses vocabulary and morphological analysis to return a proper dictionary form ("flies" → "fly"). Lemmatization is more accurate but slower; stemming is faster but may produce non-words.

Q: What is NER (Named Entity Recognition)?
A: NER is the NLP task of locating and classifying named entities in text into categories like person, organization, location, date, monetary value. It is a sequence-labeling problem often solved with CRF, BiLSTM-CRF, or transformer models (e.g., BERT). NER is foundational for information extraction and knowledge graph construction.

Q: What is part-of-speech (POS) tagging?
A: POS tagging assigns a grammatical category (noun, verb, adjective, etc.) to each token in a sentence. Modern taggers use neural sequence models, often BiLSTMs or transformers, and reach 97%+ accuracy on English. POS tags are features for parsing, NER, and many downstream NLP tasks.

Q: What is dependency parsing?
A: Dependency parsing analyzes the grammatical structure of a sentence by linking words into directed typed dependencies (head–dependent relations). It produces a tree that captures subject–verb, modifier, etc. relations. Modern parsers (e.g., spaCy's parser) use neural transition systems or graph-based models.

Q: What is sentiment analysis?
A: Sentiment analysis classifies the polarity of text (positive, negative, neutral), sometimes also emotions or aspect-level opinions. Approaches range from lexicon-based (VADER, AFINN) to classical ML (TF-IDF + logistic regression) to fine-tuned transformers. It is widely used for brand monitoring, reviews, and social media analysis.

Q: What is named entity disambiguation?
A: Entity disambiguation (entity linking) maps a mention in text to a specific entity in a knowledge base, distinguishing e.g., "Apple" (the company) from "apple" (the fruit). It requires candidate generation, embedding-based comparison, and contextual reasoning. It is key for populating knowledge graphs.

Q: What is YOLO?
A: YOLO (You Only Look Once) is a family of real-time object detection models that frame detection as a single regression problem: a CNN predicts bounding boxes and class probabilities directly from a full image in one forward pass. It is extremely fast (30–150+ FPS) and widely used in autonomous driving, robotics, and surveillance.

Q: What is a segmentation model?
A: Segmentation models classify each pixel in an image. Semantic segmentation assigns a class label to every pixel (e.g., U-Net, DeepLab). Instance segmentation additionally distinguishes individual object instances (e.g., Mask R-CNN). They are foundational for medical imaging, autonomous driving, and scene understanding.

Q: What is U-Net?
A: U-Net is a CNN architecture for image segmentation with a symmetric encoder–decoder shape and skip connections that pass high-resolution features from encoder to decoder. Originally designed for biomedical segmentation, it is widely used wherever dense per-pixel prediction is needed, often with very few training images.

Q: What is Mask R-CNN?
A: Mask R-CNN extends Faster R-CNN by adding a parallel branch that predicts a binary mask for each detected object. It performs instance segmentation: detecting each object and producing its pixel-level mask. It is widely used in applications requiring precise object outlines (e.g., robotics, biology, AR).

Q: What is a recommendation system?
A: A recommendation system predicts user preferences and suggests relevant items (products, movies, songs). Approaches include collaborative filtering (using user-item interactions), content-based (using item features), and hybrid methods. Matrix factorization and deep models (two-tower, NCF) are common backbones.

Q: What is collaborative filtering?
A: Collaborative filtering recommends items based on patterns in user-item interactions, without needing item features. User-based finds similar users; item-based finds similar items. Matrix factorization (e.g., SVD, ALS) learns latent factors for users and items. It struggles with cold-start users/items.

Q: What is matrix factorization for recommendations?
A: Matrix factorization decomposes the user-item interaction matrix R ≈ U·Vᵀ into low-rank user and item matrices whose dot products approximate observed ratings. It captures latent preferences and enables efficient recommendations. It was popularized by the Netflix Prize and is a foundation of modern recommender systems.

Q: What is a time series forecast?
A: Time series forecasting predicts future values of a sequence from its past observations. Classical methods include ARIMA, Exponential Smoothing (ETS), and Prophet. Modern approaches use RNNs, LSTMs, Temporal Convolutional Networks (TCN), and transformer-based models (e.g., Informer, PatchTST). Evaluation uses rolling-origin cross-validation.

Q: What is ARIMA?
A: ARIMA (AutoRegressive Integrated Moving Average) is a classical time series model combining autoregression (AR), differencing (I), and moving average (MA) components. It is specified by orders (p, d, q). ARIMA assumes stationarity and works well for univariate series with linear patterns but struggles with nonlinear or multivariate data.

Q: What is Prophet?
A: Prophet is an open-source forecasting library from Meta designed for business time series with daily seasonality, holidays, and trend changes. It decomposes series into trend, seasonality, and holiday components and fits quickly via Bayesian-style optimization. It is robust to missing data and outliers and is accessible to non-experts.

Q: What is the difference between stationarity and seasonality?
A: A time series is stationary if its statistical properties (mean, variance, autocorrelation) do not change over time. Seasonality refers to regular periodic patterns (e.g., daily, weekly, yearly). Stationarity is an assumption of many models; seasonality is a feature to be modeled or removed (e.g., via differencing or seasonal decomposition).

Q: What is autocorrelation (ACF)?
A: Autocorrelation measures the correlation between a time series and a lagged version of itself. The ACF plot shows correlations for various lags, helping identify seasonality, trend, and suitable lag features. PACF (partial ACF) helps determine ARIMA orders.

Q: What is an outlier in machine learning?
A: An outlier is a data point that significantly deviates from the rest of the distribution. Outliers can be data errors (should be removed/corrected) or genuine rare events (worth keeping or modeling). Robust algorithms (e.g., RANSAC, Huber loss, isolation forest) are less sensitive to outliers.

Q: What is an Isolation Forest?
A: Isolation Forest is an anomaly detection algorithm that isolates observations by randomly selecting features and split values. Anomalies are isolated quickly (short paths in random trees), so short average path lengths indicate outliers. It scales linearly with data size and is widely used for fraud and intrusion detection.

Q: What is one-class SVM?
A: One-class SVM is an anomaly detection method that learns a boundary around normal data in feature space using a kernel (usually RBF). Points outside the boundary are flagged as anomalies. It is useful when only "normal" examples are available for training and is implemented as OneClassSVM in scikit-learn.

Q: What is the difference between L1 and L2 loss?
A: L1 loss (MAE) is the absolute error and is robust to outliers but not differentiable at zero. L2 loss (MSE) is the squared error and is smooth everywhere but heavily penalizes outliers due to squaring. Huber loss combines both: quadratic for small errors, linear for large ones.

Q: What is Huber loss?
A: Huber loss combines L1 and L2: L_δ(a) = ½a² if |a|≤δ, else δ(|a|−½δ). It behaves like MSE for small errors (smooth gradient) and like MAE for large errors (robustness to outliers). It is widely used in regression tasks with noisy data, including in many RL algorithms.

Q: What is label smoothing?
A: Label smoothing is a regularization technique that replaces hard one-hot labels with a smoothed distribution (e.g., 0.9 for the true class, 0.1 spread across others). It prevents the model from becoming overconfident, improves calibration, and often boosts generalization in classification and language modeling.

Q: What is knowledge distillation?
A: Knowledge distillation trains a small student model to mimic a larger, well-performing teacher model. The student is trained on a combination of the true labels and the teacher's soft probability outputs, which carry richer information about inter-class similarities. It enables model compression for deployment.

Q: What is model quantization?
A: Quantization reduces the numerical precision of model weights and/or activations (e.g., from float32 to int8), shrinking model size and speeding up inference, often with minimal accuracy loss. Post-training quantization converts after training; quantization-aware training simulates low precision during training for better results.

Q: What is pruning in neural networks?
A: Pruning removes unimportant weights, neurons, or layers from a trained network to reduce size and compute. Magnitude pruning zeros small weights; structured pruning removes whole filters/channels. Combined with fine-tuning, pruning can shrink models by 50–90% with little accuracy loss.

Q: What is ONNX?
A: ONNX (Open Neural Network Exchange) is an open format for representing ML models, enabling interoperability between frameworks (PyTorch, TensorFlow, scikit-learn). Models can be exported to ONNX and run on optimized runtimes (ONNX Runtime, TensorRT) across platforms, simplifying deployment.

Q: What is MLflow?
A: MLflow is an open-source platform for managing the end-to-end machine learning lifecycle: experiment tracking, model packaging, model registry, and deployment. It logs parameters, metrics, and artifacts for reproducibility. It integrates with most ML frameworks and is widely used in production ML pipelines.

Q: What is a feature store?
A: A feature store is a centralized repository that stores, manages, and serves features for ML training and inference, ensuring consistency between offline and online environments. Examples include Feast, Tecton, and Hopsworks. It solves the "training-serving skew" problem by maintaining a single source of truth for features.

Q: What is a data drift?
A: Data (or covariate) drift occurs when the statistical distribution of input features changes between training and deployment, degrading model performance. Monitoring drift (e.g., via PSI or KS tests) and retraining models are standard mitigations. Drift is a major concern in production ML systems.

Q: What is concept drift?
A: Concept drift occurs when the relationship between features and the target changes over time (e.g., user preferences shift). It requires models to be continuously updated. Detection methods track performance metrics over time; mitigation strategies include sliding-window retraining, online learning, and ensemble weighting.

Q: What is the difference between data and concept drift?
A: Data drift (covariate drift): input distribution P(X) changes. Concept drift: the conditional distribution P(Y|X) changes — same input, different correct answer. Both cause model degradation but require different responses; concept drift is often subtler and harder to detect without ground truth labels.

Q: What is A/B testing in ML?
A: A/B testing in ML compares two model variants by randomly assigning users to each and measuring a business or engagement metric (not just offline accuracy). It is the gold standard for validating that a new model actually improves outcomes in production. Statistical significance and proper randomization are essential.