Comments (8)
hi. Seems like X_train, y_train are a bit out of sync sizewise based upon that error msg.
from dtreeviz.
Thank you for the answer!
You are right, I'm really sorry, I uploaded that error by mistake, I actually wanted to upload this one:
--------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-40-4568def0d1f4> in <module>
76 azim=35,
77 dist=12,
---> 78 show={'splits','title'})
79
80
~/anaconda3/lib/python3.7/site-packages/dtreeviz/trees.py in rtreeviz_bivar_3D(ax, X_train, y_train, max_depth, feature_names, target_name, fontsize, ticks_fontsize, fontname, azim, elev, dist, show, colors, n_colors_in_map)
246
247 for node, bbox in tesselation:
--> 248 plane(node, bbox)
249
250 x, y, z = X_train[:, 0], X_train[:, 1], y_train
~/anaconda3/lib/python3.7/site-packages/dtreeviz/trees.py in plane(node, bbox)
230 # print(f"{color_map[int(((node.prediction()-y_lim[0])/y_range)*(n_colors_in_map-1))]}")
231 ax.plot_surface(xx, yy, z, alpha=.85, shade=False,
--> 232 color=color_map[int(((node.prediction()-y_lim[0])/y_range)*(n_colors_in_map-1))],
233 edgecolor=colors['edge'], lw=.3)
234
IndexError: list index out of range
from dtreeviz.
ah. are there more than 10 classes? Can't do more than that.
from dtreeviz.
No, that's the fact, first I though the error was because I was using many classes, but actually in this case there are only two classes.
from dtreeviz.
Weird. Any chance you could send me a small data set that reproduces this?
from dtreeviz.
This is my code, I only was trainning:
from sklearn.datasets import *
from sklearn import tree
from dtreeviz.trees import *
from mpl_toolkits.mplot3d import Axes3D
data = pd.DataFrame({'Edad': [ 17, 64, 18, 20, 38, 49, 55, 25, 29, 31, 33, 52, 65, 27, 39, 54, 30, 28, 27, 18, 47],
'Sexo': ['H', 'M', 'M', 'M', 'M', 'H', 'H', 'M', 'H', 'H', 'H', 'M', 'M', 'M', 'M', 'H', 'H', 'H', 'M', 'H', 'M'],
'Salario': [25, 80, 22, 36, 37, 59, 74, 70, 33, 102, 88, 35, 70, 51, 38, 94, 50, 35, 74, 32, 45],
'Pagador': [1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0]})
from sklearn import preprocessing
code = preprocessing.LabelEncoder()
code.fit(["H", "M"])
data['Sexo']= code.transform(data['Sexo'])
data = data.sort_values('Edad')
features = [2,0]
X = data.values[:,features]
print(X)
y = data['Pagador'].values
print(y)
figsize = (42,16)
fig = plt.figure(figsize=figsize)
ax = fig.add_subplot(111, projection='3d')
t = rtreeviz_bivar_3D(ax,
X,y,
max_depth=None,
feature_names=['Edad','Sexo'],
target_name='Pagador',
fontsize=11,
elev=30,
azim=35,
dist=12,
show={'splits','title'})
plt.show()
Actually I tried with other internet data sets and every work fine, for example in the image. I am a little confused.
Thank you for your support.
from dtreeviz.
Heh, don't you want a classifier here not a regressor? Pagador
looks boolean
from dtreeviz.
I think you want:
ctreeviz_bivar(ax, X, y, max_depth=5,
feature_names=['Edad', 'Sexo'],
class_names=['yes', 'no'],
target_name='Pagador',
show={'splits', 'title'},
colors={'scatter_edge': 'black'}
)
Regardless, I fixed so {0,1} doesn't cause crash for regression partitioning :)
from dtreeviz.
Related Issues (20)
- from dtreeviz.trees import * Import necessary libraries HOT 1
- Color keyword argument - Value error HOT 14
- Add support for TensorFlow GradientBoostedTreesModel model
- _regr_leaf_viz calculates the mean for prediction value.
- WARNING:matplotlib.font_manager:findfont: Font family 'Arial' not found. HOT 2
- Decision Tree visualize wrong path HOT 1
- When using dataset that is different from the training for trees models - does not draw HOT 1
- Support for RandomForest HOT 5
- 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
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.