need your support...I am following one tutorial and trying to run on my dataset. I am getting below error ...Pls consider me a beginner so I would appreciate if you can let me know how to fix and what is the reason?

(x_train_bert, y_train_bert), (x_val_bert, y_val_bert), preproc = text.texts_from_array(
    x_train=x_train, y_train=y_train,
    x_test=x_val, y_test=y_val,
    class_names=train_labels.unique(),
    preprocess_mode='bert',
    lang='en',
    maxlen=65,
    max_features=35000
)

Error : ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Screenshot of error

enter image description here

I found out that I need to use (np.allclose) I am not sure where to use in my code.....Thanks

Update: New Error after updating the code with the solution provided. New Error after updating code with the solution provided

1

There are 1 best solutions below

0
On

Cause of first error: As Mario indicated, you're passing a NumPy array instead of a Python list - change to: train_labels.unique().tolist()

Cause of second error: y_train and y_test must be either NumPy arrays or lists. It looks like you're passing an empty Pandas Series (KeyError: 0). Don't forget .values when setting y_train and y_test. Alternatively, you can use texts_from_df and specify columns in DataFrame.