Github user decibel commented on a diff in the pull request: https://github.com/apache/incubator-madlib/pull/35#discussion_r58973285 --- Diff: src/ports/postgres/modules/convex/utils_regularization.py_in --- @@ -47,14 +46,22 @@ def __utils_dep_var_scale(**kwargs): The output will be stored in a temp table: a mean array and a std array This function is also used in lasso. + + Parameters: + schema_madlib -- madlib schema + tbl_data -- original data + col_ind_var -- independent variables column + col_dep_var -- dependent variable column """ + y_scale = plpy.execute( """ select - avg({col_dep_var}) as mean, + avg(case when not {schema_madlib}.array_contains_null({col_ind_var}) then {col_dep_var} end) as mean, 1 as std --- End diff -- That's not very defensive programming (assuming that the table column will always be NOT NULL). BUT... I don't think that's necessary anyway. avg() should correctly handle NULLs: ```SQL SELECT avg(unnest) FROM unnest('{1,2,NULL,NULL,NULL}'::int[]); avg -------------------- 1.5000000000000000 (1 row) ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---