Code Monkey home page Code Monkey logo

Comments (16)

p42ul avatar p42ul commented on August 27, 2024

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.

parrt avatar parrt commented on August 27, 2024

Hi @p42ul I can't find from dtreeviz import *. Can you point me where to look? I'll fix it :)

from dtreeviz.

p42ul avatar p42ul commented on August 27, 2024

@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.

parrt avatar parrt commented on August 27, 2024

no problem!

from dtreeviz.

Mirza-Ahmad avatar Mirza-Ahmad commented on August 27, 2024

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.

tlapusan avatar tlapusan commented on August 27, 2024

@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.

Gejb01 avatar Gejb01 commented on August 27, 2024

@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.

tlapusan avatar tlapusan commented on August 27, 2024

Hi @Gejb01 , did you try it from notebook ? to be honest, I didn't try to see the library behavior from pycharm.

from dtreeviz.

Gejb01 avatar Gejb01 commented on August 27, 2024

@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.

tlapusan avatar tlapusan commented on August 27, 2024

@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.

Gejb01 avatar Gejb01 commented on August 27, 2024

@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.

tlapusan avatar tlapusan commented on August 27, 2024

I guess you could use an image editor/converter for this.

from dtreeviz.

Gejb01 avatar Gejb01 commented on August 27, 2024

@tlapusan Thank you very much. By the way, do you have any tuning experience to share?

from dtreeviz.

MitaliJain123 avatar MitaliJain123 commented on August 27, 2024

@tlapusan again help me with the same

  1. 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.

tlapusan avatar tlapusan commented on August 27, 2024

Hi @MitaliJain123, the error indicates that the dtreeviz library is not imported or installed in your environment.

from dtreeviz.

MitaliJain123 avatar MitaliJain123 commented on August 27, 2024

@tlapusan but I checked it several times it is already installed

from dtreeviz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.