SVMSparsePredict_MLE Example - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.10
1.1
Published
October 2019
Language
English (United States)
Last Update
2019-12-31
dita:mapPath
ima1540829771750.ditamap
dita:ditavalPath
jsj1481748799576.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

For examples that use the syntax elements TopK and Responses, see SVMDensePredict Examples.

Input

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

Output

SELECT * FROM svm_iris_predict_out ORDER BY id;
 id  predict_value predict_confidence species    
 --- ------------- ------------------ ---------- 
   5 setosa        0.9712114283894899 setosa    
  10 setosa         0.891209210996914 setosa    
  15 setosa        0.9884800781364631 setosa    
  20 setosa        0.9801252987281942 setosa    
  25 setosa        0.9009144408735393 setosa    
  30 setosa        0.9156565763906245 setosa    
  35 setosa        0.9070437281039562 setosa    
  40 setosa        0.9454114427327119 setosa    
  45 setosa        0.9647235775345661 setosa    
  50 setosa         0.946083635829095 setosa    
  55 versicolor    0.7913472663302237 versicolor
  60 virginica     0.4508441718655297 versicolor
  65 versicolor    0.5617925890708627 versicolor
  70 versicolor    0.8426985427898467 versicolor
  75 versicolor    0.8489260026561855 versicolor
  80 versicolor    0.8069899264075321 versicolor
  85 virginica     0.6671521277894518 versicolor
  90 versicolor    0.6840553604630605 versicolor
  95 versicolor    0.6749299918507788 versicolor
 100 versicolor    0.6965141822869577 versicolor
 105 virginica     0.9641473480486245 virginica 
 110 virginica     0.9733659600265973 virginica 
 115 virginica     0.9929219369972574 virginica 
 120 versicolor    0.5344118196177321 virginica 
 125 virginica     0.9048321676266392 virginica 
 130 versicolor    0.7838136004714887 virginica 
 135 versicolor    0.5176868161785055 virginica 
 140 virginica     0.7979779423920981 virginica 
 145 virginica     0.9851460930914178 virginica 
 150 virginica     0.8614044973987343 virginica

Prediction Accuracy

SELECT (SELECT count(id)
  FROM svm_iris_predict_out
  WHERE predict_value = species)/(1.00 * (
  SELECT count(id) FROM svm_iris_predict_out) )
AS prediction_accuracy;
 prediction_accuracy 
 ------------------- 
                0.83

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.