Skip to content

Machine Learning Interview Questions in Ahmedabad

36 practice questions with answers for Machine Learning interviews in Ahmedabad.

Machine Learning jobs in Ahmedabad

Ahmedabad and GIFT City have a growing market for IT services, fintech and product start-ups. Companies here value hands-on skills and the ability to work across tools, especially in smaller teams.

Below are 36 questions that match the mix of service, product and domain employers hiring machine learning engineers in Ahmedabad.

Solved for AhmedabadStart 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 handle class imbalance?

Save to ▾
Show answer
Start with the right metrics, such as PR-AUC, recall at fixed precision or F1, not accuracy. Then use class_weight='balanced', resampling like random undersampling or SMOTE applied only on training folds, and threshold tuning based on business cost. Boosting models with scale_pos_weight also help. Stratified splits keep class ratios consistent across folds.
02

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.
03

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))
04

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.
05

Use statsmodels to get p-values for regression coefficients.

Save to ▾
Show answer
import statsmodels.api as sm Xc = sm.add_constant(X_train) ols = sm.OLS(y_train, Xc).fit() print(ols.summary()) The summary shows coefficients, standard errors, p-values, confidence intervals, R-squared and diagnostics. scikit-learn focuses on prediction and does not report p-values, so statsmodels is preferred for inference.
06

Compare filter, wrapper and embedded feature selection methods.

Save to ▾
Show answer
Filter methods score features independently of a model using statistics such as correlation, chi-square or mutual information; they are fast but ignore interactions. Wrapper methods like Recursive Feature Elimination train models on feature subsets; they are accurate but slow. Embedded methods select during training, such as L1 regularisation or tree feature importances. Embedded methods are a common practical middle ground.
07

Compute permutation importance on validation data.

Save to ▾
Show answer
from sklearn.inspection import permutation_importance import pandas as pd r = permutation_importance(model, X_val, y_val, n_repeats=10, scoring='roc_auc', random_state=42, n_jobs=-1) imp = pd.Series(r.importances_mean, index=X_val.columns) print(imp.sort_values(ascending=False)) Near-zero or negative values mean the feature adds little on unseen data.
08

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.
09

A product team wants 'similar products' recommendations with no purchase labels. How would you start?

Save to ▾
Show answer
I would build product embeddings from content: TF-IDF or sentence embeddings of titles and descriptions, plus category and price features. Then use cosine similarity with nearest-neighbour search, such as scikit-learn NearestNeighbors or an approximate index like FAISS for large catalogues. I would review samples with the product team and later add co-view or co-purchase signals once collected.
10

What is a confusion matrix?

Save to ▾
Show answer
A confusion matrix is a table of actual versus predicted classes. For binary problems it has true positives, false positives, true negatives and false negatives. From it you derive precision, recall, specificity and accuracy. For example, in fraud detection a false negative is a missed fraud and a false positive is a genuine customer blocked, and these usually have very different costs.
11

Tell me about a time you balanced model accuracy against a business constraint.

Save to ▾
Show answer
Situation: our lead-scoring model had the best AUC with a large ensemble, but the CRM needed scores within 50 ms. Task: meet latency without losing much quality. Action: I compared a smaller LightGBM model with fewer features and measured both AUC and latency. Result: we lost 0.01 AUC but met the 50 ms limit, and sales teams adopted it because scores appeared instantly.
12

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.
13

When should you use TimeSeriesSplit or GroupKFold instead of normal k-fold?

Save to ▾
Show answer
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.
14

What is MLOps?

Save to ▾
Show answer
MLOps applies DevOps practices to machine learning: version control for code, data and models, automated training pipelines, testing, CI/CD for model releases, model registries, monitoring and automated retraining. Its aim is to move models from notebooks to production reliably and keep them healthy. Common tools are MLflow, DVC, Airflow, Kubeflow, and cloud platforms like SageMaker, Vertex AI and Azure ML.
15

What is association rule mining? Explain support, confidence and lift.

Save to ▾
Show answer
Association rule mining finds items that occur together, such as in market basket analysis. Support is how often an itemset appears in all transactions. Confidence of A to B is the share of transactions with A that also contain B. Lift is confidence divided by B's support; lift above 1 means A and B occur together more than by chance. Apriori and FP-Growth are common algorithms.
16

How would you encode cyclical features like hour of day or month?

Save to ▾
Show answer
Map the value onto a circle with sine and cosine so the end connects to the start. import numpy as np df['hour_sin'] = np.sin(2 * np.pi * df['hour'] / 24) df['hour_cos'] = np.cos(2 * np.pi * df['hour'] / 24) Now 23:00 and 00:00 are close, which linear and distance-based models cannot see with raw integers. Tree models often manage with the raw value.
17

How does ordinary least squares find the regression coefficients?

Save to ▾
Show answer
OLS chooses coefficients that minimise the sum of squared residuals between actual and predicted values. It has a closed-form solution, beta = (X^T X)^-1 X^T y, when X^T X is invertible. For very large or ill-conditioned data, gradient descent or a pseudo-inverse is used instead. Squaring errors penalises large mistakes heavily, which makes OLS sensitive to outliers.
18

What is a model registry and why is it useful?

Save to ▾
Show answer
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.
19

What is the difference between batch, stochastic and mini-batch gradient descent?

Save to ▾
Show answer
Batch gradient descent uses the full dataset for each update, giving stable but slow and memory-heavy steps. Stochastic gradient descent updates after every single example, which is fast and noisy and can escape shallow minima. Mini-batch uses small groups such as 32 to 512 rows, balancing stability with speed and allowing vectorised computation. Mini-batch is the default in practice.
20

