| /* ----------------------------------------------------------------------- *//** |
| * |
| * 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. |
| * |
| *//* ----------------------------------------------------------------------- */ |
| |
| /* ----------------------------------------------------------------------------- |
| * pca Install Check. |
| * -------------------------------------------------------------------------- */ |
| |
| ----------------------------------------------------------------------------- |
| -- DENSE pca Project : Make sure all possible default calls for dense pca work |
| -- Test data (Indentical to SVD). See the SVD module for details |
| -- on how the data was generated |
| ----------------------------------------------------------------------------- |
| DROP TABLE IF EXISTS mat; |
| CREATE TABLE mat ( |
| row_id integer, |
| row_vec double precision[] |
| ); |
| |
| COPY mat (row_id, row_vec) FROM stdin delimiter '|'; |
| 1|{396,1} |
| 2|{691,58} |
| 3|{293,1} |
| 4|{462,532} |
| 5|{304,151} |
| \. |
| |
| DROP TABLE IF EXISTS result; |
| CREATE TABLE result ( |
| row_id integer, |
| principal_components double precision[], |
| std_dev double precision, |
| proportion double precision |
| ); |
| |
| DROP TABLE IF EXISTS result_mean; |
| CREATE TABLE result_mean ( |
| column_mean double precision[] |
| ); |
| |
| --To reduce runtime, we are inserting the component data instead of calling pca_train |
| TRUNCATE TABLE result, result_mean; |
| |
| COPY result (row_id, principal_components, std_dev, proportion) FROM stdin delimiter '|'; |
| 1|{0.16526842327063,-0.366421389980424}|505.194492329765|0.315197084359835 |
| 2|{0.291457976390416,-0.152774780364566}|388.886052223584|0.18677111487815 |
| \. |
| |
| COPY result_mean (column_mean) FROM stdin delimiter '|'; |
| {559.1875,479.6875} |
| \. |
| |
| |
| drop table if exists out_table; |
| drop table if exists residual_table; |
| drop table if exists result_summary_table; |
| select pca_project( 'mat', |
| 'result', |
| 'out_table', |
| 'row_id', |
| 'residual_table', |
| 'result_summary_table'); |