blob: 304ccba526f4ffef79d784b52f34cfbdf66faf6f [file]
/* ----------------------------------------------------------------------- *//**
*
* 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.
*
*//* ----------------------------------------------------------------------- */
\i m4_regexp(MADLIB_LIBRARY_PATH, `\(.*\)/lib',
`\1/../modules/pmml/test/pmml.setup.sql_in'
)
\i m4_regexp(MADLIB_LIBRARY_PATH, `\(.*\)/lib',
`\1/../modules/pmml/test/pmml.setup.datasets.sql_in'
)
m4_changequote(`<!'', `!>'')
DROP TABLE IF EXISTS linregr_model, linregr_model_summary;
SELECT linregr_train(
'houses',
'linregr_model',
'price',
'array[1, bedroom, bath, size]'
);
DROP TABLE IF EXISTS linregr_predict_output;
CREATE TABLE linregr_predict_output AS
SELECT id, linregr_predict(coef, ARRAY[1, bedroom, bath, size])
FROM linregr_model, houses;
SELECT test_pmml_output('houses', 'linregr_model', 'linregr_predict_output', 'id', 'linregr_predict', 'predicted_price_pmml_prediction');
DROP TABLE IF EXISTS linregr_model, linregr_model_summary;
SELECT linregr_train(
'houses',
'linregr_model',
'price',
'array[1, bedroom, bath, size]',
'g1, g2'
);
DROP TABLE IF EXISTS linregr_predict_output;
CREATE TABLE linregr_predict_output AS
SELECT id, linregr_model.g1, linregr_model.g2,
linregr_predict(coef, ARRAY[1, bedroom, bath, size])
FROM linregr_model, houses
WHERE linregr_model.g1=houses.g1 AND linregr_model.g2=houses.g2;
SELECT test_pmml_output('houses', 'linregr_model', 'linregr_predict_output', 'id', 'linregr_predict', 'predicted_price_pmml_prediction', 'g1,g2');
---------------- without intercept ------------------------------
DROP TABLE IF EXISTS linregr_model, linregr_model_summary;
SELECT linregr_train(
'houses',
'linregr_model',
'price',
'array[bedroom, bath, size]'
);
DROP TABLE IF EXISTS linregr_predict_output;
CREATE TABLE linregr_predict_output AS
SELECT id, linregr_predict(coef, ARRAY[bedroom, bath, size])
FROM linregr_model, houses;
SELECT test_pmml_output('houses', 'linregr_model', 'linregr_predict_output', 'id', 'linregr_predict', 'predicted_price_pmml_prediction');
DROP TABLE IF EXISTS linregr_model, linregr_model_summary;
SELECT linregr_train(
'houses',
'linregr_model',
'price',
'array[bedroom, bath, size]',
'g1, g2'
);
DROP TABLE IF EXISTS linregr_predict_output;
CREATE TABLE linregr_predict_output AS
SELECT id, linregr_model.g1, linregr_model.g2,
linregr_predict(coef, ARRAY[bedroom, bath, size])
FROM linregr_model, houses
WHERE linregr_model.g1=houses.g1 AND linregr_model.g2=houses.g2;
SELECT test_pmml_output('houses', 'linregr_model', 'linregr_predict_output', 'id', 'linregr_predict', 'predicted_price_pmml_prediction', 'g1,g2');