1.0 - 8.00 - SparseSVMPredictor Example - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

Input

  • Input table: svm_iris_input_test
  • Model table: svm_iris_model, the SVMSparse Example output table
svm_iris_input_test
id species attribute value1
5 setosa sepal_length 5.0
5 setosa sepal_width 3.6
5 setosa petal_length 1.4
5 setosa petal_width 0.2
10 setosa sepal_length 4.9
10 setosa sepal_width 3.1
10 setosa petal_length 1.5
10 setosa petal_width 0.1
15 setosa sepal_length 5.8
15 setosa sepal_width 4.0
15 setosa petal_length 1.2
15 setosa petal_width 0.2
... ... ... ...

SQL Call

CREATE MULTISET TABLE svm_iris_predict_out AS (
  SELECT * FROM SparseSVMPredictor@coprocessor (
    ON svm_iris_input_test AS input PARTITION BY id
    ON svm_iris_model AS model DIMENSION
    USING
    SampleIDColumn ('id')
    AttributeColumn ('attribute')
    ValueColumn ('value1')
    AccumulateLabel ('species')
  ) AS dt
) WITH DATA;

Output

This query returns the following table:

SELECT * FROM svm_iris_predict_out;
id predict_value predict_confidence species
5 setosa 0.867398140899245 setosa
10 setosa 0.819661754676374 setosa
15 setosa 0.927883208386689 setosa
20 setosa 0.864916306271814 setosa
25 setosa 0.762567726157518 setosa
30 setosa 0.793833738774273 setosa
35 setosa 0.81125364470445 setosa
40 setosa 0.843753709530057 setosa
45 setosa 0.797242598289854 setosa
50 setosa 0.846642017701705 setosa
55 versicolor 0.504706688492186 versicolor
60 versicolor 0.271953255632149 versicolor
65 versicolor 0.261217569263106 versicolor
70 versicolor 0.571486181065923 versicolor
75 versicolor 0.508780607775202 versicolor
80 versicolor 0.528403904925176 versicolor
85 virginica 0.357815100538804 versicolor
90 versicolor 0.457613698073775 versicolor
95 versicolor 0.437749794631343 versicolor
100 versicolor 0.396542514919166 versicolor
105 virginica 0.871426508573154 virginica
110 virginica 0.785585474251325 virginica
115 virginica 0.929674476937472 virginica
120 versicolor 0.718867788404435 virginica
125 virginica 0.669828467529083 virginica
130 versicolor 0.708950643747213 virginica
135 versicolor 0.752700333623089 virginica
140 virginica 0.513515135953709 virginica
145 virginica 0.856957955346407 virginica
150 virginica 0.626924808331081 virginica

Prediction Accuracy

This query returns the prediction accuracy:

SELECT (SELECT count(id)
FROM svm_iris_predict_out
WHERE predict_value = species)/(
  SELECT count(id) FROM svm_iris_predict_out) AS prediction_accuracy;
prediction_accuracy
0.86666666666666666667