Input/Output mapping sample
This sample uses the Drug Study model provided in the SPSS modeler tutorials and in Watson Studio. For details you can read more about it here. The model file is available in the etc directory of the DrugTreatments sample coming with the PMML toolkit.
The model uses the following output fields:
- Age the age of the patient as integer
- BP the blood pressure as string (LOW,NORMAL,HIGH)
- Cholesterol the blood chlesterol value as string (LOW,NORMAL,HIGH)
- Na_to_K the natrium to Kalium ratio as float value
- Sex the patients sex as string (F,M)
The input stream schema for the model would look like this:
Predictors =
int32 age,
rstring sex,
rstring bloodPressure,
rstring cholesterol,
float64 NA_to_K;
The input mapping string would look like this:
Age=age,BP=bloodPressure,Cholesterol=cholesterol,Na_to_K=NA_to_K,Sex=sex
The model uses no output fields but one target named Drug. Without output fields defined, per default the model output contains the following feature values:
- PredictedValue the predicted value as string. This is the name of the drug to apply
- Confidence the confidence for the predicted value as float number
- Probability the probabilities for all the other possible output drugs as map with the drug names as keys and the confidence as values
ScoringResult =
rstring predictedValue,
float64 confidence,
map<rstring,float64> probabilities;
The output mapping string would look like this:
predictedValue=Drug.PredictedValue,confidence=Drug.Confidence,probabilities=Drug.Probability
The complete operator invocation looks like this:
stream<Predictors,ScoringResult> DrugTreatments = PMMLScoring(InputRecords)
{
param
modelPath: getApplicationDir() + "/etc/drugNN_pmml_v1.xml";
modelInputAttributeMapping: "Age=age,BP=bloodPressure,Cholesterol=cholesterol,Na_to_K=NA_to_K,Sex=sex";
modelOutputAttributeMapping: "predictedValue=Drug.PredictedValue,confidence=Drug.Confidence,probabilities=Drug.Probability";
}
For complete code, see the sample DrugTreatments