Comments (12)
Please have a look at Ashafix@ee02d0f
and let me know if it's the right direction.
- Each function has an optional parameter
colors
which is a dictionary, each dictionary key can overwrite a default value. - The colors are stored in
colors.py
allowing easy global modification - Having a new optional parameter should allow re-use of all previous scripts which use dtreeviz
change_colors.py
demonstrates the effects with a few examples- "tested" on Windows 10 and Ubuntu 16.04
from dtreeviz.
good idea!
from dtreeviz.
@dhaitz : How should the configuration look like in your opinion? Global or per function call?
As far as I could see from the code, the colors are currently just global constants which can be overwritten, e.g. dtreeviz.trees.GREY = "#ff0000"
and you get red labels.
Probably the easiests way would be to have a global dictionary which stores the colors and can be overwritten for customization, e.g. COLORS = {'label': GREY, ', 'title': BLACK}
@parrt : Any preferences?
from sklearn import tree
from sklearn.datasets import load_boston
import dtreeviz.trees
dtreeviz.trees.GREY = "#ff0000"
regr = tree.DecisionTreeRegressor(max_depth=2)
boston = load_boston()
regr.fit(boston.data, boston.target)
viz = dtreeviz.trees.dtreeviz(regr, boston.data, boston.target, target_name='price', feature_names=boston.feature_names)
viz.view()
from dtreeviz.
I think some kind of argument would be better than tweaking the globals.
from dtreeviz.
@Ashafix , @parrt : Maybe something like this in dtreeviz/trees.py
?
GREY = "#ff0000"
...
COLORS = {'label': GREY, ', 'title': BLACK}
def dtreeviz(...,
colors: dict = None
):
if colors is None: # fall back to module-level default colors
colors = COLORS
from dtreeviz.
or just colors:dict=COLORS
?
from dtreeviz.
@parrt ah yes, of course this is the simple and straightforward solution.
Another approach would be:
if colors is None:
colors = dict(COLORS, **colors)
which would allow you to overwrite only certain keys in the colors
argument and use the defaults from COLORS
for all others.
from dtreeviz.
@Ashafix Looks pretty good! widespread changes but it's adding a lot of control to the look of the plots. could you make a PR? I'm wondering if colors.py should be a separate file or included... thoughts?
from dtreeviz.
@parrt : Thanks for the quick feedback! Personal opinion, I'd prefer a separate file for the colors/configuration, but not my library.
I will test and document all parameters and then create a PR.
from dtreeviz.
sounds great. does extra file cause any package weirdness for users? if invisible, let's factor out into colors.py :)
from dtreeviz.
While you are on colors, could you do font's as well :) (Ie make them configurable)
from dtreeviz.
@mattharrison : one PR at a time...
from dtreeviz.
Related Issues (20)
- Visualize custom decision tree HOT 1
- how to use dtreeviz in streamlit HOT 2
- VisualisationNotYetSupportedError: get_min_samples_leaf() is not implemented yet for XGBoost. HOT 4
- TypeError: list indices must be integers or slices, not numpy.float64 HOT 5
- Crash when leaf nodes have no samples HOT 1
- Out of memory when calling viz.view() HOT 2
- Integrate AI explanation
- CatBoost need to be supported. HOT 1
- AttributeError: module 'dtreeviz' has no attribute 'model' on Windows platform, works fine on Google colab
- tfdf.keras.CartModel support? HOT 1
- TypeError: 'int' object is not subscriptable HOT 3
- Development requirement in `setup.py` HOT 1
- Adjust Bounding Box of saved svg file
- DTreeViz crashes, if descision tree was built with objects, that are interpretable as numbers.
- How to use chinese? HOT 1
- get_score() is not implemented yet for XGBoost. HOT 1
- cannot import name 'dtreeviz' from 'dtreeviz.trees HOT 1
- VisualisationNotYetSupportedError: get_node_criterion() is not implemented yet for LightGBM
- VisualisationNotYetSupportedError: get_feature_path_importance() is not implemented yet for LightGBM
- Any way to filter features before plotting with instance_feature_importance(x,figsize=(10,12))? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dtreeviz.