Esempio n. 1
0
    TP = np.sum(results * y)
    precision = TP / np.sum(results)
    recall = TP / np.sum(y)
    print('Precision: %g' % precision)
    print('Recall: %g' % recall)
    print('F-measure: %g' % (2 * precision * recall / (precision + recall)))
    config.log('Precision: %g' % precision)
    config.log('Recall: %g' % recall)
    config.log('F-measure: %g' % (2 * precision * recall /
                                  (precision + recall)))


if __name__ == '__main__':
    dataset = FLAGS.dataset
    print('########### Start CNN on Dataset ' + dataset + ' ###########')
    config.init('CNN_' + dataset)
    train_dir = config.path + FLAGS.train_dir

    if dataset == 'HDFS':
        data_instances = config.HDFS_data
        (x_train, y_train), (x_test,
                             y_test), (x_validate,
                                       y_validate) = dataloader.load_HDFS(
                                           data_instances,
                                           train_ratio=0.3,
                                           is_data_instance=True,
                                           test_ratio=0.6,
                                           CNN_option=True)
    elif dataset == 'BGL':
        data_instances = config.BGL_data
Esempio n. 2
0
        self.best_f1_score = 0.0

    def on_epoch_end(self, epoch, logs=None):
        if (epoch + 1) % FLAGS.checkpoint_frequency == 0:
            f1_score = apply_model(self.x_val, self.y_val, self.model,
                                   'validation')
            if f1_score > self.best_f1_score:
                print('Saving model to %s' % checkpoint_name)
                model.save_weights(checkpoint_name)
                self.best_f1_score = f1_score


if __name__ == '__main__':
    dataset = FLAGS.dataset
    print('########### Start LSTM on Dataset ' + dataset + ' ###########')
    config.init('LSTM_' + dataset)
    checkpoint_name = config.path + FLAGS.checkpoint_name

    (x_train, y_train), (x_test, y_test), (x_validate,
                                           y_validate) = (None,
                                                          None), (None,
                                                                  None), (None,
                                                                          None)
    collector = None
    if dataset == 'BGL':
        data_instances = config.BGL_data

        (x_train,
         y_train), (x_test,
                    y_test), (x_validate,
                              y_validate) = load_BGL(data_instances, 0.35, 0.6)