mondejar / ecg-classification

Code for training and test machine learning classifiers on MIT-BIH Arrhyhtmia database
GNU General Public License v3.0
520 stars 193 forks source link

ValueError: Found array with 0 sample(s) (shape=(0, 23)) while a minimum of 1 isrequired by StandardScaler. #8

Closed gemorningsun closed 5 years ago

gemorningsun commented 5 years ago

Runing train_SVM.py! Loading MIT BIH arr (DS1) ... Computing morphological features (DS1) ... Wavelets ... labels writing pickle: /home/mjz/gzy/ecg-classification/python/ECG/mitbih_database/feat ures/w_90_90_DS1_rm_bsline_maxRR_wvlt_MLII.p... Loading MIT BIH arr (DS2) ... Computing morphological features (DS2) ... Wavelets ... labels writing pickle: /home/mjz/gzy/ecg-classification/python/ECG/mitbih_database/feat ures/w_90_90_DS2_rm_bsline_maxRR_wvlt_MLII.p... Traceback (most recent call last): File "run_train_SVM.py", line 54, in main(multi_mode, 90, 90, do_preprocess, use_weight_class, maxRR, use_RR, nor m_RR, compute_morph, oversamp_method, pca_k, feature_selection, do_crossval, C value, gamma_value, reduced_DS, leads_flag) File "/home/mjz/gzy/ecg-classification/python/train_SVM.py", line 195, in main scaler.fit(tr_features) File "/home/mjz/anaconda3/lib/python3.5/site-packages/sklearn/preprocessing/da ta.py", line 590, in fit return self.partial_fit(X, y) File "/home/mjz/anaconda3/lib/python3.5/site-packages/sklearn/preprocessing/da ta.py", line 612, in partial_fit warn_on_dtype=True, estimator=self, dtype=FLOAT_DTYPES) File "/home/mjz/anaconda3/lib/python3.5/site-packages/sklearn/utils/validation .py", line 431, in check_array context)) ValueError: Found array with 0 sample(s) (shape=(0, 23)) while a minimum of 1 is required by StandardScaler.

RayShark commented 5 years ago

Well, I had the same error as you. Have you got the solution yet? @gemorningsun

banivyom commented 5 years ago

shape=(0,23) shows that there is no data. I'll suggest that check whether the read data part and write pickle file part of the code is working correctly or not, you might want to change the way it's been done.

abhishekkathayat commented 5 years ago

I faced the same problem. In my case it was reading annotations file as binary in load_MITBIH.py at line 528. I replaced 'rb' with 'r' and it worked.

NasimSulaiman commented 4 years ago

I am having the same error , how to solve this !!!

melika-kheirieh commented 3 years ago

I faced the same problem. In my case it was reading annotations file as binary in load_MITBIH.py at line 528. I replaced 'rb' with 'r' and it worked.

It worked for me. Thankful