Skip to content

Commit

Permalink
MLP: Fix bug in array dep var for regression
Browse files Browse the repository at this point in the history
MLP training for regression fails if the dependent var type is an array.
This is because the variable dependent_varname was not updated to
reflect the new column created in the standardized table. This commit
fixes that issue.

Co-authored-by: Nikhil Kak <nkak@pivotal.io>
  • Loading branch information
njayaram2 and kaknikhil committed Apr 10, 2018
1 parent 5a71ff6 commit 47eefc1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ports/postgres/modules/convex/mlp_igd.py_in
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,21 @@ def mlp(schema_madlib, source_table, output_table, independent_varname,
normalize_data(locals())
dependent_vartype = get_expr_type(dependent_varname, source_table)

# We are now using tbl_data_scaled, so change the dependent
# varname accordingly.
dependent_varname = col_dep_var_norm_new
if is_classification:
# If dependent variable is an array during classification, assume
# that it is already one-hot-encoded.
if "[]" in dependent_vartype:
# We are now using tbl_data_scaled, so change the dependent
# varname accordingly.
dependent_varname = col_dep_var_norm_new
num_output_nodes = get_col_dimension(tbl_data_scaled,
dependent_varname)
else:
labels = plpy.execute("SELECT DISTINCT {0} FROM {1}".
format(dependent_varname, source_table))
format(dependent_varname_backup, source_table))
num_output_nodes = len(labels)
for label_obj in labels:
label = _format_label(label_obj[dependent_varname])
label = _format_label(label_obj[dependent_varname_backup])
classes.append(label)
classes.sort()
level_vals_str = ','.join(["{0}={1}".format(
Expand Down

0 comments on commit 47eefc1

Please sign in to comment.