ComenzarEmpieza gratis

Putting it all together

In the previous exercises, you defined a function create_pig_table that, given a basetable and a predictor, creates a predictor insight graph table for this predictor:

pig_table = create_pig_table(basetable,target,variable)

Next, you wrote a function plot_pig that plots the predictor insight graph based on this predictor insight graph table

plot_pig(pig_table, variable)

Often, you want to make many predictor insight graphs at once. In this exercise, you will learn how to automatically do this using a for loop.

Este ejercicio forma parte del curso

Introduction to Predictive Analytics in Python

Ver curso

Instrucciones del ejercicio

  • For each variable in variables, create a predictor insight graph table. The basetable is loaded in basetable.
  • For each variable in variables, plot the predictor insight graph.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Variables you want to make predictor insight graph tables for
variables = ["income","gender","disc_mean_gift","disc_time_since_last_gift"]

# Loop through the variables
for variable in variables: 
    
    # Create the predictor insight graph table
    pig_table = ____(____, "target", variable)
    
    # Plot the predictor insight graph
    ____(____, variable)
Editar y ejecutar código