Skip to content

Machine Learning Interview Questions in Chandigarh

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

Machine Learning jobs in Chandigarh

Chandigarh, Mohali and Panchkula form the Tricity IT cluster, with IT-services firms, SaaS companies and start-ups in Mohali's IT City and Chandigarh's IT Park. Interviews usually check strong fundamentals and practical tool skills.

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

Solved for ChandigarhStart 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

What is DBSCAN and when is it better than k-means?

Save to ▾
Show answer
DBSCAN groups points that lie in dense regions, defined by eps (neighbourhood radius) and min_samples, and labels points in sparse areas as noise. It finds arbitrarily shaped clusters, does not need k, and handles outliers. It struggles when clusters have very different densities and in high dimensions. HDBSCAN improves on it for varying densities.
02

Explain hierarchical clustering and dendrograms.

Save to ▾
Show answer
Agglomerative hierarchical clustering starts with each point as its own cluster and repeatedly merges the two closest clusters. Linkage defines closeness: single, complete, average or Ward, which minimises variance. A dendrogram shows the merge history, and cutting it at a height gives the clusters. It does not need k upfront but scales poorly, roughly O(n squared) memory, so it suits smaller datasets.
03

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

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

Plot a learning curve in scikit-learn.

Save to ▾
Show answer
from sklearn.model_selection import LearningCurveDisplay import numpy as np LearningCurveDisplay.from_estimator(model, X, y, cv=5, train_sizes=np.linspace(0.1, 1.0, 6), scoring='roc_auc', n_jobs=-1) plt.show() A persistent gap between curves suggests more data or regularisation; two low curves suggest a richer model or better features.
06

When would you use AdaBoost and how does it re-weight samples?

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

How do you explain the precision-recall trade-off to a business manager?

Save to ▾
Show answer
I use their own example. For fraud: 'If we flag more transactions, we catch more fraud, which is recall, but more genuine customers get blocked, which hurts precision. Here is a table of what each threshold means per day: frauds caught, customers disturbed, reviews needed.' Then we choose the threshold together based on cost. Managers relate much better to counts than to percentages.
08

What is regularisation in general and why does it reduce overfitting?

Save to ▾
Show answer
Regularisation adds a constraint or penalty that discourages overly complex models, such as large weights in linear models, deep trees or too many boosting rounds. It trades a little extra bias for a larger drop in variance, so test error falls. Examples include L1 and L2 penalties, dropout in neural networks, early stopping, pruning and limiting tree depth.
09

Compare batch scoring and real-time inference.

Save to ▾
Show answer
Batch scoring runs on a schedule, for example nightly churn scores for all customers written to a table; it is simple, cheap and tolerant of slow models. Real-time inference returns predictions on request, such as fraud checks during payment, and needs low latency, high availability, scaling and fresh features. Choose real-time only when the decision must happen at the moment of the event.
10

How do you create lag and rolling features for a sales forecasting model in pandas?

Save to ▾
Show answer
Sort by item and date, then shift so features use only past values. df = df.sort_values(['item', 'date']) g = df.groupby('item')['sales'] df['lag_7'] = g.shift(7) df['roll_mean_28'] = g.transform(lambda s: s.shift(1).rolling(28).mean()) The shift before rolling prevents the current day's sales from leaking into its own feature.
11

You must build a spam classifier quickly with limited compute. What do you choose?

Save to ▾
Show answer
I would use TF-IDF features with a Multinomial Naive Bayes or linear model like logistic regression or LinearSVC. They train in seconds, handle high-dimensional sparse text well and give strong baselines. I would evaluate precision carefully because blocking genuine mail is costly. Only if this is not good enough would I try fine-tuning a small transformer model.
12

Calculate the Population Stability Index for a feature.

Save to ▾
Show answer
import numpy as np def psi(expected, actual, bins=10): cuts = np.quantile(expected, np.linspace(0, 1, bins + 1)) cuts[0], cuts[-1] = -np.inf, np.inf e = np.histogram(expected, cuts)[0] / len(expected) + 1e-6 a = np.histogram(actual, cuts)[0] / len(actual) + 1e-6 return float(np.sum((a - e) * np.log(a / e))) Rule of thumb: below 0.1 stable, 0.1 to 0.25 moderate, above 0.25 significant drift.
13

Your house price model's residuals grow larger for expensive houses. What do you do?

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

Your cross-validation score is 0.85 but the test score is 0.70. What could explain it?

Save to ▾
Show answer
Possible causes: leakage inside CV, such as preprocessing or feature selection fit outside folds; repeated tuning that overfit the CV folds; a test set from a different time period or population; or duplicate entities across folds but not test. I would check pipeline structure, switch to time-based or group splits that match how test data differs, and compare feature distributions between the two sets.
15

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

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

