Get startedGet started for free

Retrieving information from the predictor insight table

The predictor insight graph table contains all the information needed to construct the predictor insight graph. For each value the predictor takes, it has the number of observations with this value and the target incidence within this group. The predictor insight graph table of the predictor Country is loaded as a pandas object pig_table. You can access elements using indexing. For instance, to retrieve the target incidence of donors living in the UK, you can use:

pig_table["Incidence"][pig_table["Country"]=="UK"]

This exercise is part of the course

Introduction to Predictive Analytics in Python

View Course

Exercise instructions

  • Print the number of UK donors.
  • Print the target incidence of USA donors.
  • Print the target incidence of India donors.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Inspect the predictor insight graph table of Country
print(pig_table)

# Print the number of UK donors
print(pig_table["____"][pig_table["Country"]=="UK"])

# Check the target incidence of USA and India donors
print(pig_table["____"][pig_table["Country"]=="USA"])
print(____)
Edit and Run Code