Practice
1. Which regularization technique is most suitable for feature selection in a linear regression model?
easy
Solution
Step 1: Identify the purpose of feature selection.
L1 Lasso regularization can shrink some coefficients to zero, effectively selecting features.Step 2: Eliminate wrong options.
L2 Ridge does not shrink coefficients to zero. Elastic Net combines L1 and L2 but is not as direct for feature selection. Dropout is not used in linear regression.Final Answer:
Option A -> Option AQuick Check:
L1 Lasso zeros coefficients for selection. [OK]
Hint: L1 Lasso zeros coefficients for selection. [OK]
Common Mistakes:
2. What will be the output of the following Python code snippet using NumPy for weighted sampling?
import numpy as np
np.random.seed(0)
weights = [0.1, 0.3, 0.6]
choices = ['A', 'B', 'C']
result = np.random.choice(choices, p=weights)
print(result)easy
Solution
Step 1: Understand weighted sampling.
np.random.choice with 'p' parameter uses specified probabilities for sampling.Step 2: Analyze the code.
Weights [0.1, 0.3, 0.6] mean 'C' is most likely, but not guaranteed.Final Answer:
Option A -> Option AQuick Check:
np.random.choice uses 'p' for weighted sampling [[check]]
Hint: np.random.choice uses 'p' for weighted sampling [[check]]
Common Mistakes:
3. You are tasked with designing a recommendation system for a streaming service. How would you apply the bias-variance tradeoff to optimize user satisfaction?
hard
Solution
Step 1: Understand the application context
Recommendation systems need to balance accuracy and generalization to optimize user satisfaction.Step 2: Apply the bias-variance tradeoff
Balancing model complexity helps avoid overfitting while capturing user preferences effectively.Final Answer:
Option A -> Option AQuick Check:
Balance complexity for user satisfaction. [OK]
Hint: Balance complexity for user satisfaction. [OK]
Common Mistakes:
4. You are designing a system to predict stock prices using both historical and real-time data. Which approach best integrates these data sources effectively?
hard
Solution
Step 1: Identify the need for integration
A hybrid system allows for leveraging the strengths of both historical and real-time data.Step 2: Evaluate the options
Use a batch processing system to handle both data types simultaneously. does not effectively integrate real-time updates. Train separate models for historical and real-time data and average their predictions. may lead to inconsistent predictions. Rely solely on real-time data for predictions to ensure up-to-date results. ignores valuable historical data.Final Answer:
Option A -> Option AQuick Check:
Hybrid systems leverage both data types effectively. [OK]
Hint: Hybrid systems leverage both data types effectively. [OK]
Common Mistakes:
5. You are tasked with improving a model's performance on a highly imbalanced dataset. Which approach is most appropriate to prevent overfitting while addressing class imbalance?
hard
Solution
Step 1: Address class imbalance and overfitting
Class weights help balance the dataset, and early stopping prevents overfitting by halting training when validation performance stops improving.Step 2: Eliminate wrong options
Use SMOTE to oversample the minority class and increase model complexity. increases complexity, risking overfitting, Downsample the majority class and increase the learning rate. may lead to instability, and Use a simpler model with no regularization. lacks regularization, increasing overfitting risk.Final Answer:
Option C -> Option CQuick Check:
Class weights + early stopping = balanced, robust model [OK]
Hint: Class weights + early stopping = balanced, robust model [OK]
Common Mistakes:
