InterviewStack.io LogoInterviewStack.io

Scikit Learn, Pandas, and NumPy Usage Questions

Practical proficiency with these core libraries. Pandas: DataFrames, data manipulation, handling missing values. NumPy: arrays, vectorized operations, mathematical functions. Scikit-learn: preprocessing, model fitting, evaluation metrics, pipelines. Knowing standard patterns and APIs. Writing efficient, readable code using these libraries.

MediumTechnical
62 practiced
For an imbalanced binary classification problem where the positive class is 1% of samples, explain why ROC AUC can be misleading. Using scikit-learn, write code to compute the precision-recall curve and average precision score from predicted probabilities and explain when PR AUC is preferred over ROC AUC.
HardTechnical
61 practiced
Explain numpy.memmap and np.lib.stride_tricks.sliding_window_view. Given a very large 1D signal stored on disk, show how to compute sliding window features of width 100 without loading the entire signal into memory using memmap and sliding_window_view. Provide code and list caveats such as writeability and alignment.
MediumTechnical
53 practiced
You receive a DataFrame of 20 million rows where numeric columns are float64 and many string columns repeat values. Describe and show pandas code to reduce memory footprint: downcast numeric types, convert repeated strings to categorical dtype, and use sparse dtypes where appropriate. Include how to compute and report the estimated memory saving.
EasyTechnical
54 practiced
Write Python code using scikit-learn to construct a Pipeline that scales numeric features with StandardScaler, fits a LogisticRegression with L2 penalty, and uses cross_val_score to evaluate ROC AUC. Explain why using a Pipeline is important when performing cross-validation and how it prevents data leakage.
MediumTechnical
60 practiced
Compare SimpleImputer (mean, median, most_frequent), KNNImputer, and IterativeImputer in scikit-learn. For a dataset with mixed numeric and categorical features and approximately 10% MCAR missingness, which strategy would you choose and why? Include a short code snippet showing how to apply KNNImputer on numeric columns within a pipeline.

Unlock Full Question Bank

Get access to hundreds of Scikit Learn, Pandas, and NumPy Usage interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.