1.1 - 8.10 - NaiveBayesTextClassifierPredict_MLE Example: TopK - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

Input

  • PredictorValues: created by applying the TextTokenizer function to complaints_with_docnames, a log of vehicle complaints
  • Model: complaints_tokens_model, output by NaiveBayesTextClassifierTrainer Example
InputTable for TextTokenizer: complaints_with_docnames
doc_id doc_name text_data
1 A electrical control module is shortening out, causing the vehicle to stall. engine will become totally inoperative. consumer had to change alternator/ battery and starter, and module replaced 4 times, but defect still occurring cannot determine what is causing the problem.
2 B abs brakes fail to operate properly, and air bags failed to deploy during a crash at approx. 28 mph impact. manufacturer notified.
3 C while driving at 60 mph gas pedal got stuck due to the rubber that is around the gas pedal.
4 D there is a knocking noise coming from the catalyitc converter ,and the vehicle is stalling. also, has problem with the steering.
5 E consumer was making a turn ,driving at approx 5- 10 mph when consumer hit another vehicle. upon impact, dual airbags did not deploy . all damage was done from engine to transmission,to the front of vehicle, and the vehicle considered a total loss.
6 F wheel bearing and hubs cracked, causing the metal to grind when making a right turn. also when applying the brakes, pedal goes to the floor, cause unknown. was advised by midas not to drive vehicle- wheele could come off.
7 G driving about 5-10 mph, the vehicle had a low frontal impact in which the other vehicle had no damages. upon impact, driver's and the passenger's air bags did not deploy, resulting in injuries. please provide further information and vin#.
8 H the air bag warning light has come on. indicating airbags are inoperative.they were fixed one at the time, but problem has reoccurred.
9 I consumer was driving west when the other car was going east. the other car turned in front of consumer's vehicle, consumer hit other vehicle and started to spin around ,couldn't stop, resulting in a crash. upon impact, airbags didn't deploy.
10 J while driving about 65 mph and the transmisison made a strange noise, and the left front axle locked up. the dealer has repaired the vehicle.

SQL Call

SELECT * FROM NaiveBayesTextClassifierPredict_MLE (
  ON (
    SELECT doc_id, doc_name, lower(token) AS token FROM TextTokenizer (
      ON complaints_with_docnames PARTITION BY ANY
      USING
      TextColumn ('text_data')
      OutputByWord ('true')
      Accumulate ('doc_id','doc_name')
    ) AS dt1
  ) AS PredictorValues PARTITION BY doc_id
  ON complaints_tokens_model AS "model" DIMENSION
  USING
  InputTokenColumn ('token')
  ModelType ('Bernoulli')
  DocIDColumns ('doc_id')
  Accumulate ('doc_name')
  OutputProb ('true')
  TopK (1)
) AS dt;

Output

 doc_id prediction loglik              prob               doc_name 
 ------ ---------- ------------------- ------------------ -------- 
      4 no_crash    -80.04840368356992 0.9999999999998849 D       
      1 no_crash    -98.37344066139619 0.9999999999999973 A       
      3 no_crash    -74.45875519616708  0.999999999999917 C       
      8 no_crash     -91.9733577040394 0.9999999948239724 H       
      5 crash      -115.41886392381605 0.9164844344558424 E       
      7 crash      -111.70603934552986  0.977567760977105 G       
      9 no_crash   -108.85303741743412 0.9997172911016146 I       
      2 no_crash    -93.41932479796594 0.9999976259267273 B       
      6 no_crash   -116.11212602416647 0.9999998313326355 F       
     10 no_crash    -82.65103082787691 0.9999999998244187 J

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