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

Running a Python Decision Tree

Here are some notes on the Python decision tree code which appears below.

For the first code chunk, notice the "magic" directive in the first line of the code. The magic directive begins with '%' and specifies which language or API you will be using. Therefore, since we will be using Python instead or R, we need to specify %python as the first line. That is because the notebook was originally set up as an R notebook. When mixing languages, you need to specify the language used as the first line, unless you are writing in the default notebook language.

For those of you who are not familiar with Python, the import directives at the top of the code import the needed libraries and modules, which are to be used by ...

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