| /* ----------------------------------------------------------------------- *//** |
| * |
| * 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. |
| * |
| *//* ----------------------------------------------------------------------- */ |
| |
| /* ----------------------------------------------------------------------------- |
| * Test Cross Validation (for ridge regression) |
| * -------------------------------------------------------------------------- */ |
| |
| CREATE TABLE "Lin_housing_wi" ("X" float8[], "Y" float8); |
| COPY "Lin_housing_wi" FROM STDIN NULL '?'; |
| {1,0.00632,18.00,2.310,0,0.5380,6.5750,65.20,4.0900,1,296.0,15.30,396.90,4.98} 24.00 |
| {1,0.02731,0.00,7.070,0,0.4690,6.4210,78.90,4.9671,2,242.0,17.80,396.90,9.14} 21.60 |
| {1,0.02729,0.00,7.070,0,0.4690,7.1850,61.10,4.9671,2,242.0,17.80,392.83,4.03} 34.70 |
| {1,0.03237,0.00,2.180,0,0.4580,6.9980,45.80,6.0622,3,222.0,18.70,394.63,2.94} 33.40 |
| {1,0.10959,0.00,11.930,0,0.5730,6.7940,89.30,2.3889,1,273.0,21.00,393.45,6.48} 22.00 |
| {1,0.04741,0.00,11.930,0,0.5730,6.0300,80.80,2.5050,1,273.0,21.00,396.90,7.88} 11.90 |
| \. |
| |
| SELECT cross_validation_general( |
| -- Training function |
| 'cv_linregr_train', |
| ARRAY['%data%', '"X"', '"Y"', '%model%']::varchar[], |
| '{varchar, varchar, varchar, varchar}'::varchar[], |
| -- |
| -- No free parameter to scan |
| NULL::varchar, |
| NULL, |
| -- |
| -- Prediction function |
| 'cv_linregr_predict', |
| ARRAY['%model%', '%data%', '"X"', '%id%', '%prediction%']::varchar[], |
| '{varchar, varchar, varchar, varchar, varchar}'::varchar[], |
| -- |
| -- Error measuring function |
| 'mse_error', |
| ARRAY['%prediction%', '%data%', '%id%', '"Y"', '%error%']::varchar[], |
| '{varchar, varchar, varchar, varchar, varchar}'::varchar[], |
| -- |
| '"Lin_housing_wi"', -- Data set |
| NULL, -- No unique ID associated with rows |
| False, -- If there is a unique ID, is it random? |
| -- |
| 'cv_linregr_result', -- Result |
| ARRAY['"X"', '"Y"']::varchar[], -- Data columns |
| 2 -- CV fold |
| ); |
| |