Multiple: Re-enable tests in PCA, Pagerank

JIRA: MADLIB-1264

Some tests were commented out due to failures on GPDB 5.X.
These tests are now working and have been enabled again.

Closes #312

Co-authored-by: Arvind Sridhar <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/madlib/repo
Commit: http://git-wip-us.apache.org/repos/asf/madlib/commit/a3b59356
Tree: http://git-wip-us.apache.org/repos/asf/madlib/tree/a3b59356
Diff: http://git-wip-us.apache.org/repos/asf/madlib/diff/a3b59356

Branch: refs/heads/master
Commit: a3b59356f328fb949d63758a518aeca6d72220cf
Parents: 5ccf12e
Author: Jingyi Mei <[email protected]>
Authored: Thu Aug 16 20:12:25 2018 -0700
Committer: Rahul Iyer <[email protected]>
Committed: Thu Aug 16 20:18:21 2018 -0700

----------------------------------------------------------------------
 .../postgres/modules/graph/test/pagerank.sql_in | 23 +++++++++++---------
 src/ports/postgres/modules/pca/test/pca.sql_in  | 16 ++++++--------
 2 files changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/madlib/blob/a3b59356/src/ports/postgres/modules/graph/test/pagerank.sql_in
----------------------------------------------------------------------
diff --git a/src/ports/postgres/modules/graph/test/pagerank.sql_in 
b/src/ports/postgres/modules/graph/test/pagerank.sql_in
index 14d3371..e797812 100644
--- a/src/ports/postgres/modules/graph/test/pagerank.sql_in
+++ b/src/ports/postgres/modules/graph/test/pagerank.sql_in
@@ -60,6 +60,7 @@ INSERT INTO "EDGE" VALUES
 (5, 6, 2),
 (6, 3, 2);
 
+-- Test pagerank without group
 DROP TABLE IF EXISTS pagerank_out, pagerank_out_summary;
 SELECT pagerank(
              'vertex',        -- Vertex table
@@ -73,6 +74,8 @@ SELECT assert(relative_error(SUM(pagerank), 1) < 0.00001,
         'PageRank: Scores do not sum up to 1.'
     ) FROM pagerank_out;
 
+
+-- Test pagerank with group
 DROP TABLE IF EXISTS pagerank_gr_out;
 DROP TABLE IF EXISTS pagerank_gr_out_summary;
 SELECT pagerank(
@@ -84,7 +87,7 @@ SELECT pagerank(
              NULL,              -- Default damping factor (0.85)
              NULL,              -- Default max iters (100)
              NULL,              -- Default Threshold
-             'user_id');             -- Personlized Nodes
+             'user_id');        -- Grouping Column
 
 -- View the PageRank of all vertices, sorted by their scores.
 SELECT assert(relative_error(SUM(pagerank), 1) < 0.00001,
@@ -94,8 +97,16 @@ SELECT assert(relative_error(SUM(pagerank), 1) < 0.00001,
         'PageRank: Scores do not sum up to 1 for group 2.'
     ) FROM pagerank_gr_out WHERE user_id=2;
 
--- Tests for Personalized Page Rank
+-- Check the iteration numbers for convergency
+SELECT assert(relative_error(__iterations__, 11) = 0,
+        'PageRank: Incorrect iterations for group 1.'
+    ) FROM pagerank_gr_out_summary WHERE user_id=1;
+SELECT assert(relative_error(__iterations__, 14) = 0,
+        'PageRank: Incorrect iterations for group 2.'
+    ) FROM pagerank_gr_out_summary WHERE user_id=2;
+
 
+-- Tests for Personalized Page Rank
 -- Test without grouping
 
 DROP TABLE IF EXISTS pagerank_ppr_out;
@@ -141,14 +152,6 @@ SELECT assert(relative_error(SUM(pagerank), 1) < 0.005,
     ) FROM pagerank_ppr_grp_out WHERE user_id=1;
 select assert(array_agg(user_id order by pagerank desc)= '{2, 2, 1, 1, 2, 2, 
1, 1, 2, 1, 2, 1, 2, 1}','Unexpected Ranking with grouping ') from  
pagerank_ppr_grp_out  ;
 
--- These tests have been temporarily removed for GPDB5 alpha support
-
--- SELECT assert(relative_error(__iterations__, 27) = 0,
---         'PageRank: Incorrect iterations for group 1.'
---     ) FROM pagerank_gr_out_summary WHERE user_id=1;
--- SELECT assert(relative_error(__iterations__, 31) = 0,
---         'PageRank: Incorrect iterations for group 2.'
---     ) FROM pagerank_gr_out_summary WHERE user_id=2;
 
 -- Test to capture corner case reported in 
https://issues.apache.org/jira/browse/MADLIB-1229
 

http://git-wip-us.apache.org/repos/asf/madlib/blob/a3b59356/src/ports/postgres/modules/pca/test/pca.sql_in
----------------------------------------------------------------------
diff --git a/src/ports/postgres/modules/pca/test/pca.sql_in 
b/src/ports/postgres/modules/pca/test/pca.sql_in
index 5a97c94..1510254 100644
--- a/src/ports/postgres/modules/pca/test/pca.sql_in
+++ b/src/ports/postgres/modules/pca/test/pca.sql_in
@@ -145,16 +145,14 @@ COPY mat (id, row_vec, grp) FROM stdin delimiter '|';
 16|{739,651,678,577,273,935,661,47,373,618}|2
 \.
 
--- This test has been temporarily removed for GPDB5 alpha support
-
 -- Learn individaul PCA models based on grouping column (grp)
--- drop table if exists result_table_214712398172490837;
--- drop table if exists result_table_214712398172490837_mean;
--- drop table if exists result_table_214712398172490838;
--- select pca_train('mat', 'result_table_214712398172490837', 'id', 0.8,
--- 'grp', 5, FALSE, 'result_table_214712398172490838');
--- select * from result_table_214712398172490837;
--- select * from result_table_214712398172490838;
+drop table if exists result_table_214712398172490837;
+drop table if exists result_table_214712398172490837_mean;
+drop table if exists result_table_214712398172490838;
+select pca_train('mat', 'result_table_214712398172490837', 'id', 0.8,
+'grp', 5, FALSE, 'result_table_214712398172490838');
+select * from result_table_214712398172490837;
+select * from result_table_214712398172490838;
 
 -- Matrix in the column format
 DROP TABLE IF EXISTS cmat;

Reply via email to