Challenge: Manual Feature Centering
Swipe to start coding
You are given a small dataset X as a NumPy array of shape (n_samples, n_features). Your goal is to manually center each feature (column) by subtracting its mean, without using scikit-learn. Use vectorized NumPy operations.
- Compute the per-feature means as a 1D array
feature_meansof shape(n_features,). - Create
X_centered = X - feature_meansusing broadcasting. - Compute column means of
X_centeredto verify they are approximately zero. - Do not use loops and do not modify
Xin place.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Awesome!
Completion rate improved to 5.26
Challenge: Manual Feature Centering
Swipe to show menu
Swipe to start coding
You are given a small dataset X as a NumPy array of shape (n_samples, n_features). Your goal is to manually center each feature (column) by subtracting its mean, without using scikit-learn. Use vectorized NumPy operations.
- Compute the per-feature means as a 1D array
feature_meansof shape(n_features,). - Create
X_centered = X - feature_meansusing broadcasting. - Compute column means of
X_centeredto verify they are approximately zero. - Do not use loops and do not modify
Xin place.
Solution
Thanks for your feedback!
single