def _create_datasets(self): self.value = {} max_sessions = 10 if self.fast else None sessions = Session.fetch_all(only_real=True, include_timeframes=True, max=max_sessions) pbar = tqdm( total=self.count, desc="Creating Datasets{}".format(" (fast)" if self.fast else "")) for wl in self.window_lengths: self.value[str(wl)] = {} wl_datasets = list( Session.full_dataset_gen(window_length=wl, count=self.cv_splits, sessions=sessions)) for sample_trim in self.sample_trims: self.value[str(wl)][str(sample_trim)] = {} st_datasets = [ ds.trim_none_seconds(sample_trim, return_copy=True) for ds in wl_datasets ] for ds_type in self.dataset_types: dt_datasets = [] for st_ds in st_datasets: ds = st_ds.copy() ds = ds.reduced_dataset(ds_type) ds = ds.normalize() ds.shuffle() dt_datasets.append(ds) pbar.update(1) self.value[str(wl)][str(sample_trim)][str( ds_type)] = dt_datasets pbar.close()
self.sample_shape = (2 * len(sample), cAshape[0]) if self.dim == 2: coeffs = pywt.dwt2(sample, self.wavelet) cA, (cH, cV, cD) = coeffs res = np.vstack((cA, cH, cV, cD)) self.sample_shape = np.shape(res) return self if __name__ == '__main__': ds = list(Session.full_dataset_gen(window_length=10))[0] indices = [] for class_idx in [0, 1]: for i, y in enumerate(ds.y): if y == class_idx: indices.append(i) break print(indices) wavelet = DWT(dim=1, wavelet='db1') wavelet.fit(ds.X) for i in indices: