{"id":13570130,"url":"https://github.com/parrt/dtreeviz","last_synced_at":"2025-12-26T22:00:16.924Z","repository":{"id":37686499,"uuid":"144636984","full_name":"parrt/dtreeviz","owner":"parrt","description":"A python library for decision tree visualization and model interpretation.","archived":false,"fork":false,"pushed_at":"2025-12-06T20:53:32.000Z","size":198059,"stargazers_count":3111,"open_issues_count":76,"forks_count":342,"subscribers_count":44,"default_branch":"master","last_synced_at":"2025-12-16T21:13:21.935Z","etag":null,"topics":["data-science","decision-trees","machine-learning","model-interpretation","python","random-forest","scikit-learn","visualization","xgboost"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parrt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-08-13T21:45:15.000Z","updated_at":"2025-12-11T00:57:46.000Z","dependencies_parsed_at":"2025-04-28T14:22:54.282Z","dependency_job_id":null,"html_url":"https://github.com/parrt/dtreeviz","commit_stats":{"total_commits":538,"total_committers":30,"mean_commits":"17.933333333333334","dds":0.5092936802973977,"last_synced_commit":"c11e990dda747d4f6ec268e10fd162d17473cfde"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/parrt/dtreeviz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrt%2Fdtreeviz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrt%2Fdtreeviz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrt%2Fdtreeviz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrt%2Fdtreeviz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parrt","download_url":"https://codeload.github.com/parrt/dtreeviz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrt%2Fdtreeviz/sbom","scorecard":{"id":720857,"data":{"date":"2025-08-11","repo":{"name":"github.com/parrt/dtreeviz","commit":"e0d6182e16e4e5c5c254f33dab16795292630899"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":5,"reason":"Found 13/23 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch 'dev'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}}]},"last_synced_at":"2025-08-22T11:19:17.122Z","repository_id":37686499,"created_at":"2025-08-22T11:19:17.122Z","updated_at":"2025-08-22T11:19:17.122Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28062336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","decision-trees","machine-learning","model-interpretation","python","random-forest","scikit-learn","visualization","xgboost"],"created_at":"2024-08-01T14:00:48.608Z","updated_at":"2025-12-26T22:00:16.909Z","avatar_url":"https://github.com/parrt.png","language":"Jupyter Notebook","readme":"# dtreeviz : Decision Tree Visualization\n\n## Description\n\nA python library for decision tree visualization and model interpretation.  Decision trees are the fundamental building block of [gradient boosting machines](http://explained.ai/gradient-boosting/index.html) and [Random Forests](https://en.wikipedia.org/wiki/Random_forest)(tm), probably the two most popular machine learning models for structured data.  Visualizing decision trees is a tremendous aid when learning how these models work and when interpreting models. The visualizations are inspired by an educational animation by [R2D3](http://www.r2d3.us/); [A visual introduction to machine learning](http://www.r2d3.us/visual-intro-to-machine-learning-part-1/). Please see [How to visualize decision trees](http://explained.ai/decision-tree-viz/index.html) for deeper discussion of our decision tree visualization library and the visual design decisions we made.\n\nCurrently dtreeviz supports: [scikit-learn](https://scikit-learn.org/stable), [XGBoost](https://xgboost.readthedocs.io/en/latest), [Spark MLlib](https://spark.apache.org/mllib/), [LightGBM](https://lightgbm.readthedocs.io/en/latest/), and [Tensorflow](https://www.tensorflow.org/decision_forests).  See [Installation instructions](README.md#Installation).\n\n### Authors\n\n* [Terence Parr](https://explained.ai/), a tech lead at Google, and until 2022 was a professor of data science / computer science at Univ. of San Francisco, where he was founding director of the [University of San Francisco's MS in data science program](https://www.usfca.edu/arts-sciences/graduate-programs/data-science) in 2012.\n* [Tudor Lapusan](https://www.linkedin.com/in/tudor-lapusan-5902593b/)\n* [Prince Grover](https://www.linkedin.com/in/groverpr)\n\nWith major code and visualization clean up contributions done by [Matthew Epland](https://www.linkedin.com/in/matthew-epland) (@mepland).\n\n## Sample Visualizations\n\n### Tree visualizations\n\n\u003ctable cellpadding=\"0\" cellspacing=\"0\"\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/iris-TD-2.svg\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/boston-TD-2.svg\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/knowledge-TD-4-simple.svg\" width=\"250\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### Prediction path explanations\n\n\u003ctable cellpadding=\"0\" cellspacing=\"0\"\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/breast_cancer-TD-3-X.svg\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/diabetes-LR-2-X.svg\" width=\"300\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/knowledge-TD-15-X-simple.svg\" width=\"250\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### Leaf information\n\n\u003ctable cellpadding=\"0\" cellspacing=\"0\"\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/titanic-leaf-regression.png\" width=\"150\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/titanic-leaf-samples-by-class.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### Feature space exploration\n\n#### Regression\n\n\u003ctable cellpadding=\"0\" cellspacing=\"0\"\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/cars-univar-2.svg\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/178777/49104999-4edb0d80-f234-11e8-9010-73b7c0ba5fb9.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/178777/49107627-08d57800-f23b-11e8-85a2-ab5894055092.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n#### Classification\n\n\u003ctable cellpadding=\"0\" cellspacing=\"0\"\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/178777/49105084-9497d600-f234-11e8-9097-56835558c1a6.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/178777/49105085-9792c680-f234-11e8-8af5-bc2fde950ab1.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n#### Classification boundaries\n\nAs a utility function, dtreeviz provides `dtreeviz.decision_boundaries()` that illustrates one and two-dimensional feature space for classifiers, including colors that represent probabilities, decision boundaries, and misclassified entities. This method is not limited to tree models, by the way, and should work with any model that answers method `predict_proba()`. That means any model from scikit-learn should work (but we also made it work with Keras models that define `predict()`). (As it does not work with trees specifically, the function does not use adaptors obtained from `dtreeviz.model()`.) See [classifier-decision-boundaries.ipynb](https://github.com/parrt/dtreeviz/tree/master/notebooks/classifier-decision-boundaries.ipynb).\n\n\u003ctable cellpadding=\"0\" cellspacing=\"0\"\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/178777/113516364-b608db00-952e-11eb-91cf-efe2386622f1.png\" width=\"250\"\u003e\u003cbr\u003e\u003cimg src=\"https://user-images.githubusercontent.com/178777/113516379-d5076d00-952e-11eb-955e-1dd7c09f2f29.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/178777/113516349-a12c4780-952e-11eb-86f3-0ae457eb500f.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nSometimes it's helpful to see animations that change some of the hyper parameters. If you look in notebook [classifier-boundary-animations.ipynb](https://github.com/parrt/dtreeviz/tree/master/notebooks/classifier-boundary-animations.ipynb), you will see code that generates animations such as the following (animated png files):\n\n\u003ctable cellpadding=\"0\" cellspacing=\"0\"\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/smiley-dtree-maxdepth.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"testing/samples/smiley-numtrees.png\" width=\"250\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Quick start\n\nSee [Installation instructions](README.md#Installation) then take a look at the specific [notebooks](https://github.com/parrt/dtreeviz/tree/master/notebooks) for the supported ML library you're using:\n\n* [sklearn-based examples](notebooks/dtreeviz_sklearn_visualisations.ipynb) ([colab](https://colab.research.google.com/github/parrt/dtreeviz/blob/master/notebooks/dtreeviz_sklearn_visualisations.ipynb))\n* [LightGBM-based examples](notebooks/dtreeviz_lightgbm_visualisations.ipynb) ([colab](https://colab.research.google.com/github/parrt/dtreeviz/blob/master/notebooks/dtreeviz_lightgbm_visualisations.ipynb))\n* [Spark-based examples](notebooks/dtreeviz_spark_visualisations.ipynb) ([colab](https://colab.research.google.com/github/parrt/dtreeviz/blob/master/notebooks/dtreeviz_spark_visualisations.ipynb))\n* [TensorFlow-based examples](notebooks/dtreeviz_tensorflow_visualisations.ipynb) ([colab](https://colab.research.google.com/github/parrt/dtreeviz/blob/master/notebooks/dtreeviz_tensorflow_visualisations.ipynb)) Also see blog at tensorflow.org [Visualizing TensorFlow Decision Forest Trees with dtreeviz](https://www.tensorflow.org/decision_forests/tutorials/dtreeviz_colab)\n* [XGBoost-based examples](notebooks/dtreeviz_xgboost_visualisations.ipynb) ([colab](https://colab.research.google.com/github/parrt/dtreeviz/blob/master/notebooks/dtreeviz_xgboost_visualisations.ipynb))\n* [Classifier decision boundaries for any scikit-learn model.ipynb](https://github.com/parrt/dtreeviz/tree/master/notebooks/classifier-decision-boundaries.ipynb) ([colab](https://colab.research.google.com/github/parrt/dtreeviz/blob/master/notebooks/classifier-decision-boundaries.ipynb))\n* [Changing colors notebook](notebooks/colors.ipynb) ([colab](https://colab.research.google.com/github/parrt/dtreeviz/blob/master/notebooks/colors.ipynb))\n* [AI-powered tree analysis (sklearn)](notebooks/dtreeviz_sklearn_AI_visualisations.ipynb) - Interactive chat and explanations using LLMs\n\nTo interopt with these different libraries, dtreeviz uses an adaptor object, obtained from function `dtreeviz.model()`, to extract model information necessary for visualization. Given such an adaptor object, all of the dtreeviz functionality is available to you using the same programmer interface. The basic dtreeviz usage recipe is:\n\n1. Import dtreeviz and your decision tree library\n2. Acquire and load data into memory\n3. Train a classifier or regressor model using your decision tree library\n4. Obtain a dtreeviz adaptor model using\u003cbr\u003e`viz_model = dtreeviz.model(your_trained_model,...)`\n5. Call dtreeviz functions, such as\u003cbr\u003e`viz_model.view()` or `viz_model.explain_prediction_path(sample_x)`\n\n**Example**\n\nHere's a complete example Python file that displays the following tree in a popup window:\n\n\u003cimg src=\"testing/samples/iris-TD-4.svg\" width=\"200\"\u003e\n\n```python\nfrom sklearn.datasets import load_iris\nfrom sklearn.tree import DecisionTreeClassifier\n\nimport dtreeviz\n\niris = load_iris()\nX = iris.data\ny = iris.target\n\nclf = DecisionTreeClassifier(max_depth=4)\nclf.fit(X, y)\n\nviz_model = dtreeviz.model(clf,\n                           X_train=X, y_train=y,\n                           feature_names=iris.feature_names,\n                           target_name='iris',\n                           class_names=iris.target_names)\n\nv = viz_model.view()     # render as SVG into internal object \nv.show()                 # pop up window\nv.save(\"/tmp/iris.svg\")  # optionally save as svg\n```\n\nIn a notebook, you can render inline without calling `show()`. Just call `view()`:\n\n```python\nviz_model.view()       # in notebook, displays inline\n```\n\n### AI-Powered Tree Analysis\n\nWith AI integration enabled, you can ask ad hoc questions about your decision tree model using the `chat()` method. The AI has access to comprehensive knowledge about your tree structure, nodes, and training data, enabling it to answer questions about:\n\n* **Tree structure**: Overall architecture, depth, node count, splitting criteria, and tree type (classification/regression)\n* **Tree nodes**: Split conditions, feature usage, node statistics, sample distributions, and purity measures at internal nodes\n* **Leaf nodes**: Predictions, confidence scores, sample counts, and class distributions\n* **Training dataset**: Feature statistics, target distributions, and data characteristics within nodes or leaves\n\n```python\n# Enable AI chat when creating the model\nviz_model = dtreeviz.model(tree_classifier,\n                           X_train=dataset[features], y_train=dataset[target],\n                           feature_names=features,\n                           target_name=target, class_names=[\"perish\", \"survive\"],\n                           ai_chat=True,\n                           ai_model=\"gpt-4.1-mini\",\n                           max_history_messages=10)\n\n# Ask questions about your tree\nviz_model.chat(\"Please give me a short summary of the tree structure?\")\nviz_model.chat(\"Which leaf nodes have the lowest prediction confidence?\")\n```\n\nAdditionally, when `ai_chat=True` is enabled, the main visualization methods (like `view()`) will automatically include an LLM-generated explanation alongside the visual output, providing both graphical and natural language interpretations of your decision tree.\n\nRequires `pip install dtreeviz[ai]` and an OpenAI API key set as `OPENAI_API_KEY` environment variable. See the [AI-powered tree analysis notebook](notebooks/dtreeviz_sklearn_AI_visualisations.ipynb) for more examples.\n\n## Installation\n\nInstall anaconda3 on your system, if not already done.\n\nYou might verify that you do not have conda-installed graphviz-related packages installed because dtreeviz needs the pip versions; you can remove them from conda space by doing:\n\n```bash\nconda uninstall python-graphviz\nconda uninstall graphviz\n```\n\nTo install (Python \u003e=3.6 only), do this (from Anaconda Prompt on Windows!):\n\n```bash\npip install dtreeviz             # install dtreeviz for sklearn\npip install dtreeviz[xgboost]    # install XGBoost related dependency\npip install dtreeviz[pyspark]    # install pyspark related dependency\npip install dtreeviz[lightgbm]   # install LightGBM related dependency\npip install dtreeviz[tensorflow_decision_forests]   # install tensorflow_decision_forests related dependency\npip install dtreeviz[ai]         # install AI chat/explanation features (requires OpenAI API key)\npip install dtreeviz[all]        # install all related dependencies\n```\n\nThis should also pull in the `graphviz` Python library (\u003e=0.9), which we are using for platform specific stuff.\n\n**Limitations.** Only svg files can be generated at this time, which reduces dependencies and dramatically simplifies install process.\n\nPlease email [Terence](mailto:parrt@antlr.org) with any helpful notes on making dtreeviz work (better) on other platforms. Thanks! \n\nFor your specific platform, please see the following subsections.\n\n### Mac\n\nMake sure to have the latest XCode installed and command-line tools installed. You can run `xcode-select --install` from the command-line to install those if XCode is already installed. You also have to sign the XCode license agreement, which you can do with `sudo xcodebuild -license` from command-line. The brew install shown next needs to build graphviz, so you need XCode set up properly.\n\nYou need the graphviz binary for `dot`. Make sure you have latest version (verified on 10.13, 10.14):\n\n```bash\nbrew reinstall graphviz\n```\n\nJust to be sure, remove `dot` from any anaconda installation, for example:\n\n```bash\nrm ~/anaconda3/bin/dot\n```\n\nFrom command line, this command\n\n```bash\ndot -Tsvg\n```\n\nshould work, in the sense that it just stares at you without giving an error. You can hit control-C to escape back to the shell.  Make sure that you are using the right `dot` as installed by brew:\n\n```bash\n$ which dot\n/usr/local/bin/dot\n$ ls -l $(which dot)\nlrwxr-xr-x  1 parrt  wheel  33 May 26 11:04 /usr/local/bin/dot@ -\u003e ../Cellar/graphviz/2.40.1/bin/dot\n$\n```\n\n**Limitations.** Jupyter notebook has a bug where they do not show .svg files correctly, but Juypter Lab has no problem.\n\n### Linux (Ubuntu 18.04)\n\nTo get the `dot` binary do:\n \n```bash\nsudo apt install graphviz\n```\n\n**Limitations.** The `view()` method works to pop up a new window and images appear inline for jupyter notebook but not jupyter lab (It gets an error parsing the SVG XML.)  The notebook images also have a font substitution from the Arial we use and so some text overlaps. Only .svg files can be generated on this platform.\n\n### Windows 10\n\n(Make sure to `pip install graphviz`, which is common to all platforms, and make sure to do this from Anaconda Prompt on Windows!)\n\n[Download graphviz-2.38.msi](https://graphviz.gitlab.io/_pages/Download/Download_windows.html) and update your `Path` environment variable.  Add `C:\\Program Files (x86)\\Graphviz2.38\\bin` to User path and `C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe` to System Path. It's windows so you might need a reboot after updating that environment variable.  You should see this from the Anaconda Prompt:\n\n```\n(base) C:\\Users\\Terence Parr\u003ewhere dot\nC:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe\n```\n\n(Do not use `conda install -c conda-forge python-graphviz` as you get an old version of `graphviz` python library.)\n\nVerify from the Anaconda Prompt that this works (capital `-V` not lowercase `-v`):\n\n```\ndot -V\n```\n\nIf it doesn't work, you have a `Path` problem. I found the following test programs useful. The first one sees if Python can find `dot`:\n\n```python\nimport os\nimport subprocess\nproc = subprocess.Popen(['dot','-V'])\nprint( os.getenv('Path') )\n```\n\nThe following version does the same thing except uses `graphviz` Python libraries backend support utilities, which is what we use in dtreeviz:\n\n```python\nimport graphviz.backend as be\ncmd = [\"dot\", \"-V\"]\nstdout, stderr = be.run(cmd, capture_output=True, check=True, quiet=False)\nprint( stderr )\n```\n\nIf you are having issues with run command you can try copying the following files from: https://github.com/xflr6/graphviz/tree/master/graphviz.\n\nPlace them in the AppData\\Local\\Continuum\\anaconda3\\Lib\\site-packages\\graphviz folder.  \n\nClean out the __pycache__ directory too.\n\nFor graphviz windows install 8.0.5 and python interface v0.18+ :  \n```python\nimport graphviz.backend as be\ncmd = [\"dot\", \"-V\"]\nstdout = be.execute.run_check(cmd, capture_output=True, check=True, quiet=False)\nprint( stdout )\n```\n\nJupyter Lab and Jupyter notebook both show the inline .svg images well.\n\n### Verify graphviz installation\n\nTry making text file `t.dot` with content `digraph T { A -\u003e B }` (paste that into a text editor, for example) and then running this from the command line:\n\n```\ndot -Tsvg -o t.svg t.dot\n```\n\nThat should give a simple `t.svg` file that opens properly.  If you get errors from `dot`, it will not work from the dtreeviz python code.  If it can't find `dot` then you didn't update your `PATH` environment variable or there is some other install issue with `graphviz`.\n\n### Limitations\n\nFinally, don't use IE to view .svg files. Use Edge as they look much better. I suspect that IE is displaying them as a rasterized not vector images. Only .svg files can be generated on this platform.\n\n## Install dtreeviz locally\n\nMake sure to follow the install guidelines above.\n\nIn order to run tests, you need to install the library with the `[dev]` extra:\n```bash \npip install dtreeviz[dev]        # Install develop dependencies\n```\n\nTo push the `dtreeviz` library to your local egg cache (force updates) during development, do this (from anaconda prompt on Windows):\n \n```bash \npython setup.py install -f\n```\n\nE.g., on Terence's box, it adds `/Users/parrt/anaconda3/lib/python3.6/site-packages/dtreeviz-2.3-py3.6.egg`.\n\n## Feedback\n\nWe welcome info from users on how they use dtreeviz, what features they'd like, etc... via [email (to parrt)](mailto:parrt@antlr.org) or via an [issue](https://github.com/parrt/dtreeviz/issues).\n\n## Useful Resources\n\n* [How to visualize decision trees](http://explained.ai/decision-tree-viz/index.html)\n* [How to explain gradient boosting](http://explained.ai/gradient-boosting/index.html)\n* [The Mechanics of Machine Learning](https://mlbook.explained.ai/)\n* [Animation by R2D3](http://www.r2d3.us/)\n* [A visual introductionn to machine learning](http://www.r2d3.us/visual-intro-to-machine-learning-part-1/)\n* [fast.ai's Introduction to Machine Learning for Coders MOOC](https://course18.fast.ai/ml.html)\n* Stef van den Elzen's [Interactive Construction, Analysis and\nVisualization of Decision Trees](http://alexandria.tue.nl/extra1/afstversl/wsk-i/elzen2011.pdf)\n* Some similar feature-space visualizations in [Towards an effective cooperation of the user and the computer for classification, SIGKDD 2000](https://github.com/EE2dev/publications/blob/master/cooperativeClassification.pdf)\n* [Beautiful Decisions: Inside BigML’s Decision Trees](https://blog.bigml.com/2012/01/23/beautiful-decisions-inside-bigmls-decision-trees/)\n* \"SunBurst\" approach to tree visualization: [An evaluation of space-filling information visualizations\nfor depicting hierarchical structures](https://www.cc.gatech.edu/~john.stasko/papers/ijhcs00.pdf)\n\n## License\n\nThis project is licensed under the terms of the MIT license, see [LICENSE](LICENSE).\n\n","funding_links":[],"categories":["Uncategorized","Jupyter Notebook","Visualization","Tools","Machine Learning Framework","Awesome python :scream_cat: dataviz not implemented(?) yet in R","A01_机器学习教程","Training","模型的可解释性","Interesting Non EO parts Python","Tutorials \u0026 Guides","Technical Resources"],"sub_categories":["Uncategorized","Interpretability/Explicability","Model Interpretation","Visualization","GEDI","Interpretability \u0026 Explainability","Open Source/Access Responsible AI Software Packages"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparrt%2Fdtreeviz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparrt%2Fdtreeviz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparrt%2Fdtreeviz/lists"}