def fit(self, X_train, y_train, X_test, y_test, batch_size=50, nb_epoch=3): """ :param X_train: each instance is a list of word index :param y_train: :return: """ print(len(X_train), 'train sequences') print(len(X_test), 'test sequences') print("Pad sequences (samples x time)") X_train = sequence.pad_sequences(X_train, maxlen=self.maxlen) X_test = sequence.pad_sequences(X_test, maxlen=self.maxlen) print('X_train shape:', X_train.shape) print('X_test shape:', X_test.shape) y_train = expand_label(y_train) y_test = expand_label(y_test) #early stopping early_stop = EarlyStopping(monitor='val_loss', patience=2) self.model.fit({ 'input': X_train, 'output': y_train }, batch_size=batch_size, nb_epoch=nb_epoch, verbose=1, validation_data=({ 'input': X_test, 'output': y_test }), callbacks=[early_stop])
def fit(self, X_train, y_train, X_test, y_test, batch_size=100, nb_epoch=3, show_accuracy=True): """ :param X_train: each instance is a list of word index :param y_train: :return: """ print(len(X_train), 'train sequences') print(len(X_test), 'test sequences') print("Pad sequences (samples x time)") X_train = sequence.pad_sequences(X_train, maxlen=self.maxlen) X_test = sequence.pad_sequences(X_test, maxlen=self.maxlen) print('X_train shape:', X_train.shape) print('X_test shape:', X_test.shape) y_train = expand_label(y_train) y_test = expand_label(y_test) self.model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=nb_epoch, show_accuracy=True, validation_data=(X_test, y_test))
def fit(self, X_train, y_train, X_test, y_test, batch_size=50, nb_epoch=3): """ :param X_train: each instance is a list of word index :param y_train: :return: """ print(len(X_train), 'train sequences') print(len(X_test), 'test sequences') print("Pad sequences (samples x time)") X_train = sequence.pad_sequences(X_train, maxlen=self.maxlen) X_test = sequence.pad_sequences(X_test, maxlen=self.maxlen) print('X_train shape:', X_train.shape) print('X_test shape:', X_test.shape) y_train = expand_label(y_train) y_test = expand_label(y_test) #early stopping early_stop = EarlyStopping(monitor='val_loss', patience=2) self.model.fit({'input': X_train, 'output': y_train}, batch_size=batch_size, nb_epoch=nb_epoch, verbose=1, validation_data=({'input': X_test, 'output': y_test}), callbacks=[early_stop])
def get_single_feature(raw_df, KPI_ID_name): df = pd.DataFrame(raw_df.copy()) df = df.reset_index(drop=True) # test_manual_feature = get_manual_feature(KPI_LIST_test[index]) # test_manual_feature['diff_shift'] # median_time = test_manual_feature['diff_timestamp_feature'].median() print("KPI_LIST_test[index] length:", len(KPI_LIST_test[index])) # print("test_manual_feature length:", len(test_manual_feature)) # test_processd_feature = get_process_feature(is_test=True, KPI_ID_name=KPI_ID_name, window=window) # df['pro_diff'] = test_processd_feature # df['pro_diff'] = df['pro_diff'] * 100 del df['timestamp'] del df['KPI ID'] # print(df) if KPI_ID_name == '1c35dbf57f55f5e4': y_df = df['value'].map(lg_1600) elif KPI_ID_name == '7c189dd36f048a6c': y_df = df['value'].map(lw_300) elif KPI_ID_name == '8a20c229e9860d0c': y_df = df['value'].map(a20) elif KPI_ID_name == '8bef9af9a922e0b3': y_df = df['value'].map(bef) elif KPI_ID_name == '8c892e5525f3e491': y_df = df['value'].map(c89) elif KPI_ID_name == '9bd90500bfd11edb': y_df = df['value'].map(bd9) elif KPI_ID_name == '9ee5879409dccef9': y_df = df['value'].map(ee5) elif KPI_ID_name == '02e99bd4f6cfb33f': y_df = df['value'].map(e99) elif KPI_ID_name == '18fbb1d5a5dc099d': y_df = df['value'].map(fbb) elif KPI_ID_name == '40e25005ff8992bd': y_df = df['value'].map(e25) elif KPI_ID_name == '54e8a140f6237526': y_df = df['value'].map(e8a) elif KPI_ID_name == '76f4550c43334374': y_df = df['value'].map(f45) elif KPI_ID_name == '88cf3a776ba00e7c': y_df = df['value'].map(cf3) elif KPI_ID_name == '046ec29ddf80d62e': y_df = df['value'].map(ec2) elif KPI_ID_name == '07927a9a18fa19ae': y_df = df['value'].map(a9a) elif KPI_ID_name == '09513ae3e75778a3': y_df = df['value'].map(ae3) elif KPI_ID_name == '71595dd7171f4540': y_df = df['value'].map(dd7) elif KPI_ID_name == '769894baefea4e9e': y_df = df['value'].map(bae) elif KPI_ID_name == 'a5bf5d65261d859a': y_df = df['value'].map(a5b) elif KPI_ID_name == 'a40b1df87e3f1c87': y_df = df['value'].map(a40) elif KPI_ID_name == 'affb01ca2b4f0b45': y_df = df['value'].map(aff) elif KPI_ID_name == 'b3b2e6d1a791d63a': y_df = df['value'].map(b3b) elif KPI_ID_name == 'c58bfcbacb2822d1': test_manual_feature = get_manual_feature(KPI_LIST_test[index]) y_df = test_manual_feature['is_diff_over_3sigma'] elif KPI_ID_name == 'cff6d3c01e6a6bfa': y_df = df['value'].map(cff) elif KPI_ID_name == 'da403e4e3f87c9e0': y_df = df['value'].map(da4) elif KPI_ID_name == 'e0770391decc44ce': y_df = df['value'].map(e07) # print("y_df before shift:") # print(y_df) df['y'] = y_df if is_shift: df['y'] = df['y'].shift(shift) df['y'].bfill(inplace=True) df['y'] = df['y'].map(to_int) df['y'] = expand_label(df['y'].values, wide=wide) return df['y']