| /* ----------------------------------------------------------------------- *//** |
| * |
| * 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. |
| * |
| * @file pred_metrics.sql_in |
| * |
| * @brief A collection of summary statistics to gauge model |
| * accuracy based on predicted values vs. ground-truth values. |
| * @date April 2016 |
| * |
| * |
| *//* ----------------------------------------------------------------------- */ |
| |
| CREATE TABLE test_set( |
| pred FLOAT8, |
| obs FLOAT8 |
| ); |
| |
| INSERT INTO test_set VALUES |
| (37.5,53.1), (12.3,34.2); |
| |
| DROP TABLE IF EXISTS table_out; |
| SELECT mean_squared_error( 'test_set', 'table_out', 'pred', 'obs'); |
| DROP TABLE IF EXISTS table_out; |
| SELECT adjusted_r2_score( 'test_set', 'table_out', 'pred', 'obs', 3, 100); |
| DROP TABLE IF EXISTS table_out; |
| SELECT confusion_matrix( 'test_set', 'table_out', 'pred', 'obs'); |
| DROP TABLE IF EXISTS table_out; |
| |
| CREATE TABLE test_binary( |
| pred FLOAT8, |
| obs FLOAT8 |
| ); |
| |
| INSERT INTO test_binary VALUES |
| (0.5,0), (0.2,1.0); |
| SELECT binary_classifier( 'test_binary', 'table_out', 'pred', 'obs'); |
| DROP TABLE IF EXISTS table_out; |
| |
| SELECT area_under_roc( 'test_binary', 'table_out', 'pred', 'obs'); |
| DROP TABLE IF EXISTS table_out; |