dtreeviz icon indicating copy to clipboard operation
dtreeviz copied to clipboard

'function' object has no attribute 'model'

Open HarshKapadia opened this issue 2 years ago • 4 comments

I am facing this issue while visualizing a decision tree using dtreeviz . I follow your demo of sklearn from READ.md. I am using vscode and download jupyter notebook as extension.

this is what I got after executing it

AttributeError Traceback (most recent call last) Cell In[37], line 1 ----> 1 viz_model = dtreeviz.model(tree_classifier, 2 X_train=dataset[features], y_train=dataset[target], 3 feature_names=features, 4 target_name=target, class_names=["perish", "survive"])

AttributeError: 'function' object has no attribute 'model'

HarshKapadia avatar Feb 22 '23 19:02 HarshKapadia

Hmm...must be an old version of dtreeviz?

parrt avatar Feb 22 '23 20:02 parrt

this is my package details

Name: dtreeviz Version: 2.0.0 Summary: A Python 3 library for sci-kit learn, XGBoost, LightGBM, Spark, and TensorFlow decision tree visualization Home-page: https://github.com/parrt/dtreeviz Author: Terence Parr, Tudor Lapusan, and Prince Grover Author-email: [email protected] License: MIT Location: c:\users\UserName\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages Requires: colour, graphviz, matplotlib, numpy, pandas, pytest, scikit-learn Required-by:

HarshKapadia avatar Feb 22 '23 21:02 HarshKapadia

@HarshKapadia I suspect it's an import issue. Please double check there, because your code sees the dtreeviz as a function, as it was in the old version of the library.

Maybe this could help also : https://stackoverflow.com/questions/75346507/dtreeviz-nameerror

If you followed all the above suggestions and still no success, providing a collab notebook or some sharable code to reproduce the issue would help us :)

tlapusan avatar Feb 23 '23 06:02 tlapusan

I am also having the same issue while trying to visualize a representative tree of xgboost classifier. AttributeError Traceback (most recent call last) in ----> 1 viz_model = dtreeviz.model(best_model_O, 2 X_train=X_train_O, y_train_O=y_train_O, 3 feature_names=X_train_O.columns.tolist(), 4 target_name='Risk Level', 5 class_names=best_model_O.classes_)

AttributeError: module 'dtreeviz' has no attribute 'model' I am using dtreeviz-2.2.2 @parrt and @tlapusan any solution?

TesfamariamAbuhay avatar Oct 11 '23 19:10 TesfamariamAbuhay