Example #1
0
    def test_TransferFailure(self):
        X = numpy.zeros((8, 4))
        ae = AE(layers=[L("Tanh", units=8)], n_iter=1)
        ae.fit(X)

        nn = mlp.MultiLayerPerceptron(layers=[mlp.Layer("Tanh", units=4)])
        assert_raises(AssertionError, ae.transfer, nn)
Example #2
0
    def test_TransferSuccess(self):
        X = numpy.zeros((8, 4))
        ae = AE(layers=[L("Tanh", units=4)], n_iter=1)
        ae.fit(X)

        nn = mlp.MultiLayerPerceptron(layers=[mlp.Layer("Tanh", units=4)])
        ae.transfer(nn)
    def test_LayerTypes(self):
        X = numpy.zeros((8,12))
        for l in ['autoencoder', 'denoising']:
            ae = AE(layers=[L("Sigmoid", type=l, units=4)])
            y = ae.fit_transform(X)

            assert_equals(type(y), numpy.ndarray)
            assert_equals(y.shape, (8, 4))
    def test_CostFunctions(self):
        X = numpy.zeros((8,12))
        for t in ['msre', 'mbce']:
            ae = AE(layers=[L("Sigmoid", units=4, cost=t)], n_iter=1)
            y = ae.fit_transform(X)

            assert_equals(type(y), numpy.ndarray)
            assert_equals(y.shape, (8, 4))
Example #5
0
    def test_LayerTypes(self):
        X = numpy.zeros((8, 12))
        for l in ['autoencoder', 'denoising']:
            ae = AE(layers=[L("Sigmoid", type=l, units=4)])
            y = ae.fit_transform(X)

            assert_equals(type(y), numpy.ndarray)
            assert_equals(y.shape, (8, 4))
Example #6
0
    def test_CostFunctions(self):
        X = numpy.zeros((8, 12))
        for t in ['msre', 'mbce']:
            ae = AE(layers=[L("Sigmoid", units=4, cost=t)], n_iter=1)
            y = ae.fit_transform(X)

            assert_equals(type(y), numpy.ndarray)
            assert_equals(y.shape, (8, 4))
def main():
    print '[INFO, time: %s] Getting Data....' % (time.strftime('%H:%M:%S'))
    preprocesser = Preprocess()
    data= preprocesser.read()

    print '[INFO, time: %s] Fitting %s ...' % (time.strftime('%H:%M:%S'), 'Auto Encoder')
    ae = AutoEncoder(
    	layers=[
		Layer("Sigmoid",units=100)
               ],
	learning_rate=0.01,
	n_iter=40,
        verbose=True,
    )
    ae.fit(data[:,:-1])

    print '[INFO, time: %s] Transforming Data with %s ...' % (time.strftime('%H:%M:%S'), 'Auto Encoder')
    splitRatio = 0.67
    train, test = splitDataset(data, splitRatio)
    train = np.asarray(train)
    test = np.asarray(test)
    
    trainX = train[:,:-1]
    trainy = train[:,-1]
    
    testX = test[:,:-1]
    testy = test[:,-1]

    transformed_trainX = ae.transform(trainX)
    transformed_testX = ae.transform(testX)

    print '[INFO, time: %s] Fitting %s ...' % (time.strftime('%H:%M:%S'), 'SVM - rbf kernel (i.e. gaussian) with default paramenters')
    clf = SVC()
    clf.fit(transformed_trainX, trainy)

    print '[INFO, time: %s] Making Predictions...' % (time.strftime('%H:%M:%S'))
    prediction = clf.predict(transformed_testX)
    print '[RESULT, time: %s] accuracy = %f' % (time.strftime('%H:%M:%S'),accuracy_score(testy, prediction))
 def test_FitVerbose(self):
     X = numpy.zeros((8,4))
     ae = AE(layers=[L("Sigmoid", units=8)], n_iter=1, verbose=1)
     ae.fit(X)
Example #9
0
 def test_FitVerbose(self):
     X = numpy.zeros((8, 4))
     ae = AE(layers=[L("Sigmoid", units=8)], n_iter=1, verbose=1)
     ae.fit(X)