parrt / dtreeviz

A python library for decision tree visualization and model interpretation.
MIT License
2.89k stars 332 forks source link

TypeError: 'int' object is not subscriptable #313

Open kevlariii opened 6 months ago

kevlariii commented 6 months ago

I successfully imported dtreeviz with the command: from dtreeviz import *

I tried this command: viz = dtreeviz(clf, xdev, ydev, target_name="isFraud", feature_names = list(xdev.columns), class_names = ['notFraud', 'isFraud'])

I get the error: TypeError: 'int' object is not subscriptable

Here are my xdev and ydev: xtrain

image

Any idea on where this error might be coming from? Thank you so much!

LegalWiggle commented 5 months ago

Having the same issue as you, did you manage to resolve it?

tlapusan commented 5 months ago

@kevlariii I see that you are using the old API of the library, could you try with the new version ? You can find examples here : https://github.com/parrt/dtreeviz/tree/master/notebooks

If the error still persists, would be very helpful if you could prepare a sharable notebook (like google colab) to investigate the issue. Thanks.

@LegalWiggle if you could provide one also, would be great.

Leci37 commented 4 months ago

@kevlariii @LegalWiggle Just add dtreeviz .model(

from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
import dtreeviz
print(dtreeviz.__version__)
#---------------------
    viz = dtreeviz.model(regr_TreeClassifier_model,
                   X_train,  # pandas.DataFrame
                   y_train,  # pandas.Series
                   target_name=Y_TARGET,
                   feature_names=list(X_train.columns)  ) 
    viz.view(scale=0.8)

@tlapusan this kind import from dtreeviz import * could generate errors like this ticket ¿add exception ?