Question: We are using Oracle 11.

In our CASE WHEN statement, I need to check if the number of days between the 2 dates are > 3 business days (so excluding weekends and holidays).

So, if 

Date1 = 1/21/19 (Monday)

Date2 = 1/18/19 (Friday)

The number of business days in between Date1 and Date2 is 1 day, not 3 days.

```
CASE WHEN TO_DATE(SETTLEMENT_DATE, 'YYYY-MM-DD') - TO_DATE(TRADE_DATE, 
'YYYY-MM-DD')  > 3  THEN 0  --> this includes weekend and holidays
WHEN CODE = 1 THEN 1
WHEN CODE =2 THEN 2
ELSE 3
END AS MyColumn

```

Thank you.

Answer: 
As of scikit-learn version 21.0 (roughly May 2019), Decision Trees can now be plotted with matplotlib using scikit-learn’s [tree.plot\_tree](https://i.stack.imgur.com/xcp45.png) without relying on graphviz. 

```
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn import tree

X, y = load_iris(return_X_y=True)

# Make an instance of the Model
clf = DecisionTreeClassifier(max_depth = 5)

# Train the model on the data
clf.fit(X, y)

fn=['sepal length (cm)','sepal width (cm)','petal length (cm)','petal width (cm)']
cn=['setosa', 'versicolor', 'virginica']

# Setting dpi = 300 to make image clearer than default
fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (4,4), dpi=300)

tree.plot_tree(clf,
           feature_names = fn, 
           class_names=cn,
           filled = True);

# You can save your plot if you want
#fig.savefig('imagename.png')

```

Something similar to what is below will output in your jupyter notebook.  

[![enter image description here](https://i.stack.imgur.com/xcp45.png)](https://i.stack.imgur.com/xcp45.png)

The code was adapted from this [post](https://towardsdatascience.com/visualizing-decision-trees-with-python-scikit-learn-graphviz-matplotlib-1c50b4aa68dc).
There are 4 methods which I'm aware of for plotting the scikit-learn decision tree:

* print the text representation of the tree with `sklearn.tree.export_text` method
* plot with `sklearn.tree.plot_tree` method (`matplotlib` needed)
* plot with `sklearn.tree.export_graphviz` method (`graphviz` needed)
* plot with `dtreeviz` package (`dtreeviz` and `graphviz` needed)

You can find a comparison of different visualization of sklearn decision tree with code snippets in this blog post: [link](https://mljar.com/blog/visualize-decision-tree/).

When using Jupiter notebook, remember to display the variable with plot. Example for `dtreeviz`:

```py
from dtreeviz.trees import dtreeviz # remember to load the package

viz = dtreeviz(clf, X, y,
                target_name="target",
                feature_names=iris.feature_names,
                class_names=list(iris.target_names))

viz # display the tree

```