Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
Feature clipping is a simple feature-engineering trick to reduce the impact of extreme values by capping them at chosen thresholds. In this task, you’ll clip each numeric feature column using per-feature lower and upper bounds.
Implement the function
Rules:
X in place; return a new clipped 2D array.Output:
| Argument | Type |
|---|---|
| X | np.ndarray |
| lower | np.ndarray |
| upper | np.ndarray |
| Return Name | Type |
|---|---|
| value | np.ndarray |
Return new 2D array; do not modify X.
Use Python/NumPy only; no pandas.
Bounds are per-column: lower[j], upper[j].
Use np.clip(X, lower, upper) to efficiently clip the array.
NumPy broadcasting automatically handles per-column clipping when lower and upper are of shape (n_features,).
This single function call processes the entire matrix at once without loops.