ShapeletSupervisedClassifier Example | Teradata Vantage - ShapeletSupervisedClassifier Example - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

Input

  • InputTable: shapelets_test, which has additional data from the data set used to train the model
  • Model: shapelets_model, output table of ShapeletSupervised Example
InputTable: shapelets_test
id period stockprice stock_category
5 22418 460 Technology
5 22419 457 Technology
5 22420 452 Technology
5 22421 459 Technology
5 22422 462 Technology
5 22423 459 Technology
5 22424 463 Technology
5 22425 479 Technology
5 22426 493 Technology
5 22427 490 Technology
... ... ... ...

SQL Call

CREATE MULTISET TABLE shapelets_predict AS (
  SELECT * FROM ShapeletSupervisedClassifier (
    ON shapelets_test AS InputTable PARTITION BY id ORDER BY period
    ON shapelets_model AS Model DIMENSION ORDER BY shapelet_id, time_instant
  USING
  TimeInterval (1)
  TargetColumn ('stockprice')
  Accumulate ('stock_category')
  ) AS dt
) WITH DATA;

Output

SELECT * FROM shapelets_predict ORDER BY 1;

The column stock_category contains the original category.

 id predicted_category stock_category 
 -- ------------------ -------------- 
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  5 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  6 technology         technology    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  7 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare    
  8 healthcare         healthcare

Prediction Accuracy

SELECT (SELECT COUNT(id) FROM shapelets_predict
  WHERE predicted_category = stock_category)/
    (SELECT COUNT(id) FROM shapelets_predict) AS prediction_accuracy;
 prediction_accuracy 
 ------------------- 
                   1

The prediction accuracy is 100% because the predicted and original categories are the same.

Download a zip file of all examples and a SQL script file that creates their input tables.