Skip to content

Apple Data Science Interview Questions & Answers

Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.

Solved for AppleStart practicing
3 QUESTIONS FREESign up or log in to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

What is cross-validation and why use it?

AppleEasy
Save to ▾
Show answer
Split the data into k folds, train on k−1 folds and validate on the remaining one, rotate and average the scores. It gives a more reliable estimate than one split and helps tune hyperparameters without touching the test set.
02

What are *args and **kwargs?

AppleEasy
Save to ▾
Show answer
*args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dict. They make function signatures flexible and are common in wrappers and decorators.
03

CNN vs RNN vs Transformer — what is the difference?

AppleHard
Save to ▾
Show answer
CNNs use convolutions to find spatial patterns (images). RNNs/LSTMs process sequences step by step but struggle with long context. Transformers use self-attention to look at all tokens at once — parallel and better at long-range context; they power modern LLMs.
04

Why is XGBoost so popular?

AppleMedium
Save to ▾
Show answer
It combines gradient boosting with regularisation, handling of missing values, parallel tree construction and speed optimisations, and it performs strongly on tabular data.
05

What is a RAG system and why use it?

AppleHard
Save to ▾
Show answer
Retrieval-Augmented Generation fetches relevant documents and gives them to an LLM as context, reducing hallucination and keeping answers grounded in current private data.
06

What is batch normalisation?

AppleMedium
Save to ▾
Show answer
It normalises layer inputs per mini-batch and then rescales them, stabilising and speeding up training and allowing higher learning rates.
07

What is the Central Limit Theorem?

AppleMedium
Save to ▾
Show answer
The distribution of sample means approaches a normal distribution as the sample size grows (roughly 30+), whatever the population's shape. It lets us build confidence intervals and run hypothesis tests on means.
08

What are precision and recall trade-offs in practice?

AppleMedium
Save to ▾
Show answer
Raising the threshold improves precision but lowers recall. Fraud detection leans to recall, while spam filters often prefer precision; choose by the cost of each error.
09

What is the vanishing gradient problem?

AppleMedium
Save to ▾
Show answer
Gradients shrink as they pass through many layers (for example with sigmoid), so early layers barely learn. ReLU, residual connections and good initialisation help.
10

What is a confidence interval?

AppleMedium
Save to ▾
Show answer
A range built from sample data that would contain the true parameter in a stated percentage (for example 95%) of repeated samples. It is not the probability that the parameter lies inside this one interval.
11

How does a CNN work?

AppleMedium
Save to ▾
Show answer
Convolution filters slide over the input to detect local patterns, pooling reduces size, and deeper layers combine edges into shapes and objects. Used mainly for images.
12

What is sampling bias and how can you reduce it?

AppleMedium
Save to ▾
Show answer
Bias occurs when the sample does not represent the population. Reduce it with random or stratified sampling, higher response rates and by checking sample demographics against the population.
13

Type I vs Type II error?

AppleEasy
Save to ▾
Show answer
Type I = false positive (rejecting a true null), probability α. Type II = false negative (missing a real effect), probability β. Power = 1 − β.
14

How do you design an A/B test?

AppleHard
Save to ▾
Show answer
Define the hypothesis and one primary metric, calculate sample size from the baseline, minimum detectable effect, α and power, randomise users, run for full business cycles, check for sample-ratio mismatch, then test both statistical and practical significance.
15

Random forest vs a single decision tree?

AppleMedium
Save to ▾
Show answer
A forest averages many trees trained on bootstrapped rows and random feature subsets, which cuts variance and overfitting at the cost of interpretability.
16

What is standard deviation and what does it tell you?

AppleEasy
Save to ▾
Show answer
The square root of the variance; it measures how far values typically sit from the mean, in the same units as the data.
17

L1 vs L2 regularisation?

AppleMedium
Save to ▾
Show answer
L1 (Lasso) adds absolute weights and can shrink some to zero, giving feature selection. L2 (Ridge) adds squared weights and shrinks them smoothly without removing features.
18

What is gradient descent and what does the learning rate do?

AppleMedium
Save to ▾
Show answer
An optimisation method that updates weights in the opposite direction of the loss gradient. The learning rate sets the step size: too high and it diverges, too low and it is slow. Variants include SGD, mini-batch and Adam.
19

Explain the KNN algorithm and its drawbacks.

AppleMedium
Save to ▾
Show answer
It predicts from the k nearest labelled points. It is simple but slow at prediction time, sensitive to scaling and irrelevant features, and weak in high dimensions.
20

How does the Gini impurity differ from entropy?