Tell me about a time your analysis was not used by stakeholders. What did you learn?

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

How do you tune the alpha of Ridge regression using cross-validation?

Save to ▾
Show answer
RidgeCV tests many alphas efficiently; scale features first. from sklearn.linear_model import RidgeCV from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler import numpy as np m = make_pipeline(StandardScaler(), RidgeCV(alphas=np.logspace(-3, 3, 30))) m.fit(X_train, y_train) print(m[-1].alpha_) LassoCV and ElasticNetCV work the same way.
19

Lasso dropped a feature the business considers very important. How do you handle it?

Save to ▾
Show answer
Lasso often keeps only one of a group of correlated features, so the dropped feature may be redundant rather than useless. I would check correlations, try Elastic Net which keeps correlated groups, and compare cross-validated performance with the feature forced in. I would explain the trade-off clearly; if the accuracy difference is small, keeping the feature for trust and interpretability is reasonable.
20

Describe a time you found a serious data quality issue late in a project.

Save to ▾
Show answer
Situation: two days before a demo, I noticed sales for one region were doubled. Task: fix it without missing the deadline. Action: I traced it to a join that duplicated rows on a non-unique key, fixed the join, added row-count assertions to the pipeline and retrained. I informed my lead immediately with the impact. Result: the demo went ahead with correct numbers, and the assertions caught a similar issue later.
21

What are shadow deployment and canary release for models?

Save to ▾
Show answer
In shadow deployment the new model receives a copy of live traffic and its predictions are logged but not used, so you can compare it with the current model safely. In a canary release a small share of real traffic, such as 5 percent, is served by the new model, and the share grows if metrics stay healthy. Both reduce the risk of a bad model affecting all users.
22

A new model version performs badly right after release. How do you handle it?

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

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
24

Use HistGradientBoosting with native categorical support in scikit-learn.

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

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

Business users do not trust a gradient boosting model because it is a black box. How do you help?

Save to ▾
Show answer
I would use SHAP to show global drivers with a summary plot and explain individual decisions with waterfall plots, such as why one applicant got a high risk score. I would also check that the top drivers make business sense, add monotonic constraints where logic requires it, and share a few real case examples. If trust is still an issue, a scorecard model can serve as a transparent benchmark.
27

What makes XGBoost, LightGBM and CatBoost different?

Save to ▾
Show answer
XGBoost adds regularisation to the objective, uses second-order gradients and handles missing values natively. LightGBM grows trees leaf-wise and uses histogram binning, making it very fast on large data, though it can overfit small data. CatBoost handles categorical features with ordered target statistics and uses symmetric trees, giving strong defaults with less tuning. All three support GPU training.
28

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

What is feature engineering and why does it matter?

Save to ▾
Show answer
Feature engineering is creating input variables that make patterns easier for a model to learn, using domain knowledge. Examples are extracting day of week from a date, ratios like debt-to-income, rolling averages of past purchases, or text length. On tabular problems good features often improve results more than switching algorithms. Features must use only information available at prediction time.
30

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

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

Why can impurity-based feature importance be misleading?

Save to ▾
Show answer
Impurity-based importance is computed on training data and favours high-cardinality or continuous features, which offer more split points, even if they are noise. It also splits credit between correlated features. Permutation importance on validation data, which measures the score drop when a feature is shuffled, is more reliable, and SHAP values give consistent per-prediction attributions.
33

Why do skewed features often need a log or power transform?

Save to ▾
Show answer
Heavily right-skewed features like income or transaction amount have long tails that can dominate linear models and distance metrics. A log1p, Box-Cox or Yeo-Johnson transform compresses large values and makes the distribution closer to normal, which often improves linear and distance-based models. Yeo-Johnson works with zero and negative values. Tree models usually do not need these transforms.
34

Your dataset has 800 correlated features and the model trains slowly. What would you do?

Save to ▾
Show answer
I would remove constant and near-duplicate features, drop one from each highly correlated pair, then apply PCA inside the pipeline and keep components explaining about 95 percent of variance. Alternatively, use L1-regularised models or tree importances for supervised selection. I would compare speed and cross-validated scores; often 50 to 100 features give nearly the same accuracy.
35

Compare grid search, random search and Bayesian optimisation.

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

How does a support vector machine work?

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

Few big employers listed in Chandigarh?

Many Chandigarh candidates also apply to teams in Gurgaon and to remote or hybrid roles. Practise the Gurgaon set as well.

Frequently asked questions

Which companies hire Machine Learning professionals in Chandigarh?

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

Are Machine Learning interviews in Chandigarh different from other cities?

The questions depend more on the company than the city. Chandigarh's mix of employers decides the style: Interviews usually check strong fundamentals and practical tool skills

How do I find Machine Learning jobs in Chandigarh?

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