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

DTreeViz crashes, if descision tree was built with objects, that are interpretable as numbers. #317

Open
lgi1sgm opened this issue Mar 8, 2024 · 0 comments

Comments

@lgi1sgm
Copy link

lgi1sgm commented Mar 8, 2024

sklearn.tree.DecisionTreeClassifer casts the parameter X into dtype=np.float23 (see Documentation), therefore it works with the data provided in the example.

But DTreeViz does not and crashes in a call of np.linspace in the function get_split_node_heights().

Example

#!/usr/bin/env python

import pandas as pd
from sklearn.tree import DecisionTreeClassifier, export_text
import dtreeviz


X = pd.DataFrame({'feature_1' : [10, 2, 5], 'feature_2': ['1', '1', '4']})
y = pd.Series([0, 0, 1], name='label')

# X, y = make_blobs(n_samples=10, n_features=2, centers=3)

d = DecisionTreeClassifier()
d.fit(X, y)

print(export_text(d))

dtreeviz_model = dtreeviz.model(d, X_train=X, y_train=y)

dtreeviz_render = dtreeviz_model.view()  # this will crash
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

1 participant