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

Color keyword argument - Value error #288

Open
Seeth92 opened this issue Apr 21, 2023 · 17 comments
Open

Color keyword argument - Value error #288

Seeth92 opened this issue Apr 21, 2023 · 17 comments

Comments

@Seeth92
Copy link

Seeth92 commented Apr 21, 2023

I am working on a binary classification problem using lightGBM.
The model was trained on 42 features. The training dataset size is (78000, 42) - 78000 observations spanning across 42 features
The test dataset size is (25220, 42)

Using dtreeviz on my trained model:

viz = dtreeviz.model(gm, tree_index = 0, X_train = X_train, y_train=Y_train, feature_names = features, target_name="A", class_names = ["A", "B"])

When I execute viz.view() I am facing the following error:
ValueError: The 'color' keyword argument must have one color per dataset, but 1 datasets and 0 colors were provided

Any thoughts on how to go about this?

@tlapusan
Copy link
Collaborator

Is it something similar with #280?

@baligoyem
Copy link

I am facing the same error.

Here is the image which contains some details:

image

@Seeth92
Copy link
Author

Seeth92 commented Apr 24, 2023

@tlapusan Yes, the error description is the same as the one posted by @baligoyem

@baligoyem
Copy link

Have you ever faced the AttributeError, which its description is 'Rectangle' object has no attribute 'patches'?

I am asking this question because I have sometimes randomly faced these two errors that are related to each other, I believe.

@tlapusan
Copy link
Collaborator

did you try the latest version of dtreeviz ?

@baligoyem
Copy link

baligoyem commented Apr 24, 2023

yes, I did. But it did not resolve.

@Seeth92
Copy link
Author

Seeth92 commented Apr 24, 2023

Using colour-0.1.5 and dtreeviz-2.2.1 .. No luck at all

@tlapusan
Copy link
Collaborator

could you provide a google collab or any kind of shareable notebook so I could reproduce your issue?

@Seeth92
Copy link
Author

Seeth92 commented Jun 26, 2023

@tlapusan Sorry for responding this late. Unfortunately, I can't share the notebook as the data and features used is confidential :(

@Guido-Hwang
Copy link

+1

3 similar comments
@Thegongyx
Copy link

+1

@leonswl
Copy link

leonswl commented Dec 1, 2023

+1

@andylokandy
Copy link

+1

@windyd
Copy link

windyd commented Mar 22, 2024

In my case (dtreeviz=2.2.2), it seems to be a precision problem from the get_thresholds method. If you have small float thresholds, samples are assigned to wrong paths. In some cases, some nodes may end up with no samples.

class ShadowLightGBMTree(ShadowDecTree):
    ...
    def get_thresholds(self) -> np.ndarray:
        if self.thresholds is not None:
            return self.thresholds

        node_thresholds = [-1] * self.nnodes()
        for i in range(self.nnodes()):
            if self.children_left[i] != -1 and self.children_right[i] != -1:
                if self.is_categorical_split(i):
                    node_thresholds[i] = list(map(int, self.tree_nodes[i]["threshold"].split("||")))
                else:
                    ###  thresholds are ROUNDED!
                    node_thresholds[i] = round(self.tree_nodes[i]["threshold"], 2)

        self.thresholds = np.array(node_thresholds, dtype=object)
        return self.thresholds

No sample -> No color mapped -> this problem.

@leocwolter
Copy link

leocwolter commented Jun 3, 2024

+1 on 2.2.2, any workarounds?

@CaoHaiNam
Copy link

I dealt with this issue. You should ensure that the data you use to train the LGBM model is the same as the data for visualization.

@sidml
Copy link

sidml commented Oct 7, 2024

I am using the same data for visualization and I still get the error. Not sure, how to fix it.

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