The table of raw test data, housing_test, is described by the following two tables.
sn | price | lotsize | bedrooms | bathrms | stories | driveway | recroom | fullbase |
---|---|---|---|---|---|---|---|---|
13 | 27000 | 1700 | 3 | 1 | 2 | yes | no | no |
16 | 37900 | 3185 | 2 | 1 | 1 | yes | no | no |
25 | 42000 | 4960 | 2 | 1 | 1 | yes | no | no |
38 | 67000 | 5170 | 3 | 1 | 4 | yes | no | no |
53 | 68000 | 9166 | 2 | 1 | 1 | yes | no | yes |
104 | 132000 | 3500 | 4 | 2 | 2 | yes | no | no |
111 | 43000 | 5076 | 3 | 1 | 1 | no | no | no |
117 | 93000 | 3760 | 3 | 1 | 2 | yes | no | no |
132 | 44500 | 3850 | 3 | 1 | 2 | yes | no | no |
140 | 43000 | 3750 | 3 | 1 | 2 | yes | no | no |
142 | 40000 | 2650 | 3 | 1 | 2 | yes | no | yes |
157 | 60000 | 2953 | 3 | 1 | 2 | yes | no | yes |
... | ... | ... | ... | ... | ... | ... | ... | ... |
gashw | airco | prefarea | garagepl | homestyle |
---|---|---|---|---|
no | no | 0 | no | Classic |
no | yes | 0 | no | Classic |
no | no | 0 | no | Classic |
no | yes | 0 | no | Eclectic |
no | yes | 2 | no | Eclectic |
yes | no | 2 | no | bungalow |
no | no | 0 | no | Classic |
yes | no | 2 | no | Eclectic |
no | no | 0 | no | Classic |
no | no | 0 | no | Classic |
no | no | 1 | no | Classic |
no | yes | 0 | no | Eclectic |
... | ... | ... | ... | ... |
Create the input table for the AdaBoostPredict function, housing_test_att, by using the Unpivot function on the table of raw data, housing_test:
CREATE TABLE housing_test_att distribute BY HASH(sn) AS ( SELECT * FROM unpivot ( ON housing_test ColsToUnpivot ('price', 'lotsize', 'bedrooms', 'bathrms', 'stories', 'driveway', 'recroom', 'fullbase', 'gashw', 'airco', 'garagepl', 'prefarea') ColsToAccumulate ('sn') ) );
This query returns the following table:
SELECT * FROM housing_test_att ORDER BY 1, 2;
sn | attribute | value |
---|---|---|
13 | airco | no |
13 | bathrms | 1 |
13 | bedrooms | 3 |
13 | driveway | yes |
13 | fullbase | no |
13 | garagepl | 0 |
13 | gashw | no |
13 | lotsize | 1700.0 |
13 | prefarea | no |
13 | price | 27000.0 |
13 | recroom | no |
13 | stories | 2 |
16 | airco | yes |
16 | bathrms | 1 |
16 | bedrooms | 2 |
16 | driveway | yes |
16 | fullbase | no |
16 | garagepl | 0 |
16 | gashw | no |
16 | lotsize | 3185.0 |
16 | prefarea | no |
16 | price | 37900.0 |
16 | recroom | no |
16 | stories | 1 |
... | ... | ... |