Resolving invalid input issues when scoring PMML models

When scoring a PMML model, if input values do not conform to the domain definitions in the PMML model, the model may reject the request. You can configure the runtime to treat invalid values as missing values by setting the PMML_TREAT_INVALID_VALUE_AS_MISSING environment variable.

About this task

When you score a PMML model, the runtime validates input field values against the definitions specified in the PMML file. If a field value is invalid, the model may reject the request and return an unexpected result, such as null. For example, a string field defined will reject an unexpected value, such as blank.

By default, invalid values cause an error. To allow scoring to continue when invalid values are encountered, you can configure the runtime to treat them as missing values and continue scoring.

Procedure

  1. Check your application log for invalid input errors.
    An error message like the following is displayed when the input contains an invalid value and scoring fails:
    Invalid input value for field “{field name}”: “”
  2. To ensure the model’s invalid-value handling is applied, set the environment variable in .profile, PMML_TREAT_INVALID_VALUE_AS_MISSING=true.
    For example, export PMML_TREAT_INVALID_VALUE_AS_MISSING=true
  3. After, .profile environment variable is set, restart the scoring server and test with the same input.
    • With the variable set to true, scoring succeeds, and the invalid value is treated as missing.
    Example:
    Input row with invalid value for a fraud detection pmml model:
    [{    "User": 1654,  
     "Card": 1,    
    "Year": 2018,    
    "Month": 2,  
    "Day": 22,    
    "Time": 381,    
    "Amount": 0.40,    
    "Use Chip": "",  // Passing blank as an example where the field expects a value   
    "Merchant Name": "3414527459579106770",    
    "Merchant City": "Rome",    
    "Merchant State": "Italy",    
    "Zip": "91750.0",    
    "MCC": 5651,    
    "Errors?": "Insufficient Balance,"  }]
    With PMML_TREAT_INVALID_VALUE_AS_MISSING=true, scoring succeeds :
    [
        {
       "probability(0)": 0.9999711683679767,    
       "probability(1)": 0.000028831632023155917  
        }
    ]
    Without the environment variable set, Result throws a null value:
    [  {    "probability(0)": null,    "probability(1)": null  }]