Skip to content

Junior ML Engineer (Fresher) Interview Questions & Answers

40 questions for Junior ML Engineer (Fresher) interviews — 24 easy, 16 medium.

About the Junior ML Engineer (Fresher) role

Junior ML Engineers support senior team members by cleaning data, building baseline models, running experiments and writing evaluation reports. Freshers are expected to know Python, pandas and scikit-learn well, understand core algorithms and metrics, and show two or three end-to-end projects on GitHub. Interviews focus on fundamentals, preprocessing, simple coding tasks and explaining your project choices clearly. Basic SQL and Git habits also help a lot.

Python and pandas Data cleaning scikit-learn basics Core ML metrics Git and Jupyter
Solved for this roleStart practicing
3 QUESTIONS FREESign up 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

How do you select the top k features using mutual information in scikit-learn?

Save to ▾
Show answer
SelectKBest with mutual_info_classif captures non-linear relationships, unlike plain correlation. from sklearn.feature_selection import SelectKBest, mutual_info_classif sel = SelectKBest(score_func=mutual_info_classif, k=20) X_new = sel.fit_transform(X_train, y_train) print(X_train.columns[sel.get_support()]) Put the selector inside a pipeline so selection is redone in each CV fold.
02

What is the difference between standardisation and normalisation?

Save to ▾
Show answer
Standardisation (StandardScaler) transforms a feature to mean 0 and standard deviation 1 using (x - mean) / std; it keeps outliers but does not bound values. Min-max normalisation (MinMaxScaler) rescales to a fixed range such as 0 to 1 and is sensitive to outliers. RobustScaler uses median and IQR and is better when outliers are present. Always fit the scaler on training data only.
03

What is the difference between parameters and hyperparameters?

Save to ▾
Show answer
Parameters are learned from data during training, such as the weights of a linear regression or split thresholds of a tree. Hyperparameters are set before training and control the learning process, such as learning rate, max_depth, number of trees or regularisation strength C. Hyperparameters are tuned with validation data using grid search, random search or Bayesian optimisation.
04

How do you handle missing values in a dataset?

Save to ▾
Show answer
First understand why values are missing: completely at random, at random, or not at random. Options are dropping rows or columns with heavy missingness, simple imputation with mean, median or mode, model-based imputation like KNNImputer or IterativeImputer, or a separate 'missing' category. Adding a missing-indicator column often helps because missingness itself can be predictive, such as income left blank.
05

How do you extract useful features from a datetime column in pandas?

Save to ▾
Show answer
Convert to datetime and pull out calendar parts. import pandas as pd df['ts'] = pd.to_datetime(df['ts']) df['hour'] = df['ts'].dt.hour df['dow'] = df['ts'].dt.dayofweek df['month'] = df['ts'].dt.month df['is_weekend'] = df['dow'].isin([5, 6]).astype(int) For cyclical features like hour, sine and cosine encoding keeps 23 and 0 close together.
06

What is machine learning and how is it different from traditional programming?

Save to ▾
Show answer
Machine learning is a way of building programs that learn patterns from data instead of following hand-written rules. In traditional programming you give rules and data to get answers; in ML you give data and answers to get the rules, stored as model parameters. For example, a spam filter learns which word patterns indicate spam from labelled emails rather than from a fixed keyword list.
07

How do you implement simple gradient descent for linear regression in NumPy?

Save to ▾
Show answer
Compute predictions, the gradient of MSE, and update weights in a loop. import numpy as np w = np.zeros(X.shape[1]); b = 0.0; lr = 0.01 for _ in range(1000): err = X @ w + b - y w -= lr * (2 / len(y)) * (X.T @ err) b -= lr * (2 / len(y)) * err.sum() Scale features first or the loop converges slowly.
08

What is one-hot encoding and when can it cause problems?

Save to ▾
Show answer
One-hot encoding turns a categorical column into binary columns, one per category, so models do not assume order. It causes problems with high-cardinality features like city or product ID, creating thousands of sparse columns and higher memory and overfitting risk. Alternatives are target encoding, frequency encoding, hashing, or grouping rare categories into 'Other'. Use handle_unknown='ignore' for unseen categories.
09

How does a decision tree decide where to split?

Save to ▾
Show answer
At each node the tree tries candidate features and thresholds and picks the split that most reduces impurity in the child nodes. For classification, impurity is measured by Gini or entropy; for regression, by variance or MSE. The process repeats recursively until a stopping rule such as max_depth, min_samples_leaf or pure leaves is reached. This greedy approach is fast but not globally optimal.
10

How do you set up a basic train-test split with scikit-learn?

Save to ▾
Show answer
Use train_test_split with a fixed random_state for reproducibility and stratify for classification so class ratios match. 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, random_state=42, stratify=y ) For time series, avoid random splits and use the most recent period as the test set.
11

Explain gradient descent and the role of the learning rate.

Save to ▾
Show answer
Gradient descent minimises a loss by repeatedly moving parameters in the direction of the negative gradient: w = w - learning_rate * gradient. The learning rate controls step size. Too high and the loss oscillates or diverges; too low and training is very slow or gets stuck. Variants include batch, stochastic and mini-batch gradient descent, plus adaptive optimisers like Adam.
12

Explain the k-nearest neighbours algorithm and its weaknesses.

Save to ▾
Show answer
k-NN predicts by finding the k closest training points and taking a majority vote for classification or the average for regression. It has no training phase but is slow at prediction on large data, needs feature scaling, suffers from the curse of dimensionality and is sensitive to irrelevant features. Small k overfits, large k underfits; choose k with cross-validation.
13

Print a confusion matrix and classification report in scikit-learn.

Save to ▾
Show answer
from sklearn.metrics import confusion_matrix, classification_report pred = clf.predict(X_test) print(confusion_matrix(y_test, pred)) print(classification_report(y_test, pred, digits=3)) The report shows precision, recall, F1 and support per class plus macro and weighted averages. ConfusionMatrixDisplay.from_estimator draws it as a plot.
14

Why do we split data into training, validation and test sets?

Save to ▾
Show answer
The training set fits model parameters, the validation set is used to choose hyperparameters and compare models, and the test set gives a final unbiased estimate of performance. If you tune on the test set, its score becomes optimistic because information has leaked into model choices. A common split is 70/15/15, or train/test plus cross-validation on the training part.
15

The fraud team can only review 500 alerts a day. How do you set the threshold?

Save to ▾
Show answer
Instead of 0.5, rank transactions by predicted probability and pick the threshold that yields about 500 alerts per day on recent data. Then report precision and recall at that cut-off, or precision at k. I would monitor daily alert volume because drift can change it, and recompute the threshold periodically. If cost data exists, I would choose the threshold that maximises expected savings.
16

What is the difference between a regression and a classification problem?

Save to ▾
Show answer
Regression predicts a continuous number, such as sales next month or delivery time in minutes. Classification predicts a discrete category, such as fraud or not fraud, or one of five product types. The choice decides the loss function and metrics: regression uses MSE, MAE or R-squared, while classification uses log loss, accuracy, precision, recall or AUC.
17

A business stakeholder asks you to use deep learning for a 5,000-row tabular dataset. How do you respond?

Save to ▾
Show answer
I would explain that for small tabular data, gradient-boosted trees or regularised linear models usually match or beat neural networks, train faster and are easier to explain. I would propose building a simple baseline, then a boosting model, and only test a neural network if there is a clear reason. I would show the comparison on cross-validated metrics so the decision is data-driven.
18

How do you save and load a scikit-learn model?

Save to ▾
Show answer
Save the whole fitted pipeline so preprocessing travels with the model. import joblib joblib.dump(pipe, 'model_v1.joblib') pipe = joblib.load('model_v1.joblib') preds = pipe.predict(new_df) Load with the same scikit-learn version used for training, and never load pickle or joblib files from untrusted sources because they can execute code. ONNX or skops are safer portable options.
19

Tell me about a time your model did not work as expected. What did you do?

Save to ▾
Show answer
Situation: my first churn model scored 0.95 AUC in validation but failed in a pilot. Task: find out why. Action: I traced features and found one field updated after customers left, which leaked the label. I removed it, rebuilt features with a strict cut-off date and moved to a time-based split. Result: AUC dropped to 0.78 but held steady in production, and I added a leakage checklist to my workflow.
20

Your model shows 99 percent training accuracy but 72 percent validation accuracy. What will you do?

Save to ▾
Show answer
This is overfitting. I would first check for leakage or a split mismatch, then simplify the model: add regularisation, reduce depth or features, use early stopping, or prune trees. I would gather more data or use augmentation if possible and use cross-validation to confirm the fix. Plotting learning curves shows whether more data would actually help.
21

Why do you want to work as a machine learning engineer?

Save to ▾
Show answer
I enjoy turning data into decisions that people actually use. During my projects I liked the full cycle: framing the problem, cleaning messy data, comparing models and explaining results. ML engineering lets me combine coding with statistics and see measurable business impact, such as reducing manual review time. I also want to keep growing into deployment and monitoring, which I am already practising with FastAPI and Docker.
22

What is a loss function? Name common ones for regression and classification.

Save to ▾
Show answer
A loss function measures how wrong a prediction is for one example, and training minimises its average over the data. Regression commonly uses mean squared error, mean absolute error or Huber loss, which is robust to outliers. Classification uses log loss, also called cross-entropy, and hinge loss for SVMs. The choice should reflect the business cost of errors.
23

A fraud model has 99.6 percent accuracy, but the business says it is useless. Why?

Save to ▾
Show answer
If only 0.4 percent of transactions are fraud, predicting 'not fraud' for everything gives 99.6 percent accuracy and catches nothing. I would switch to recall, precision and PR-AUC, check the confusion matrix, then retrain with class weights or resampling and tune the threshold so the fraud team gets a manageable number of alerts with high recall.
24

How does logistic regression work?

Save to ▾
Show answer
Logistic regression computes a weighted sum of features and passes it through the sigmoid function, 1 / (1 + e^-z), to get a probability between 0 and 1. It is trained by minimising log loss. Coefficients represent change in log-odds per unit of a feature, and exp(coefficient) gives the odds ratio. A threshold, 0.5 by default, converts probabilities into class labels.
25

How do you explain data cleaning decisions to a non-technical manager?

Save to ▾
Show answer
I avoid jargon and tie each decision to its effect on business results. For example: 'About 8 percent of orders had missing delivery times. Instead of deleting them, which would hide slow regions, I filled them using similar orders and flagged them, so the model still learns from those regions.' I keep a short log of decisions so they can be reviewed later and repeated.
26

What is the bias-variance trade-off?

Save to ▾
Show answer
Bias is error from overly simple assumptions, which causes underfitting. Variance is error from sensitivity to the particular training sample, which causes overfitting. Increasing model complexity usually lowers bias but raises variance. The goal is the complexity that minimises total test error. For example, a linear model on curved data has high bias, while a very deep unpruned tree has high variance.
27

What is the difference between label encoding and ordinal encoding?

Save to ▾
Show answer
Both map categories to integers. In scikit-learn, LabelEncoder is meant for the target variable, while OrdinalEncoder is for input features. Integer encoding implies an order, so it is fine for truly ordered values like low, medium, high, or for tree models, but it can mislead linear models on nominal data like colours. For nominal features with linear models, prefer one-hot encoding.
28

What does it mean to deploy a machine learning model?

Save to ▾
Show answer
Deployment makes a trained model available to produce predictions for real users or systems. It can be batch, scoring data on a schedule and writing results to a table, or real-time, serving predictions through a REST API, or streaming, scoring events as they arrive. It includes packaging the model with its preprocessing, setting up infrastructure, logging, monitoring and a retraining plan.
29

Write a minimal scikit-learn workflow to train and evaluate a model.

Save to ▾
Show answer
The fit, predict, score pattern is the same for almost every estimator. from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score model = LogisticRegression(max_iter=1000) model.fit(X_train, y_train) preds = model.predict(X_test) print(accuracy_score(y_test, preds)) Use predict_proba when you need probabilities for thresholds or ranking.
30

How would you build a quick baseline before trying complex models?

Save to ▾
Show answer
Use a DummyClassifier or DummyRegressor to see the score of a trivial guess, then a simple model. from sklearn.dummy import DummyClassifier base = DummyClassifier(strategy='most_frequent') base.fit(X_train, y_train) print(base.score(X_test, y_test)) Any real model must clearly beat this number; otherwise the features carry little signal.
31

How do you plot an ROC curve and get AUC in scikit-learn?

Save to ▾
Show answer
from sklearn.metrics import roc_auc_score, RocCurveDisplay import matplotlib.pyplot as plt proba = clf.predict_proba(X_test)[:, 1] print('AUC', roc_auc_score(y_test, proba)) RocCurveDisplay.from_predictions(y_test, proba) plt.show() Pass probabilities or decision scores, not hard labels, otherwise the curve has only one point.
32

Grid search with 5 hyperparameters is taking two days. How do you speed it up?

