Machine Learning Interview Questions in Thiruvananthapuram
36 practice questions with answers for Machine Learning interviews in Thiruvananthapuram.
Machine Learning jobs in Thiruvananthapuram
Thiruvananthapuram's Technopark is one of India's oldest IT parks, hosting IT-services, product and engineering-services companies. Data and testing teams here often work with global clients in finance, travel and healthcare.
Below are 36 questions that match the mix of service, product and domain employers hiring machine learning engineers in Thiruvananthapuram.
Solved for ThiruvananthapuramStart 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
Your dataset has a city column with 2,000 unique values. How will you encode it?
One-hot would create 2,000 sparse columns, so I would first group rare cities below a frequency threshold into 'Other'. Then options are frequency encoding, out-of-fold target encoding, or mapping cities to useful attributes such as tier, state or population. For boosting models like CatBoost or LightGBM, native categorical handling also works well. I would compare options with cross-validation.
02
What is a loss function? Name common ones for regression and classification.
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.
03
How do you implement simple gradient descent for linear regression in NumPy?
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.
An SVM finds the hyperplane that separates classes with the maximum margin, and the points on the margin are the support vectors. The soft-margin version uses C to trade off margin width against misclassification. Kernels like RBF or polynomial let SVMs learn non-linear boundaries by implicitly mapping data to higher dimensions. SVMs need scaled features and become slow beyond roughly a hundred thousand rows.
05
What is the difference between Ridge, Lasso and Elastic Net regression?
All add a penalty on coefficient size to reduce overfitting. Ridge uses an L2 penalty (sum of squares), shrinking coefficients toward zero but rarely to zero, and handles multicollinearity well. Lasso uses L1 (sum of absolute values) and can set coefficients exactly to zero, performing feature selection. Elastic Net mixes both, which is useful when there are groups of correlated features.
06
Your team retrains models manually in notebooks every month. How would you improve it?
I would convert the notebook into a versioned training pipeline with separate steps for data extraction, validation, feature building, training and evaluation, scheduled with Airflow or a cloud pipeline. Each run would log to MLflow, compare against the production model on a fixed holdout, and register the new model only if it passes thresholds. Promotion would stay a reviewed step, at least initially.
07
Compare grid search, random search and Bayesian optimisation.
Grid search tries every combination of listed values; it is thorough but expensive and wastes trials on unimportant parameters. Random search samples combinations and usually finds good settings faster in high-dimensional spaces. Bayesian optimisation, as in Optuna or Hyperopt, builds a model of past trials to pick promising settings next, using fewer trials. Successive halving methods add early pruning of weak trials.
08
Tell me about a time your analysis was not used by stakeholders. What did you learn?
Situation: I built eight customer segments, but marketing did not use them. Task: understand why. Action: I met the team and learned the segments were hard to act on and lacked clear names. I reduced them to five, added a one-page profile and suggested campaign ideas for each. Result: two segments were used in the next campaign. I learned to involve users from the start.
09
Grid search with 5 hyperparameters is taking two days. How do you speed it up?
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.
Time series data is ordered and autocorrelated, so random splits leak future information. I use time-based splits or TimeSeriesSplit, create lag and rolling-window features from past values only, and handle trend and seasonality. Baselines like last value or seasonal naive come first. Models range from ARIMA and Prophet to gradient boosting on lag features.
12
What is the no free lunch theorem and what does it mean in practice?
It states that no single algorithm is best for every problem when averaged over all possible problems. In practice it means you should try several model families, start with a simple baseline, and choose based on validation results for your data. For tabular data gradient boosting often wins, but a logistic regression may be preferred if interpretability matters more.
13
Tell me about a time you had to explain a model's error to a business team.
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.
I would study the missingness pattern first, for example whether self-employed applicants skip it. I would add a binary was_missing feature, impute with the median within relevant groups or use IterativeImputer, and compare against models that handle missing values natively, like HistGradientBoosting or XGBoost. I would also raise the issue with the data owner so collection can improve.
16
A model's accuracy dropped 10 percent over three months in production. How do you investigate?
I would first check data pipelines for broken features, nulls or schema changes, then compare current feature distributions with training data using PSI to find drift. I would check whether the label definition or business process changed, and analyse errors by segment. If drift is real, retrain on recent data, possibly with time-weighted samples, and set up automatic drift alerts and scheduled retraining.
17
Run stratified 5-fold cross-validation with multiple metrics.
from sklearn.model_selection import StratifiedKFold, cross_validate
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
res = cross_validate(pipe, X, y, cv=cv,
scoring=['roc_auc', 'average_precision', 'f1'], n_jobs=-1)
for k in ['test_roc_auc', 'test_average_precision', 'test_f1']:
print(k, res[k].mean().round(3), res[k].std().round(3))
18
What is machine learning and how is it different from traditional programming?
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.
A model registry is a central store of model versions with metadata: training data version, parameters, metrics, owner and stage such as staging or production. It makes promotions and rollbacks controlled and auditable, and lets serving systems load a model by name and version. MLflow Model Registry, SageMaker Model Registry and Vertex AI Model Registry are common examples.
20
A new model version performs badly right after release. How do you handle it?
Roll back immediately to the previous version from the model registry, which should be a one-step action. Then investigate: compare the input features served with those used in validation, check for training-serving skew, version mismatches or a wrong artifact. Add the failure case to automated pre-release checks, and use canary or shadow releases next time so issues affect only a small share of traffic.
21
Two models have RMSE 120 and 125, but the second has much lower MAE. Which do you choose?
It depends on error cost. The first model makes fewer big errors, while the second is better on typical cases but has some large misses. If large errors are expensive, such as stock-outs of costly items, choose the first. If typical accuracy matters more, choose the second. I would also check error distributions by segment and discuss with stakeholders before deciding.
Fix random seeds in NumPy, Python and the model, pin library versions in requirements.txt, version the data or record its hash, and save the exact code commit and hyperparameters. Tools like MLflow log parameters, metrics and artifacts per run. Use pipelines so preprocessing is identical each time, and keep the train-test split stored rather than recreated randomly.
Common methods are the elbow method, plotting inertia against k and looking for the bend; the silhouette score, which measures how close points are to their own cluster versus the next one; and the gap statistic. Business usability matters too: four clear segments a marketing team can act on are better than nine statistically optimal but confusing ones.
24
When should you use TimeSeriesSplit or GroupKFold instead of normal k-fold?
Use TimeSeriesSplit when data is ordered in time, so each validation fold comes after its training data and no future information leaks back. Use GroupKFold when multiple rows belong to the same entity, such as several visits per patient, so the same entity never appears in both train and validation. Normal k-fold in these cases gives over-optimistic scores.
25
What is the difference between PCA and t-SNE or UMAP?
PCA is a linear method that preserves global variance, is fast, deterministic and can transform new data, so it is used for preprocessing. t-SNE and UMAP are non-linear methods that preserve local neighbourhoods, producing good 2D visualisations of clusters. t-SNE distances between clusters are not meaningful. UMAP is faster, keeps more global structure and can transform new points.
26
Tell me about a time your model did not work as expected. What did you do?
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.
That is heteroscedasticity, typical for price data that is right-skewed. I would model log(price) instead of price, which turns absolute errors into roughly percentage errors and stabilises variance. Then I would convert predictions back with exp and check residual plots again. Evaluating with RMSLE or MAPE also fits better when relative error matters more than absolute error.
29
Your manager asks for a single number showing the model's business value. What do you give?
I would convert model outcomes into money or time using a cost matrix agreed with the business, for example savings from caught fraud minus the cost of reviewing false alerts. I would compare this against the current process or a rule-based baseline on holdout data and show a range rather than one point. A short note on assumptions keeps the number honest.
Data drift, or covariate shift, means the distribution of input features changes, such as average order value rising after a pricing change. Concept drift means the relationship between features and target changes, such as fraud patterns evolving. Data drift can be detected without labels using PSI or KS tests; concept drift usually needs labels and shows up as falling performance. Both trigger investigation and retraining.
31
Build RFM features for customer segmentation in pandas.
AdaBoost trains weak learners, usually decision stumps, in sequence. After each round it increases the weights of misclassified samples so the next learner focuses on them, and gives each learner a vote weight based on its accuracy. It works well on clean data but is sensitive to noisy labels and outliers, which get ever larger weights. Gradient boosting is a generalisation that has largely replaced it.
33
Validation AUC is 0.99 on a loan default model. What do you suspect?
Such a high score on a hard problem usually signals leakage. I would check feature importances for a suspiciously dominant feature, look for fields recorded after the loan outcome such as collection status, verify preprocessing was fit only on training data, and check for duplicate customers across train and test. Then re-run with a time-based split to confirm a realistic score.
Softmax turns a vector of raw scores into probabilities that sum to one: p_i = exp(z_i) / sum of exp(z_j). It is used in multinomial logistic regression and the output layer of neural networks for multiclass problems. Larger scores get exponentially larger shares. In practice the maximum score is subtracted before exponentiation to avoid numerical overflow.
35
Use HistGradientBoosting with native categorical support in scikit-learn.
from sklearn.ensemble import HistGradientBoostingClassifier
clf = HistGradientBoostingClassifier(
categorical_features='from_dtype', max_iter=500,
learning_rate=0.05, early_stopping=True, random_state=42)
X_train[cat_cols] = X_train[cat_cols].astype('category')
clf.fit(X_train, y_train)
It handles missing values natively and is much faster than GradientBoostingClassifier on large data.
36
What is multicollinearity and how do you detect it?
Multicollinearity is high correlation between input features, which makes linear model coefficients unstable and hard to interpret, though predictions may remain fine. Detect it with a correlation matrix or the Variance Inflation Factor, where VIF above 5 to 10 signals a problem. Fix it by dropping one of the correlated features, combining them, using PCA, or applying Ridge regularisation.
Few big employers listed in Thiruvananthapuram?
Many Thiruvananthapuram candidates also apply to teams in Bangalore and to remote or hybrid roles. Practise the Bangalore set as well.
Which companies hire Machine Learning professionals in Thiruvananthapuram?
Companies with large offices in Thiruvananthapuram include many IT services and product firms. Use their company pages below to practise employer-specific sets.
Are Machine Learning interviews in Thiruvananthapuram different from other cities?
The questions depend more on the company than the city. Thiruvananthapuram's mix of employers decides the style: Data and testing teams here often work with global clients in finance, travel and healthcare
How do I find Machine Learning jobs in Thiruvananthapuram?
Shortlist companies with Thiruvananthapuram offices, keep your CV focused on Machine Learning projects, apply on company career pages and job portals with the Thiruvananthapuram filter, and practise the questions on this page before each interview.