The InputTable, svm_iris, is in dense format. It contains four iris attributes (sepal length, sepal width, petal length, and petal width), grouped into three categories (setosa, versicolor, and virginica).
id | sepal_length | sepal_width | petal_length | petal_width | species |
---|---|---|---|---|---|
1 | 5.1 | 3.5 | 1.4 | 0.2 | setosa |
2 | 4.9 | 3 | 1.4 | 0.2 | setosa |
3 | 4.7 | 3.2 | 1.3 | 0.2 | setosa |
4 | 4.6 | 3.1 | 1.5 | 0.2 | setosa |
5 | 5 | 3.6 | 1.4 | 0.2 | setosa |
6 | 5.4 | 3.9 | 1.7 | 0.4 | setosa |
7 | 4.6 | 3.4 | 1.4 | 0.3 | setosa |
8 | 5 | 3.4 | 1.5 | 0.2 | setosa |
9 | 4.4 | 2.9 | 1.4 | 0.2 | setosa |
10 | 4.9 | 3.1 | 1.5 | 0.1 | setosa |
11 | 5.4 | 3.7 | 1.5 | 0.2 | setosa |
12 | 4.8 | 3.4 | 1.6 | 0.2 | setosa |
13 | 4.8 | 3 | 1.4 | 0.1 | setosa |
14 | 4.3 | 3 | 1.1 | 0.1 | setosa |
... | ... | ... | ... | ... | ... |
Train and Test Sets
The input data set has 150 rows that are split into a train set (80%) and a test set (20%). You can perform the split either with the following code or with the Sampling (ML Engine) function (giving the SampleFraction syntax element the value 0.8).
DROP TABLE svm_iris_train; DROP TABLE svm_iris_test; CREATE MULTISET TABLE svm_iris_train AS ( SELECT * FROM svm_iris WHERE id MOD 5 <> 0 ) WITH DATA; CREATE MULTISET TABLE svm_iris_test AS ( SELECT * FROM svm_iris WHERE id MOD 5 = 0 ) WITH DATA;
This query returns the following table:
SELECT * FROM svm_iris_train ORDER BY id;
id | sepal_length | sepal_width | petal_length | petal_width | species |
---|---|---|---|---|---|
1 | 5.1 | 3.5 | 1.4 | 0.2 | setosa |
2 | 4.9 | 3 | 1.4 | 0.2 | setosa |
3 | 4.7 | 3.2 | 1.3 | 0.2 | setosa |
4 | 4.6 | 3.1 | 1.5 | 0.2 | setosa |
6 | 5.4 | 3.9 | 1.7 | 0.4 | setosa |
7 | 4.6 | 3.4 | 1.4 | 0.3 | setosa |
8 | 5 | 3.4 | 1.5 | 0.2 | setosa |
9 | 4.4 | 2.9 | 1.4 | 0.2 | setosa |
11 | 5.4 | 3.7 | 1.5 | 0.2 | setosa |
... | ... | ... | ... | ... | ... |
This query returns the following table:
SELECT * FROM svm_iris_test ORDER BY id;
id | sepal_length | sepal_width | petal_length | petal_width | species |
---|---|---|---|---|---|
5 | 5 | 3.6 | 1.4 | 0.2 | setosa |
10 | 4.9 | 3.1 | 1.5 | 0.1 | setosa |
15 | 5.8 | 4 | 1.2 | 0.2 | setosa |
20 | 5.1 | 3.8 | 1.5 | 0.3 | setosa |
25 | 4.8 | 3.4 | 1.9 | 0.2 | setosa |
30 | 4.7 | 3.2 | 1.6 | 0.2 | setosa |
35 | 4.9 | 3.1 | 1.5 | 0.2 | setosa |
40 | 5.1 | 3.4 | 1.5 | 0.2 | setosa |
45 | 5.1 | 3.8 | 1.9 | 0.4 | setosa |
50 | 5 | 3.3 | 1.4 | 0.2 | setosa |
55 | 6.5 | 2.8 | 4.6 | 1.5 | versicolor |
60 | 5.2 | 2.7 | 3.9 | 1.4 | versicolor |
65 | 5.6 | 2.9 | 3.6 | 1.3 | versicolor |
70 | 5.6 | 2.5 | 3.9 | 1.1 | versicolor |
... | ... | ... | ... | ... | ... |