Ejemplo n.º 1
0
        # run data through autoencoder (so that it can be pulled into classifier)
        ae_predictions = ae.predict_mse(x_train)
        #print 'ae_predictions.shape: ', ae_predictions.shape

        # format the output vectors
        y_train_vector = np.array([
            1 if y_train[np.where(item >= 1)].size else 0 for item in y_train
        ])
        y_test_vector = np.array(
            [1 if y_test[np.where(item >= 1)].size else 0 for item in y_test])
        #print 'y_train_vector shape :', y_train_vector.shape

        from classifier import Classifier
        cf = Classifier('classical', conf)
        #print 'building %s classifier...' % cf.get_model_type()
        cf.add_dense()
        cf.train_classifier(ae_predictions, y_train_vector)
        cf_model = cf.get_model()

        # predict nom nom
        predictions = np.array([
            1 if item >= 0.5 else 0
            for item in cf_model.predict(ae.predict_mse(x_test))
        ])
        predictions_train = np.array([
            1 if item >= 0.5 else 0
            for item in cf_model.predict(ae.predict_mse(x_train))
        ])
        p.plot_wave(predictions, '[test] Classifier Predictions')
        p.plot_wave(predictions_train, '[train] Classifier predicitions')