I'm using sklearn.utils.resample(array to resample, n_Sample) to resample an array from various hz to 2 hz. The problem is that the order of the values is randomized, i.e. every time I run the code, the order of the vector elements changes.
ds = {
"S2": pickle.load(open(string+"WESAD/S2/S2.pkl", 'rb'), encoding='latin1'),
"S7": pickle.load(open(string+"WESAD/S7/S7.pkl", 'rb'), encoding='latin1'),
"S10": pickle.load(open(string+"WESAD/S10/S10.pkl", 'rb'), encoding='latin1'),
"S14": pickle.load(open(string+"WESAD/S14/S14.pkl", 'rb'), encoding='latin1'),
"S17": pickle.load(open(string+"WESAD/S17/S17.pkl", 'rb'), encoding='latin1')
}
print("Subjects loaded")
nSampleChest = len(ds['S2']['signal']['chest']['ACC'])//350
nSampleWristACC = len(ds['S2']['signal']['wrist']['ACC'])//16
nSampleWristBVP = len(ds['S2']['signal']['wrist']['BVP'])//32
nSampleWristEDATEMP = len(ds['S2']['signal']['wrist']['EDA'])//2
X = {}
for s in ds.keys():
X[s] = np.concatenate([
sklearn.utils.resample(ds[s]['signal']['chest']['ACC'], n_samples = nSampleChest),
sklearn.utils.resample(ds[s]['signal']['chest']['ECG'], n_samples = nSampleChest),
sklearn.utils.resample(ds[s]['signal']['chest']['EDA'], n_samples = nSampleChest),
sklearn.utils.resample(ds[s]['signal']['chest']['EMG'], n_samples = nSampleChest),
sklearn.utils.resample(ds[s]['signal']['chest']['Resp'], n_samples = nSampleChest),
sklearn.utils.resample(ds[s]['signal']['chest']['Temp'], n_samples = nSampleChest),
sklearn.utils.resample(ds[s]['signal']['wrist']['ACC'], n_samples = nSampleWristACC),
sklearn.utils.resample(ds[s]['signal']['wrist']['BVP'], n_samples = nSampleWristBVP),
sklearn.utils.resample(ds[s]['signal']['wrist']['EDA'], n_samples = nSampleWristEDATEMP),
sklearn.utils.resample(ds[s]['signal']['wrist']['TEMP'], n_samples = nSampleWristEDATEMP),
], axis = 1)
How can I keep order of the array?
Aucun commentaire:
Enregistrer un commentaire