AppleMedium
Save to ▾
Show answer
Both measure node impurity; Gini is cheaper to compute and entropy is slightly more sensitive to class balance, with similar trees in practice.
21

What is the attention mechanism?

AppleMedium
Save to ▾
Show answer
It lets a model weigh which input positions matter most for each output, computing weighted combinations of values from query-key similarity. It is the core of transformers.
22

How do you deal with high-cardinality categorical features?

AppleMedium
Save to ▾
Show answer
Use target or frequency encoding with cross-validation, hashing, embeddings or grouping rare categories, instead of huge one-hot matrices.
23

What is a generator and when would you use one?

AppleMedium
Save to ▾
Show answer
A function using yield that produces values lazily, one at a time. It saves memory when processing large files or streams because the full sequence is never held in RAM.
24

What is PCA and when do you use it?

AppleMedium
Save to ▾
Show answer
It projects data onto orthogonal directions of maximum variance to reduce dimensions, remove correlation and speed up models, at some cost of interpretability.
25

What is data leakage?

AppleEasy
Save to ▾
Show answer
Information from outside the training window, such as future data or test statistics, enters training and inflates performance. Split first, then fit scalers and encoders on training data only.
26

What is a p-value?

AppleMedium
Save to ▾
Show answer
The probability of seeing a result at least as extreme as the observed one if the null hypothesis were true. A small p-value is evidence against the null, not proof that the alternative is true.
27

How does K-means clustering work and how do you choose k?

AppleMedium
Save to ▾
Show answer
It assigns points to the nearest centroid and updates centroids until stable. Choose k with the elbow method, silhouette score or business context.
28

Explain train, validation and test sets.

AppleEasy
Save to ▾
Show answer
Train fits the model, validation tunes hyperparameters and model choice, and the untouched test set gives a final unbiased estimate of performance.
29

How do you choose a learning rate for a neural network?

AppleMedium
Save to ▾
Show answer
Start with a sensible default such as 1e-3 for Adam, run a learning-rate range test, and use schedulers or warm-up while watching the loss curve.
30

How would you optimise a slow Pandas pipeline on a 5 GB file?

AppleHard
Save to ▾
Show answer
Read in chunks or use usecols and dtypes, convert strings to category, avoid apply with row loops in favour of vectorised ops, and consider Polars, Dask or Parquet storage.
31

What is NumPy broadcasting?

AppleEasy
Save to ▾
Show answer
The rule that lets arrays of different shapes operate together by virtually stretching the smaller one, for example adding a scalar or a (3,) vector to a (4,3) matrix.
32

Design an end-to-end churn prediction system.

AppleHard
Save to ▾
Show answer
Define churn and the prediction window → build usage and billing features → handle imbalance → train gradient boosting → evaluate with PR-AUC and lift → explain with SHAP → deploy as batch scoring or an API → monitor drift → hand top-risk users to the retention team.
33

Pandas: find the top 3 products by revenue in each region.

AppleMedium
Save to ▾
Show answer
(df.assign(rev=df.price * df.qty) .groupby(['region', 'product'])['rev'].sum() .reset_index() .sort_values('rev', ascending=False) .groupby('region').head(3))
34

How do you handle imbalanced classes?

AppleMedium
Save to ▾
Show answer
Use stratified splits, class weights, resampling such as SMOTE, threshold tuning and judge models with precision, recall, F1 or PR-AUC instead of accuracy.
35

What is the difference between bagging and boosting?

AppleEasy
Save to ▾
Show answer
Bagging trains models in parallel on bootstrap samples and averages them (reduces variance, e.g. Random Forest). Boosting trains models one after another, each fixing the previous errors (reduces bias, e.g. XGBoost).
36

What is the bias–variance trade-off?

AppleMedium
Save to ▾
Show answer
Bias is error from overly simple assumptions (underfitting). Variance is sensitivity to the training data (overfitting). More model complexity lowers bias but raises variance — aim for the lowest total error using cross-validation and regularization.
37

What is the difference between an epoch, a batch and an iteration?

AppleMedium
Save to ▾
Show answer
An epoch is one pass over the training data; a batch is the subset used for one update; an iteration is one weight update on a batch.
38

Explain ROC curve and AUC.

AppleMedium
Save to ▾
Show answer
The ROC curve plots true positive rate against false positive rate across thresholds. AUC is the probability that a random positive is ranked above a random negative; 0.5 is chance.
39

What is TF-IDF?

