Search code examples
tensorflowgoogle-cloud-mlgoogle-cloud-ml-engine

How to interpret Google Cloud ML Prediction results?


I worked through the GC ML Census Wide & Deep Learning example https://github.com/GoogleCloudPlatform/cloudml-samples/tree/master/census

Given census data about a person such as age, gender, education and occupation (the features), this DNNLinearCombinedClassifier model should predict whether or not the person earns more than 50,000 dollars a year (the target label).

I ran an online prediction gcloud ml-engine predict --model census --version v1 --json-instances ../test.json

using the test.json data {"age": 25, "workclass": " Private", "education": " 11th", "education_num": 7, "marital_status": " Never-married", "occupation": " Machine-op-inspct", "relationship": " Own-child", "race": " Black", "gender": " Male", "capital_gain": 0, "capital_loss": 0, "hours_per_week": 40, "native_country": " United-States"}

I get the following result: {"probabilities": [0.9962924122810364, 0.003707568161189556], "logits": [-5.593664646148682], "classes": 0, "logistic": [0.003707568161189556]}

How do I interpret this ? my current understanding is that logit is the inverse of the sigmoid binary classification activation function in the output layer (not sure what the output numbers signify) and that classes: 0 refers to a binary classification of < $50,000, as opposed to 1 (>= $50,000)


Solution

  • Correct.

    • probabilities: are the probabilities of < $50K vs >=$50K.
    • classes: the predicted class (0, i.e. < $50K)
    • logits: ln(p/(1-p)) = ln(0.00371/(1-.00371)) = -5.593
    • logistic: 1/(1+exp(-logit)) = 1/(1+exp(5.593)) = 0.0037