Libraries/Utilities for Tabular Data

I’m having some issues with a few of the utilities introduced in Lesson 9:

  • draw_tree(m, xs, size = 7, leaves_parallel = True, precision = 2) throws the error, NameError: name 'draw_tree' is not defined.

These are the libraries I have installed and included:

#setting up the notebook
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

#installing fastai, waterfallcharts, treeinterpreter, & dtreeviz
!pip install -Uqq fastai waterfallcharts treeinterpreter dtreeviz

#importing from fastai
from fastai.collab import *
from fastai.tabular.all import *

#importaing from pandas
from pandas.api.types import is_string_dtype, is_numeric_dtype, is_categorical_dtype

#importing from sklearn
from sklearn.ensemble import RandomForestRegressor
from sklearn.tree import DecisionTreeRegressor

#importing from dtreeviz
from dtreeviz.trees import *

#importing from IPython
from IPython.display import Image, display_svg, SVG

Help resolving these errors is appreciated.
-Simon

Hi Simon, draw_tree is located in utils.py within the fastbook repo. Can you try submitting this line and then see if draw_tree works: from fastbook import *

1 Like