scikit-learn / scikit-learn/scikit-learn

sklearn.tree.export_dict

Open
#20,051 11 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module:tree New Feature
Dominant language
Python
Stars
67.3k
Forks
27.4k
Avg merge
1d 15h
Merged PRs (30d)
58

Description

Currently, there are two options to get the decision tree representations: export_graphviz and export_text.

I would like to add export_dict, which will output the decision as a nested dictionary.

While you can convert the graphviz representation using cli tools, it's a bit unruly and is a weird workflow. When converting back, the nesting is also kind of weird, with /n chars floating around.

The main utility for json/dict representations are

  1. That they're far easier to work with for any front-end work.
  2. Working with a dict allows you to use the representation easily for any downstream tasks using the decision tree (that aren't raw inference).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing export_graphviz and export_text entry points to understand how decision-tree representations are produced. Define the nested dictionary shape with the project discussion, then add export_dict and tests demonstrating that the returned structure represents the tree without graphviz or text parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.