The team needs a reliable implementation for feature cleaning in a production-oriented ML workflow. A small implementation error can change the model input or metric enough to make a downstream result misleading.
Replace NaN entries in each feature column with that column's mean computed from the observed values.
Process each column independently: compute the mean of its observed (non-NaN) values and put it in place of every NaN in that column. A column with no observed value stays NaN.
Implement solve(X).
Returns. Return a new float NumPy matrix of the same shape. The input is not modified.
Example 1
Input:
solve([[1.0, float('nan')], [3.0, 5.0]])
Output:
[[1.0, 5.0], [3.0, 5.0]]
Example 2
Input:
solve([[1.0, 2.0], [float('nan'), 4.0], [5.0, float('nan')]])
Output:
[[1.0, 2.0], [3.0, 4.0], [5.0, 3.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.