Comments (16)
For anyone else getting this error, this is due to how the example code imports the module.
If you run from dtreeviz import *
, you won't get the necessary function.
Use from dtreeviz.trees import dtreeviz
instead.
from dtreeviz.
Hi @p42ul I can't find from dtreeviz import *
. Can you point me where to look? I'll fix it :)
from dtreeviz.
@parrt My apologies, I can't seem to find it either. I think I may have just mistyped it 🙄
In any case, from dtreeviz.trees import *
works.
from dtreeviz.
no problem!
from dtreeviz.
from dtreeviz.trees import *
from dtreeviz.trees import dtreeviz
I have used both libraries but still error occured. Error: module object is not callable
from dtreeviz.
@Mirza-Ahmad can you give us more details, dtreeviz version, code example? That error occurs when you try to use a Python module as if it were a function or callable object.
from dtreeviz.
@tlapusan Hello, why is it that when I run the following code in PyCharm, no plot appears?
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
import dtreeviz
Load the Iris dataset
iris = load_iris()
X = iris.data
y = iris.target
Train the decision tree model
clf = DecisionTreeClassifier(max_depth=3)
clf.fit(X, y)
Visualize the decision tree
viz = dtreeviz.model(clf, X, y,
feature_names=iris.feature_names,
class_names=iris.target_names)
Display the visualization
viz.view()
from dtreeviz.
Hi @Gejb01 , did you try it from notebook ? to be honest, I didn't try to see the library behavior from pycharm.
from dtreeviz.
@tlapusan Thank you for your reply.Using your method, I obtained the visualization, but cannot save it, and received the following prompt: ''Traceback (most recent call last) Cell In[19], line 1 ----> 1 viz.save('model.svg') AttributeError: 'DTreeVizAPI' object has no attribute 'save'''. Why is this happening?Looking forward to your reply.
from dtreeviz.
@Gejb01 would help to post also your code to better understand your issue :)
maybe this line of code will do your job:
viz_model.view().save("./tree.svg")
from dtreeviz.
@tlapusan Thank you very much for your reply. I can now output the SVG image, but may I ask if it's possible to save it as a PDF file?
from dtreeviz.
I guess you could use an image editor/converter for this.
from dtreeviz.
@tlapusan Thank you very much. By the way, do you have any tuning experience to share?
from dtreeviz.
@tlapusan again help me with the same
- Classification
viz = dtreeviz.model(clas,
X_train,
y_train,
feature_names=iris.feature_names,
class_names=["setosa", "versicolor", "virginica"]
)
viz.view()
this is the code that I am using for some practice point of view but it is showing the below mentioned error.
NameError Traceback (most recent call last)
Cell In[20], line 2
1 #1. Classification
----> 2 viz = dtreeviz.model(clas,
3 X_train,
4 y_train,
5 feature_names=iris.feature_names,
6 class_names=["setosa", "versicolor", "virginica"]
7 )
8 viz.view()
NameError: name 'dtreeviz' is not defined
help me to resolve it
from dtreeviz.
Hi @MitaliJain123, the error indicates that the dtreeviz library is not imported or installed in your environment.
from dtreeviz.
@tlapusan but I checked it several times it is already installed
from dtreeviz.
Related Issues (20)
- 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
- Google Cloud Function support/how-to?
- tree visualization issue with DecisionTreeClassifiers class of PySpark MLLIB HOT 8
- change bins in classifier nodes 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.