TD_NaiveBayesTextClassifierTrainer Function Example | Teradata Vantage - Example: Using TD_NaiveBayesTextClassifierTrainer with Multinomial Model Type - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

TD_NaiveBayesTextClassifierTrainer InputTable

doc_id category token   
 ------ -------- ------- 
      1 no_crash vehicl 
      1 no_crash motor  
      1 no_crash separ  
      1 no_crash from   
      1 no_crash frame  
      2 crash    deploy 
      2 crash    anoth  
      2 crash    end    
      2 crash    vehicl 
      2 crash    70mph  
      2 crash    airbag 
      2 crash    rear   
      3 no_crash sunroof
      3 no_crash leak   
      4 crash    driver 
      4 crash    sustain
      4 crash    injuri 

TD_NaiveBayesTextClassifierTrainer SQL Call

SELECT * FROM TD_NaiveBayesTextClassifierTrainer (
   ON complaints_tokenized AS InputTable
   USING
   TokenColumn ('token')
   DocCategoryColumn ('category')
   ModelType ('Multinomial')
) AS dt;

TD_NaiveBayesTextClassifierTrainer Output Table

token                                 category    prob        
 ------------------------------------- ----------- ----------- 
 driver                                crash       0.076923077
 vehicl                                no_crash    0.086956522
 leak                                  no_crash    0.086956522
 anoth                                 crash       0.076923077
 deploy                                crash       0.076923077
 airbag                                crash       0.076923077
 from                                  no_crash    0.086956522
 70mph                                 crash       0.076923077
 NAIVE_BAYES_PRIOR_PROBABILITY         crash       0.588235294
 separ                                 no_crash    0.086956522
 end                                   crash       0.076923077
 sunroof                               no_crash    0.086956522
 injuri                                crash       0.076923077
 NAIVE_BAYES_MISSING_TOKEN_PROBABILITY crash       0.038461538
 rear                                  crash       0.076923077
 vehicl                                crash       0.076923077
 NAIVE_BAYES_PRIOR_PROBABILITY         no_crash    0.411764706
 NAIVE_BAYES_MISSING_TOKEN_PROBABILITY no_crash    0.043478261
 NAIVE_BAYES_TEXT_MODEL_TYPE           MULTINOMIAL 1.000000000
 frame                                 no_crash    0.086956522
 motor                                 no_crash    0.086956522
 sustain                               crash       0.076923077