a b/test_mixep.py
1
from neural_network import NeuralNetwork, NeuralLogistic
2
from mix_of_exp import MixtureOfExperts
3
from neural_network import NeuralNetwork, NeuralLogistic
4
from sklearn.linear_model import LogisticRegression, LinearRegression, SGDClassifier, SGDRegressor
5
import random
6
import numpy as np
7
import matplotlib.colors as mcolors
8
import matplotlib.pyplot as plt
9
from sklearn.ensemble import AdaBoostClassifier
10
from utils import generate_data, plot_predictions, prediction_accuracy, sparsify_data
11
from sklearn.pipeline import FeatureUnion, Pipeline
12
from model_builder import build_model, regex_baseline
13
from model_tester import execute_test
14
import sys
15
import profile
16
17
18
logistic = NeuralLogistic(restarts = 2, regularization = 0.00)
19
20
nn = NeuralNetwork([(8, 'logistic'), (8, 'tanh'), (None, 'softmax')], 'maxent', regularization = 1e0, restarts = 30, max_iter = 10000, init_size = 1, step_size = 1e-2)
21
22
#nn = NeuralNetwork([(None, 'softmax')], 'maxent', include_offset = True, max_iter = 5000)
23
24
me = MixtureOfExperts([NeuralLogistic(regularization = 1e-1), NeuralLogistic(regularization = 1e-1), NeuralLogistic(regularization = 1e-1)], 
25
                       NeuralLogistic(regularization = 1e-1), max_iter = 25)
26
                       #NeuralNetwork([(3, 'tanh'), (None, 'softmax')], 'maxent'))
27
28
adaboost = AdaBoostClassifier(n_estimators = 500)
29
30
mix_ex_args = {'experts' :[NeuralLogistic(regularization = 1e-1), NeuralLogistic(regularization = 1e-1), NeuralLogistic(regularization = 1e-1)], 
31
               'gate'    : NeuralLogistic(regularization = 1e-1),
32
               'max_iter': 15}
33
34
model = build_model(regex_baseline, method = 'me', model_args = mix_ex_args)
35
36
print execute_test(model, 25, 5)
37
38
39
40
41