Open talhaanwarch opened 4 years ago
One way is to do it following way using user-defined features
from mne_features.univariate import compute_pow_freq_bands
def pow_freq(x):
return compute_pow_freq_bands(128,x,freq_bands=np.array([0.5, 4., 8., 13.,30.]))
def energy_freq(x):
return compute_energy_freq_bands(128,x,freq_bands=np.array([0.5, 4., 8., 13.,30.]))
selected_funcs = [('powfreq', pow_freq),('energyfreq',energy_freq),'line_length', 'kurtosis', 'ptp_amp', 'skewness']
But energyfreq
is giving a strange warning and setting accuracy to NaN. Whereas powfreq
is working correctly.
Issue with energyfreq is as follow
Cross-validation accuracy score = nan (+/- nan)
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_split.py:296: FutureWarning: Setting a random_state has no effect since shuffle is False. This will raise an error in 0.24. You should leave random_state to its default (None), or set shuffle=True.
FutureWarning
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py:536: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details:
ValueError: Data to be filtered must be real floating, got int64
FitFailedWarning)
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py:536: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details:
ValueError: Data to be filtered must be real floating, got int64
FitFailedWarning)
Please check this colab file for reproducing the problem
your data is of dtype int64
do:
scores = cross_val_score(pipe, data.astype(float), y, cv=skf)
and it works
Thanks. In both cases, the data type is int64, but in the case of pow_freq
it worked and in another case energy_freq
it did not. But changing data type to float it worked
i figured out this is the issue with compute_energy_freq_bands
that required data in float64
data type. Converting data to float64
will increase the computational time and space.
int64 and float64 are the same size. 64 bits per entry. It just needs to be fixed in mne-features.
I am trying to extract frequency band features using following way
It throwing me following error
'The entries of the given
freq_bandsparameter (%s) must be positive and less than the Nyquist 'frequency.' % str(freq_bands).
So how can I remove the 100Hz frequency value limit from
['energy_freq_bands','pow_freq_bands']
while extracting features. I mean how can I just setfreq_bands=np.array([0.5, 4., 8., 13.,30.])
without changing much things