AppleMedium
Save to ▾
Show answer
Term Frequency × Inverse Document Frequency: a word scores high if it is frequent in one document but rare across all documents. A classic way to turn text into numeric features.
40

How do you detect outliers?

AppleMedium
Save to ▾
Show answer
Use the IQR rule (below Q1-1.5 IQR or above Q3+1.5 IQR), z-scores beyond 3, box plots or model-based methods such as Isolation Forest, then decide whether to cap, remove or keep them.
41

What is regularization? Explain L1 vs L2.

AppleMedium
Save to ▾
Show answer
Regularization adds a penalty on weights to reduce overfitting. L1 (Lasso) adds |w| and can push features to exactly zero. L2 (Ridge) adds w² and shrinks weights smoothly.
42

Explain Bayes' theorem with an example.

AppleMedium
Save to ▾
Show answer
P(A given B) = P(B given A) x P(A) / P(B). In a medical test it converts test accuracy and disease prevalence into the real chance a positive result means disease.
43

How do you perform feature selection?

AppleMedium
Save to ▾
Show answer
Use filter methods (correlation, chi-square), wrapper methods (RFE), embedded methods (Lasso, tree importance) and domain knowledge, validating each choice with cross-validation.
44

Correlation vs covariance?

AppleEasy
Save to ▾
Show answer
Covariance shows the direction of a relationship but depends on units. Correlation is covariance scaled to −1…+1, so it shows direction and strength and is unit-free.
45

What is the difference between parametric and non-parametric tests?

AppleMedium
Save to ▾
Show answer
Parametric tests assume a distribution (usually normal) and use means; non-parametric tests such as Mann-Whitney use ranks and make fewer assumptions.
46

Explain the chi-square test.

AppleMedium
Save to ▾
Show answer
It checks whether observed category counts differ from expected counts, used for independence between two categorical variables and for goodness of fit.
47

Your dataset is highly imbalanced (2% positives). How do you handle it?

AppleMedium
Save to ▾
Show answer
Use stratified splits, class weights, resampling (SMOTE or undersampling) and threshold tuning, and judge the model with PR-AUC or F1 instead of accuracy.
48

What is tokenisation in NLP?

AppleEasy
Save to ▾
Show answer
Splitting text into units such as words, subwords or characters that are mapped to ids; subword methods like BPE handle rare words well.
49

What are common ways to evaluate NLP models?

AppleMedium
Save to ▾
Show answer
Accuracy, F1 and confusion matrices for classification, BLEU or ROUGE for generation and summarisation, perplexity for language models, plus human review.
50

What are decorators in Python?

AppleMedium
Save to ▾
Show answer
A decorator wraps a function to add behaviour such as logging, timing or caching without changing its code. It is applied with the @name syntax above the function.
51

How do you profile and speed up slow Python code?

AppleMedium
Save to ▾
Show answer
Measure first with cProfile or timeit, then replace loops with NumPy or Pandas vectorised calls, use built-ins, caching and better data structures.
52

What is the difference between a set and a dictionary?

AppleEasy
Save to ▾
Show answer
A set stores unique values with no keys; a dictionary stores key-value pairs with unique keys. Both use hashing, so lookups are O(1) on average.
53

What is the difference between apply, map and applymap in Pandas?

AppleMedium
Save to ▾
Show answer
map works element-wise on a Series, apply works on a Series or along a DataFrame axis, and applymap (now DataFrame.map) applies a function to every cell.
54

Pandas: merge vs join vs concat?

AppleMedium
Save to ▾
Show answer
merge joins on columns, SQL-style (how='inner', 'left', ...). join joins on the index. concat stacks DataFrames along rows or columns.
55

What is a confusion matrix?

AppleEasy
Save to ▾
Show answer
A table of true positives, false positives, true negatives and false negatives from which accuracy, precision, recall and F1 are calculated.
56

How do you tune hyperparameters?

AppleMedium
Save to ▾
Show answer
Use grid search, random search or Bayesian optimisation with cross-validation, starting with a coarse random search and narrowing the promising ranges.
57

Explain the Law of Large Numbers.

AppleMedium
Save to ▾
Show answer
As the number of independent trials grows, the sample average converges to the true expected value, which is why larger samples give more stable estimates.
58

What are Python's main built-in data types?

AppleEasy
Save to ▾
Show answer
int, float, complex, bool, str, list, tuple, set, dict and NoneType. Mutable ones are list, set and dict; the others are immutable.
59

What is the difference between a function and a method?

AppleEasy
Save to ▾
Show answer
A method is a function that belongs to an object or class and receives the instance (self) as its first argument.