| /* ----------------------------------------------------------------------- *//** |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| * |
| *//* ----------------------------------------------------------------------- */ |
| |
| m4_include(`SQLCommon.m4') |
| /* ----------------------------------------------------------------------------- |
| * Test knn. |
| * |
| * -------------------------------------------------------------------------- */ |
| |
| drop table if exists knn_train_data; |
| create table knn_train_data ( |
| id integer, |
| data integer[], |
| label integer); |
| copy knn_train_data (id, data, label) from stdin delimiter '|'; |
| 1|{1,1}|1 |
| 2|{2,2}|1 |
| 3|{3,3}|1 |
| 4|{4,4}|1 |
| 5|{4,5}|1 |
| 6|{20,50}|0 |
| 7|{10,31}|0 |
| 8|{81,13}|0 |
| 9|{1,111}|0 |
| \. |
| DROP TABLE IF EXISTS knn_test_data; |
| create table knn_test_data ( |
| id integer, |
| data integer[]); |
| copy knn_test_data (id, data) from stdin delimiter '|'; |
| 1|{2,1} |
| 2|{2,6} |
| 3|{15,40} |
| 4|{12,1} |
| 5|{2,90} |
| 6|{50,45} |
| \. |
| |
| 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,False,'MADLIB_SCHEMA.squared_dist_norm2',False); |