O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Constructing a cross-tab

Now that we have categorized age, we can run a cross-tab which counts outcomes by the age category.

Since there are only two outcomes and two age categories, this results in a four-cell crosstab:

  1. First, display the results using the special Databricks display command.
  2. After the results appear as shown in the table below, you can click the plot button (2nd icon on the bottom left) and the Customized Plot dialogue will appear, which will allow the results to be plotted as a bar chart. The plot show that diabetes occurs more frequently in the higher age group than in the lower age group, while the reverse is true for the non-diabetes group:
        table <- crosstab(filtered, "outcome", "agecat")  display(as.data.frame(table)) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required