electricity-theft-detection-with-self-attention icon indicating copy to clipboard operation
electricity-theft-detection-with-self-attention copied to clipboard

how to solve this error? thanks

Open zzzhmy opened this issue 1 year ago • 4 comments

TypeError Traceback (most recent call last) in <cell line: 1>() ----> 1 f1_per_fold = perform_kfold_cv(df, models, optims, criterion, k_folds, device=device, n_epochs=10)

3 frames /usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py in _num_samples(x) 333 if hasattr(x, "shape") and x.shape is not None: 334 if len(x.shape) == 0: --> 335 raise TypeError( 336 "Singleton array %r cannot be considered a valid collection." % x 337 )

TypeError: Singleton array array(<Flags(allows_duplicate_labels=True)>, dtype=object) cannot be considered a valid collection.

zzzhmy avatar Jan 06 '24 07:01 zzzhmy

it's solved,thanks

zzzhmy avatar Jan 10 '24 06:01 zzzhmy

解决了,谢谢

你好,我碰到了同样的问题,请问您是如何解决的?谢谢

zzk1212 avatar Mar 29 '24 12:03 zzk1212

it's solved,thanks I meet the same question, could you let me know what you solve the problem?

yeqian1961 avatar Jun 04 '24 13:06 yeqian1961

I solved this problem by changing the way it accesses the target column.

In the file train.py, within the function 'perform_kfold_cv', change df.flags to df['flags']. The first returns the attribute of the dataframe, while the second accesses the data within the flags column

Tisandg avatar Jun 20 '24 16:06 Tisandg