1.0 - 8.00 - HMMEvaluator Example: Loan Default Prediction - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

The example evaluates a given loan sequence against the two models: model 1 (trained on default loan cases) and model 2 (trained on paid loan cases). The models are trained and referenced from the loan default prediction example from HMMUnsupervised.

Input

The input, test_loan_prediction, is a test loan sequence, which HMMEvaluator uses to predict whether this loan is more likely to be paid in full or to default. The input table does not include observations of 7 (default) or 8 (paid). The sequence of observations in this table is the same for evaluation of both models (that is, model_id = 1 and model_id = 2).

test_loan_prediction
model_id seq_id seq_vertex_id observed_id
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      

SQL Call

The following SQL call creates the probabilities for each observation of the sequence for each model.

SELECT model_id, seq_id, observed_id, sequence_probability
  FROM HMMEvaluator (
  ON pi_loan AS InitStateProb PARTITION BY model_id
  ON A_loan AS TransProb PARTITION BY model_id
  ON B_loan AS EmissionProb PARTITION BY model_id
  ON test_loan_prediction AS observation
    PARTITION BY model_id ORDER BY seq_id, seq_vertex_id
  USING
  InitStateModelColumn ('model_id')
  InitStateColumn ('state')
  InitStateProbColumn ('probability')
  TransAttributeColumn ('model_id')
  TransFromStateColumn ('from_state')
  TransToStateColumn ('to_state')
  TransProbColumn ('probability')
  EmitModelColumn ('model_id')
  EmitStateColumn ('state')
  EmitObsColumn ('observed')
  EmitProbColumn ('probability')
  ModelColumn ('model_id')
  SeqColumn ('seq_id')
  ObsColumn ('observed_id')
) AS dt ORDER BY seq_id, model_id, sequence_probability DESC;

Output