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

class_weight error #27

Open
posylinnnn opened this issue Feb 1, 2023 · 0 comments
Open

class_weight error #27

posylinnnn opened this issue Feb 1, 2023 · 0 comments

Comments

@posylinnnn
Copy link

hello,

When I ran the code I encountered this error:
class_weight is causing a ValueError: The truth value of an array with more than one element is ambiguous. use a.any() or a.all().

I tried to fix it, but without success.
I saw someone's solution online:

from sklearn.utils import class_weight
weight = class_weight.compute_class_weight('balanced', np.unique(y_train), y_train)
class_weights = {l:c for l,c in zip(np.unique(labels[i]), class_weights)}

But this solution doesn't work for me, can you help me?
Thank you very much!

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

1 participant