Here are the top Scikit-learn interview questions to prepare for your next role.
1️⃣ How can you extract model feature importances in Scikit-learn?
- A) Using the feature_importances_ attribute in a fitted model.
- B) Using the get_feature_importance() method.
- C) Using the importance_ attribute in a fitted model.
- D) Using the extract_importance() function from the sklearn.utils module.
2️⃣ How does OneHotEncoder differ from LabelEncoder?
- A) OneHotEncoder encodes categorical features as arrays while LabelEncoder encodes categorical features as integers.
- B) OneHotEncoder is used for numerical features while LabelEncoder is used for categorical features.
- C) OneHotEncoder creates a new column for each category while LabelEncoder creates a single column with integer values.
- D) OneHotEncoder is a part of Scikit-learn while LabelEncoder is a part of NumPy.
3️⃣ What is the role of MinMaxScaler?
- A) Standardize features by removing the mean and scaling to unit variance.
- B) Scale features to lie within a given range, typically between 0 and 1.
- C) Normalize samples individually to unit norm.
- D) Transform features by scaling each feature to a given range corresponding to the quantiles of the feature.
4️⃣ How does GridSearchCV work?
- A) It applies deep learning techniques to discover the optimal hyperparameters for a given model.
- B) It uses a genetic algorithm to evolve the hyperparameters over generations until the best set is found.
- C) It only tests the model on a random set of hyperparameters and selects the best performing set by chance.
- D) It iterates over a predefined set of hyperparameters and fits the model on each combination to determine the best set of hyperparameters.