This is an automated email from the ASF dual-hosted git repository.
njayaram pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/madlib.git
The following commit(s) were added to refs/heads/master by this push:
new 01bfbcb MLP: Fix column names in prediction output table
01bfbcb is described below
commit 01bfbcbfb4547bc0e60f2e9a315f8bcbe9ec66e1
Author: Himanshu Pandey <[email protected]>
AuthorDate: Thu May 2 13:44:55 2019 -0700
MLP: Fix column names in prediction output table
JIRA: MADLIB-1323
Change column names for pred_type=prob to have 'prob_' prefix, instead
of 'estimated_prob_'. This commit also adds test cases for this change
in dev-check.
Closes #384
---
src/ports/postgres/modules/convex/mlp_igd.py_in | 12 ++++--------
src/ports/postgres/modules/convex/test/mlp.sql_in | 7 +++++++
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/ports/postgres/modules/convex/mlp_igd.py_in
b/src/ports/postgres/modules/convex/mlp_igd.py_in
index 3d93a9a..b290c5f 100644
--- a/src/ports/postgres/modules/convex/mlp_igd.py_in
+++ b/src/ports/postgres/modules/convex/mlp_igd.py_in
@@ -59,6 +59,8 @@ from utilities.validate_args import output_tbl_valid
from utilities.validate_args import table_exists
from utilities.validate_args import quote_ident
from utilities.minibatch_validation import validate_dependent_var_for_minibatch
+from utilities.utilities import create_cols_from_array_sql_string
+
@MinWarning("error")
@@ -1048,14 +1050,8 @@ def mlp_predict(schema_madlib, model_table, data_table,
id_col_name,
else:
intermediate_col = unique_string()
if classes:
- # we cannot call sql quote_ident on the class value because
- # aliasing does not support quote_ident. Hence calling our
- # python implementation of quote_ident
- score_format = ',\n'.join([
- 'CAST({interim}[{j}] as DOUBLE PRECISION) as "{c_str}"'.
- format(j=i + 1, c_str=quote_ident("estimated_prob_{0}".
- format(str(c))).strip(' "'), interim=intermediate_col)
- for i, c in enumerate(classes)])
+ score_format = create_cols_from_array_sql_string(
+ classes, intermediate_col, 'prob', 'double precision',
False, 'MLP')
else:
# Case when the training step did not have to one-hot encode
# the dependent var.
diff --git a/src/ports/postgres/modules/convex/test/mlp.sql_in
b/src/ports/postgres/modules/convex/test/mlp.sql_in
index 2d66815..9053df7 100644
--- a/src/ports/postgres/modules/convex/test/mlp.sql_in
+++ b/src/ports/postgres/modules/convex/test/mlp.sql_in
@@ -454,6 +454,13 @@ SELECT mlp_predict(
'mlp_prediction_batch_output',
'prob');
SELECT * FROM mlp_prediction_batch_output;
+
+-- assert to test if the newly created column name exists and matches the count
+SELECT assert(count(*) =3, 'Column Names does not exists')
+ from pg_attribute
+ where attrelid = 'mlp_prediction_batch_output'::regclass
+ and attname in( 'prob_1', 'prob_2','prob_3');
+
DROP TABLE IF EXISTS mlp_prediction_batch_output;
DROP TABLE IF EXISTS mlp_class_batch, mlp_class_batch_summary,
mlp_class_batch_standardization;