SVMSparsePredict Function Example | Teradata Vantage - 17.05 - SVMSparsePredict Example - Teradata Database

Teradata Vantage™ - Advanced SQL Engine Analytic Functions

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.00
17.05
created_date
June 2020
category
Programming Reference
featnum
B035-1206-170K

Input

  • InputTable: svm_iris_input_test
  • Model: svm_iris_model, output by ML Engine SVMSparse function

    The model is in binary format. To display its readable content, use ML Engine SVMSparseSummary function.

svm_iris_input_test
id species attribute value
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 SVMSparsePredict (
    ON svm_iris_input_test AS InputTable PARTITION BY id
    ON svm_iris_model AS Model DIMENSION
    USING
    IDColumn ('id')
    AttributeNameColumn ('attribute')
    AttributeValueColumn ('value')
    Accumulate ('species')
  ) AS dt
) WITH DATA;

Output

This query returns the following table:

SELECT * FROM svm_iris_predict_out ORDER BY id;
id predict_value predict_confidence species
5 setosa 0.878736053291771 setosa
10 setosa 0.827684323576856 setosa
15 setosa 0.933727152238982 setosa
... ... ... ...

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.946666666666667