InterviewStack.io LogoInterviewStack.io

Python Programming & ML Libraries Questions

Python programming language fundamentals (syntax, data structures, control flow, error handling) with practical usage of machine learning libraries such as NumPy, pandas, scikit-learn, TensorFlow, and PyTorch for data manipulation, model development, training, evaluation, and lightweight ML tasks.

EasyTechnical
22 practiced
Write a concise pandas expression to one-hot encode the categorical column df['color'] and drop the first level to avoid multicollinearity. Show how to keep the result in df (i.e., drop original column and add dummies). Also mention how to persist the encoding mapping for production inference to handle unseen categories.
MediumTechnical
21 practiced
Implement a scikit-learn Pipeline that imputes numeric missing values with median, scales numeric features with StandardScaler, encodes categorical features using OneHotEncoder (handle unknowns), and trains a RandomForestClassifier. Show code using ColumnTransformer and Pipeline given lists numeric_cols and cat_cols. Also include how to validate this pipeline with GridSearchCV.
MediumTechnical
25 practiced
Explain the bias-variance tradeoff. For a supervised ML model, describe what characteristic shapes you'd expect to see on training and validation learning curves for a high-bias model and a high-variance model. Then list practical changes you can implement in scikit-learn or PyTorch to address high variance and high bias respectively.
MediumTechnical
23 practiced
Explain how to save and load PyTorch model weights and optimizer state for checkpointing and resuming training. Include code snippets that show saving model.state_dict(), optimizer.state_dict(), and additional metadata (epoch, scheduler state) and explain device mapping when loading on CPU vs GPU.
HardTechnical
18 practiced
Implement a memory-mapped data loader using numpy.memmap for a very large dataset stored on SSD that supports random sampling and minibatch reads. Describe a shuffling strategy that avoids loading the entire index into memory (e.g., block shuffling or indexed reservoir) and provide a code sketch showing how to open memmap, sample indices, and read minibatches efficiently while minimizing seeks.

Unlock Full Question Bank

Get access to hundreds of Python Programming & ML Libraries interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.