Save to ▾
Show answer
Switch to random search or Optuna with pruning, which find good settings with far fewer trials. Narrow ranges using a quick coarse search, tune the most important parameters first, use early stopping for boosting, run trials in parallel with n_jobs, and tune on a stratified sample of the data before a final refit on the full set. HalvingRandomSearchCV is another quick option.
33

What are overfitting and underfitting, and how do you detect them?

Save to ▾
Show answer
Overfitting is when a model memorises training noise and performs much worse on unseen data. Underfitting is when the model is too simple to capture the pattern, so both training and validation scores are poor. Detect them by comparing training and validation metrics or plotting learning curves. A large gap means overfitting; two low, close scores mean underfitting.
34

What is heteroscedasticity and why does it matter?

Save to ▾
Show answer
Heteroscedasticity means the variance of residuals changes with the level of the prediction, such as errors growing for expensive houses. Predictions remain unbiased, but standard errors and p-values become unreliable. Detect it with a residuals versus fitted plot or the Breusch-Pagan test. Fixes include log-transforming the target, weighted least squares, or robust standard errors.
35

Apply PCA and check explained variance.

Save to ▾
Show answer
from sklearn.decomposition import PCA import numpy as np pca = PCA().fit(Xs) cum = np.cumsum(pca.explained_variance_ratio_) n = np.argmax(cum >= 0.95) + 1 print(n, 'components explain 95 percent') X_red = PCA(n_components=0.95).fit_transform(Xs) Passing a float to n_components keeps enough components to reach that variance.
36

Tell me about a time you had to explain a model's error to a business team.

Save to ▾
Show answer
Situation: a sales forecast missed by 18 percent in one month. Task: explain why to the category team. Action: I broke the error down by region and found most came from a sudden promotion not in our data. I showed a simple chart and proposed adding a promotion calendar feed. Result: the team shared promotion plans in advance, and the next quarter's error fell below 8 percent.
37

What is data leakage? Give two examples.

Save to ▾
Show answer
Data leakage is when information not available at prediction time gets into training, giving falsely high validation scores. Example one: fitting a scaler or imputer on the full dataset before splitting. Example two: using a feature created after the event, such as 'refund issued' when predicting fraud. Prevent it with pipelines, time-aware splits and checking each feature's timestamp.
38

Explain precision, recall and F1 score.

Save to ▾
Show answer
Precision is TP / (TP + FP): of the cases flagged positive, how many were right. Recall is TP / (TP + FN): of the actual positives, how many were found. F1 is the harmonic mean of the two and is low if either is low. Use precision when false alarms are costly, such as spam filters; use recall when misses are costly, such as cancer screening or fraud.
39

How do you build a text classifier with TF-IDF and logistic regression?

Save to ▾
Show answer
from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.linear_model import LogisticRegression from sklearn.pipeline import make_pipeline clf = make_pipeline( TfidfVectorizer(ngram_range=(1, 2), min_df=2, sublinear_tf=True), LogisticRegression(max_iter=1000, class_weight='balanced') ) clf.fit(train_texts, train_labels) print(clf.score(test_texts, test_labels))
40

How do you find and remove duplicate rows and check missing values in pandas?

Save to ▾
Show answer
Quick data-quality checks before modelling: print(df.isna().sum().sort_values(ascending=False)) print(df.duplicated().sum()) df = df.drop_duplicates() df['age'] = df['age'].fillna(df['age'].median()) For modelling, do the median imputation inside a pipeline instead so the value is learned only from training data.

Frequently asked questions

What does a Junior ML Engineer (Fresher) do?

Junior ML Engineers support senior team members by cleaning data, building baseline models, running experiments and writing evaluation reports. Freshers are expected to know Python, pandas and scikit-learn well, understand core algorithms and metrics, and show two or three end-to-end projects on GitHub. Interviews focus on fundamentals, preprocessing, simple coding tasks and explaining your project choices clearly. Basic SQL and Git habits also help a lot.

Which skills are tested in a Junior ML Engineer (Fresher) interview?

Expect questions on Python and pandas, Data cleaning, scikit-learn basics, Core ML metrics, Git and Jupyter. Most rounds also ask you to explain a project and solve one practical problem live.

How do I prepare for a Junior ML Engineer (Fresher) interview?

Revise ML Fundamentals, Data Preprocessing and Feature Engineering, Classification Models first using the topic sheets, practise the questions on this page aloud, then do one full mock interview to practise timing.