You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@madlib.apache.org by orhankislal <gi...@git.apache.org> on 2017/10/11 19:39:53 UTC

[GitHub] madlib pull request #184: Knn dev 1129

Github user orhankislal commented on a diff in the pull request:

    https://github.com/apache/madlib/pull/184#discussion_r144114755
  
    --- Diff: src/ports/postgres/modules/knn/test/knn.sql_in ---
    @@ -55,15 +71,23 @@ copy knn_test_data (id, "DATA") from stdin delimiter '|';
     6|{50,45}
     \.
     drop table if exists madlib_knn_result_classification;
    -select knn('"KNN_TRAIN_DATA"','"DATA"','label','knn_test_data','"DATA"','id','madlib_knn_result_classification','c',3);
    +select knn('knn_train_data','data','id','label','knn_test_data','data','id','madlib_knn_result_classification',3,False);
     select assert(array_agg(prediction order by id)='{1,1,0,1,0,0}', 'Wrong output in classification with k=3') from madlib_knn_result_classification;
     
    +drop table if exists madlib_knn_result_classification;
    +select knn('knn_train_data','data','id','label','knn_test_data','data','id','madlib_knn_result_classification',3,True);
    +select assert((k_nearest_neighbours )='{1,2,3}', 'Wrong output in classification with k=3') from madlib_knn_result_classification where id = 1;
    --- End diff --
    
    This assertion might fail on gpdb since the order of the nearest neighbors might change. I would suggest using a query like `select unnest(k_nearest_neighbours) = ANY('{1,2,3}'::int[]) from madlib_knn_result_classification where id = 1;` 


---