ComenzarEmpieza gratis

Juntándolo todo

En los ejercicios anteriores, definiste una función create_pig_table que, dada una basetable y un predictor, crea una tabla para el predictor insight graph de ese predictor:

pig_table = create_pig_table(basetable,target,variable)

Después, escribiste una función plot_pig que representa el predictor insight graph a partir de esa tabla del predictor insight graph

plot_pig(pig_table, variable)

A menudo querrás crear muchos predictor insight graphs de una vez. En este ejercicio, aprenderás a hacerlo automáticamente usando un bucle for.

Este ejercicio forma parte del curso

Introducción al análisis predictivo en Python

Ver curso

Instrucciones del ejercicio

  • Para cada variable en variables, crea una tabla del predictor insight graph. La basetable está cargada en basetable.
  • Para cada variable en variables, representa el predictor insight graph.

Ejercicio interactivo práctico

Prueba este ejercicio y completa 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