Impute Missing Values and Normalize Columns
Updated
Problem statement
In each column of dataset, treat zero as missing and replace it with the mean of that column's nonzero values. Then z-score normalize the imputed column using its population mean and population standard deviation.
Function
imputeAndNormalize(dataset: double[][]) → double[][]Examples
Example 1
dataset = [[1,2,0],[0,1,1],[5,6,5]]return = [[-1.224744871391589,-0.4629100498862757,0.0],[0.0,-0.9258200997725514,-1.224744871391589],[1.224744871391589,1.3887301496588271,1.224744871391589]]Zeros become the nonzero column means before population z-score normalization.
Constraints
2 <= dataset.length <= 50.1 <= dataset[i].length <= 50and all rows have equal length.- Every column has at least two different nonzero values.
- Results use absolute tolerance
1e-5.
More Luma AI Online Assessment questions
- Build a Gaussian Blur KernelOA · Seen Jun 2026
- Center Crop a Grayscale ImageOA · Seen Jun 2026
- Minimum Euclidean Distance Between PointsOA · Seen Jun 2026
- Numerically Stable SoftmaxOA · Seen Jun 2026
- Rotate a Rectangular Image ClockwiseOA · Seen Jun 2026
- Triangle Flags from Adjacent ElementsOA · Seen Jun 2026
Similar questions at other companies
- Rotate a Square Matrix 90 Degrees ClockwiseZipRecruiter · OAZipRecruiter interview questions
- Survey Table: Group Given an AnswerSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Optimal Central WarehouseGoogle · ONSITE INTERVIEWGoogle interview questions
- Linear Layer Forward and Backward PassesMeta · ONSITE INTERVIEWMeta interview questions
- Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
- Rotate a Square Grid ClockwiseC3.ai · ONSITE INTERVIEWC3.ai interview questions
- Linear, Sigmoid and L2 Forward and Backward PassesNVIDIA · PHONE SCREENNVIDIA interview questions
- Rotate ImageTokopedia · PHONE SCREENTokopedia interview questions
- Rotate ImageSambaNova Systems · PHONE SCREENSambaNova Systems interview questions
- Matrix MultiplicationeBay · ONSITE INTERVIEWeBay interview questions