The Decision Tree Visualizer is a powerful library that allows you to visualize sklearn Decision Tree Classifiers with ease. It provides functions for extracting useful information about the tree structure and rules, and generates HTML files for visualizing the decision tree.
To install the library, use pip:
pip install d-treevis
To get started, import the library and use the create_tree and create_sankey functions:
import d_treevis as dtvNext, fit a sklearn Decision Tree Classifier on your dataset and pass it to the create_tree function:
from sklearn.tree import DecisionTreeClassifier
# Fit a Decision Tree Classifier on your dataset
tree_model = DecisionTreeClassifier()
tree_model.fit(X, y)
# Visualize the decision tree
visualizer.visualize(tree_model)You can also customize the target names and colors for better visualization:
# Define target names and colors
target_names = ['Survived', 'Not Survived']
target_colors = ['red', 'yellow']
# Visualize the decision tree with custom target names and colors
visualizer.visualize(tree_model, target_names=target_names, target_colors=target_colors)For detailed documentation and examples, please refer to the Decision Tree Visualizer Documentation.
This library is licensed under the MIT License.
Contributions are welcome! Please read the Contribution Guidelines before submitting a pull request.
If you have any questions or suggestions, feel free to reach out to us at [email protected].