Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saving Rashomon set as JSON? #2

Open
lin-things opened this issue Nov 2, 2022 · 2 comments
Open

saving Rashomon set as JSON? #2

lin-things opened this issue Nov 2, 2022 · 2 comments

Comments

@lin-things
Copy link

Thank you so much for the awesome tool!

How exactly do I generate the JSON file? I don't think the example notebook covers this.

Thanks!

@xiaohk
Copy link
Member

xiaohk commented Nov 9, 2022

Hello @gllg4009, good catch! We will add a function to directly export a JSON file from TreeFARMS.

https://github.com/ubc-systopia/treeFarms/blob/d6d1363d1d4a4cf4bc768c98a481b6b8f484a153/treefarms/model/treefarms.py#L149-L172

Right now, you can manually export the JSON using the code below:

# Get the rashomon in a trie structure
trie = model.model_set.to_trie()
df = model.dataset

# Convert the trie to decision paths
feature_names = df.columns
decision_paths = timbertrek.transform_trie_to_rules(
    trie,
    df,
    feature_names=feature_names,
)

# Save the decision paths in a JSON file
dump(decision_paths, open('./my-decision-paths.json', 'w'))

You then can drag the JSON file into https://poloclub.github.io/timbertrek/ to visualize it :)

@lin-things
Copy link
Author

Lovely, thanks @xiaohk !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants