def getSampleData(data, mode='trapezoidal'): # only for feature plot copydata = copy.deepcopy(data) random.shuffle(copydata) if mode == 'trapezoidal': dataset = preprocess.removeDataTrapezoidal(copydata) if mode == 'variable': dataset = preprocess.removeRandomData(copydata) else: "ERROR, WRONG STREAM_MODE" all_keys = set().union(*(d.keys() for d in dataset)) X, y = [], [] for row in dataset: for key in all_keys: if key not in row.keys(): row[key] = 0 y.append(row['class_label']) del row['class_label'] if 0 not in row.keys(): start = 1 if 0 in row.keys(): start = 0 for row in dataset: X_row = [] for i in range(start, len(row)): X_row.append(row[i]) X.append(X_row) return X, y
def getShuffledData(self, mode=p.stream_mode ): # generate data for cross validation data = self.data copydata = copy.deepcopy(data) random.shuffle(copydata) if mode == 'trapezoidal': dataset = preprocess.removeDataTrapezoidal(copydata) if mode == 'variable': dataset = preprocess.removeRandomData(copydata) else: dataset = copydata all_keys = set().union(*(d.keys() for d in dataset)) X, y = [], [] for row in dataset: for key in all_keys: if key not in row.keys(): row[key] = 0 y.append(row['class_label']) del row['class_label'] if 0 not in row.keys(): start = 1 if 0 in row.keys(): start = 0 for row in dataset: X_row = [] for i in range(start, len(row)): X_row.append(row[i]) X.append(X_row) self.X, self.y = X, y
def getShuffledTrapezoidalData(data): copydata = copy.deepcopy(data) random.shuffle(copydata) dataset = p.removeDataTrapezoidal(copydata) all_keys = set().union(*(d.keys() for d in dataset)) X, y = [], [] for row in dataset: for key in all_keys: if key not in row.keys(): row[key] = 0 y.append(row['class_label']) del row['class_label'] if 0 not in row.keys(): start = 1 if 0 in row.keys(): start = 0 for row in dataset: X_row = [] for i in range(start, len(row)): X_row.append(row[i]) X.append(X_row) return X, y
def getShuffledData(self): # generate data for cross validation data = self.data copydata = copy.deepcopy(data) random.Random(p.random_seed).shuffle(copydata) dataset = preprocess.removeDataTrapezoidal(copydata) all_keys = set().union(*(d.keys() for d in dataset)) X, y = [], [] for row in dataset: for key in all_keys: if key not in row.keys(): row[key] = 0 y.append(row['class_label']) del row['class_label'] if 0 not in row.keys(): start = 1 if 0 in row.keys(): start = 0 for row in dataset: X_row = [] for i in range(start, len(row)): X_row.append(row[i]) X.append(X_row) self.X, self.y = X, y