What is the difference between Ridge, Lasso and Elastic Net regression?

Save to ▾
Show answer
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.
21

Train a random forest and show feature importances in scikit-learn.

Save to ▾
Show answer
from sklearn.ensemble import RandomForestClassifier import pandas as pd rf = RandomForestClassifier(n_estimators=300, min_samples_leaf=2, n_jobs=-1, random_state=42, oob_score=True) rf.fit(X_train, y_train) print('OOB', rf.oob_score_) imp = pd.Series(rf.feature_importances_, index=X_train.columns) print(imp.sort_values(ascending=False).head(10))
22

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.
23

What is multicollinearity and how do you detect it?

Save to ▾
Show answer
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.
24

Serve a scikit-learn model with FastAPI.

Save to ▾
Show answer
from fastapi import FastAPI from pydantic import BaseModel import joblib, pandas as pd app = FastAPI() model = joblib.load('model_v1.joblib') class Item(BaseModel): age: int income: float city: str @app.post('/predict') def predict(item: Item): df = pd.DataFrame([item.model_dump()]) return {'score': float(model.predict_proba(df)[0, 1])} Run it with: uvicorn app:app --host 0.0.0.0 --port 8000
25

How do you approach a time series forecasting problem differently from normal regression?

Save to ▾
Show answer
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.
26

k-means gives one huge cluster and several tiny ones. What could be wrong?

Save to ▾
Show answer
Likely causes are unscaled features, where one large-range feature dominates distance; heavy skew or outliers pulling centroids; or data that is not naturally spherical. I would log-transform and scale features, remove or cap extreme outliers, and try different k values. If shapes are irregular, DBSCAN, HDBSCAN or a Gaussian Mixture Model may fit better.
27

How do you work with data engineers and software engineers on an ML project?

Save to ▾
Show answer
I agree early on interfaces: which tables or APIs provide features, the input and output schema, latency targets and who owns monitoring. I share a short design document and keep my code in the same repository standards as theirs, with tests and reviews. In my last project weekly syncs with data engineering helped us fix a late-arriving data issue before launch rather than after.
28

What is the ROC curve and AUC? When is PR-AUC better?

Save to ▾
Show answer
The ROC curve plots true positive rate against false positive rate at every threshold, and AUC is the probability that a random positive is ranked above a random negative. It is threshold-independent. On heavily imbalanced data, like 0.5 percent fraud, ROC-AUC can look high even when precision is poor, so the precision-recall curve and PR-AUC give a more honest picture.
29

How do one-vs-rest and multinomial approaches differ for multiclass classification?

Save to ▾
Show answer
One-vs-rest trains one binary classifier per class against all others and picks the highest score; it is simple but probabilities may not sum to one. Multinomial (softmax) logistic regression models all classes jointly with a single loss, giving consistent probabilities. For metrics, use macro averaging to treat classes equally or weighted averaging to account for class frequency.
30

What is a feature store and when is it needed?

Save to ▾
Show answer
A feature store is a system that defines, computes and serves features consistently for both training and real-time inference, with an offline store for historical data and an online store for low-latency lookup. It prevents training-serving skew and lets teams reuse features. It is worth it when many models share features or need real-time features; small teams can start with well-managed tables.
31

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.
32

40 percent of values in an important income column are missing. What do you do?

Save to ▾
Show answer
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.
33

Labels for your loan model arrive only after 6 months. How do you monitor it meanwhile?

Save to ▾
Show answer
I would rely on proxy signals: input data drift with PSI, prediction score distribution, approval rates by segment, and early indicators like first missed payment at 30 or 60 days. Once enough early outcomes arrive, I would check performance on these. I would also set up a delayed evaluation job that computes full metrics as labels mature and compares them with the validation baseline.
34

What is the curse of dimensionality?

Save to ▾
Show answer
As the number of features grows, data becomes sparse in the feature space, distances between points become similar, and the amount of data needed to generalise grows rapidly. Distance-based methods like k-NN and k-means suffer most. Remedies include feature selection, dimensionality reduction such as PCA, regularisation and collecting more data. Text and genomics data often face this problem.
35

Build RFM features for customer segmentation in pandas.

Save to ▾
Show answer
snap = df['order_date'].max() + pd.Timedelta(days=1) rfm = df.groupby('customer_id').agg( recency=('order_date', lambda d: (snap - d.max()).days), frequency=('order_id', 'nunique'), monetary=('amount', 'sum')) rfm[['frequency', 'monetary']] = np.log1p(rfm[['frequency', 'monetary']]) Scale these columns before clustering.
36

Check calibration with a reliability curve and Brier score.

Save to ▾
Show answer
from sklearn.calibration import CalibrationDisplay from sklearn.metrics import brier_score_loss proba = clf.predict_proba(X_test)[:, 1] print('Brier', brier_score_loss(y_test, proba)) CalibrationDisplay.from_predictions(y_test, proba, n_bins=10) plt.show() Points on the diagonal mean predicted probabilities match observed frequencies.

Frequently asked questions

Which companies hire Machine Learning professionals in Ahmedabad?

Companies with large offices in Ahmedabad include many IT services and product firms. Use their company pages below to practise employer-specific sets.

Are Machine Learning interviews in Ahmedabad different from other cities?

The questions depend more on the company than the city. Ahmedabad's mix of employers decides the style: Companies here value hands-on skills and the ability to work across tools, especially in smaller teams

How do I find Machine Learning jobs in Ahmedabad?

Shortlist companies with Ahmedabad offices, keep your CV focused on Machine Learning projects, apply on company career pages and job portals with the Ahmedabad filter, and practise the questions on this page before each interview.