def model_complexity_exp(self):
        #TODO should we create a new learner object??
        self.learner = DTLearner()
        self.expHelper = ExperimentHelper(self.splitter, self.learner)
        param_range = np.array([2, 4, 6, 8])
        self.expHelper.model_complexity_exp('max_depth', param_range)

        self.learner = DTLearner(max_depth=4)
        self.expHelper = ExperimentHelper(self.splitter, self.learner)
        param_range = np.array([2, 5, 6, 8, 10])
        self.expHelper.model_complexity_exp('max_leaf_nodes', param_range)
        """self.learner = DTLearner(max_depth = 4, max_leaf_nodes = 5)
Exemple #2
0
    def model_complexity_exp2(self):
        #TODO should we create a new learner object??
        self.learner = SVMLearner(kernel='linear', C=0.2)
        self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                          'linear4', 'Linear Kernel')
        param_range = np.array([1, 2, 4, 5, 6, 7, 8])
        self.expHelper.model_complexity_exp('gamma', param_range)

        self.learner = SVMLearner(kernel='linear', C=0.2)
        self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                          'linear5', 'Linear Kernel')
        param_range = np.array([0.1, 0.2, 0.4, 0.5, 0.6, 0.7, 0.8])
        self.expHelper.model_complexity_exp('gamma', param_range)
    def model_complexity_exp_alpha1(self):
        #TODO should we create a new learner object??
        self.learner = ANNLearner(hidden_layer_sizes=(300, ))
        self.expHelper = ExperimentHelper(self.splitter, self.learner, '1')
        #param_range = np.array([(100),(200,),(300,),(400,),(500,)])
        #param_range = np.array([0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1])
        param_range = np.array([0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1])
        self.expHelper.model_complexity_exp('alpha', param_range)

        self.learner = ANNLearner(hidden_layer_sizes=(390, ))
        self.expHelper = ExperimentHelper(self.splitter, self.learner, '2')
        #param_range = np.array([(100),(200,),(300,),(400,),(500,)])
        param_range = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7])
        #param_range = np.array([0.0001, 0.0005, 0.001, 0.005, 0.008])
        self.expHelper.model_complexity_exp('alpha', param_range)
    def model_complexity_exp_2(self):
        #TODO should we create a new learner object??

        self.learner = BoostLearner(max_depth=2)
        self.expHelper = ExperimentHelper(self.splitter, self.learner)
        param_range = np.array([0.1, 0.2, 0.4, 0.6, 0.8, 0.9])
        self.expHelper.model_complexity_exp('learning_rate', param_range)
    def model_complexity_exp(self):
        #TODO should we create a new learner object??

        self.learner = BoostLearner()
        self.expHelper = ExperimentHelper(self.splitter, self.learner)
        param_range = np.array([2, 4, 6, 8, 9, 10])
        self.expHelper.model_complexity_exp('max_depth', param_range)
Exemple #6
0
 def model_complexity_exp_linear1(self):
     #TODO should we create a new learner object??
     self.learner = LinearSVMLearner(dual=True)
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'linear-2', 'LinearKernel')
     param_range = np.array([0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8])
     self.expHelper.model_complexity_exp('C', param_range)
Exemple #7
0
 def model_complexity_exp_linear2(self):
     #TODO should we create a new learner object??
     self.learner = LinearSVMLearner(fit_intercept=True, C=0.01)
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'linear-3', 'LinearKernel')
     param_range = np.array([1, 2, 3, 4, 5, 6])
     self.expHelper.model_complexity_exp('intercept_scaling', param_range)
 def model_complexity_exp_alpha2(self):
     #TODO should we create a new learner object??
     self.learner = ANNLearner()
     self.expHelper = ExperimentHelper(self.splitter, self.learner, '2')
     #param_range = np.array([(100),(200,),(300,),(400,),(500,)])
     param_range = np.array([0.0001, 0.001, 0.01, 0.1, 1, 5])
     self.expHelper.model_complexity_exp('alpha', param_range)
Exemple #9
0
 def learning_curve_iter2_bank(self):
     self.learner = KNNLearner(metric='euclidean',
                               n_neighbors=38,
                               weights='uniform')
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       '-iter-2')
     self.expHelper.learning_curve_exp()
Exemple #10
0
 def model_complexity_exp3(self):
     #TODO should we create a new learner object??
     self.learner = KNNLearner(weights='distance')
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'distance weight')
     param_range = np.array([1, 2, 3, 4, 5])
     self.expHelper.model_complexity_exp('n_neighbors', param_range)
 def model_complexity_exp11(self):
     #TODO should we create a new learner object??
     self.learner = ANNLearner()
     self.expHelper = ExperimentHelper(self.splitter, self.learner)
     param_range = np.array([(50, ), (
         50,
         50,
     ), (
         50,
         50,
         50,
     ), (
         50,
         50,
         50,
         50,
     ), (
         50,
         50,
         50,
         50,
         50,
     )])
     #param_range = np.array([100, 200,300,400, 500])
     self.expHelper.model_complexity_exp('hidden_layer_sizes', param_range)
Exemple #12
0
 def model_complexity_exp2(self):
     #TODO should we create a new learner object??
     self.learner = KNNLearner(metric='euclidean')
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'euclidean')
     param_range = np.array([1, 2, 3, 4, 5])
     self.expHelper.model_complexity_exp('n_neighbors', param_range)
Exemple #13
0
 def experiment_run_test_bank_linear(self):
     self.learner = LinearSVMLearner(fit_intercept=True,
                                     C=0.01,
                                     intercept_scaling=6)
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'Linear Kernel')
     self.expHelper.experiment_run_test()
Exemple #14
0
 def model_complexity_exp4(self):
     #TODO should we create a new learner object??
     self.learner = KNNLearner(metric='euclidean', weights='distance')
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'distance weight')
     param_range = np.arange(1, 40, 2)
     print(param_range)
     self.expHelper.model_complexity_exp('n_neighbors', param_range)
Exemple #15
0
 def learning_curve_iter2_bank_linear(self):
     print("linear")
     self.learner = LinearSVMLearner(fit_intercept=True,
                                     C=0.01,
                                     intercept_scaling=6)
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'Linear Kernel')
     self.expHelper.learning_curve_exp()
Exemple #16
0
 def model_complexity_exp11(self):
     #TODO should we create a new learner object??
     self.learner = KNNLearner()
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'euclidean', '1')
     #param_range = np.array([1,2,3,4,5])
     param_range = np.arange(40, 60, 2)
     print(param_range)
     self.expHelper.model_complexity_exp('n_neighbors', param_range)
 def experiment_run_test_bank2(self):
     self.learner = ANNLearner(activation='relu',
                               alpha=0.7,
                               hidden_layer_sizes=(390, ),
                               learning_rate='constant',
                               solver='adam',
                               early_stopping=False)
     self.expHelper = ExperimentHelper(self.splitter, self.learner)
     self.expHelper.experiment_run_test()
Exemple #18
0
 def model_complexity_exp4(self):
     #TODO should we create a new learner object??
     self.learner = SVMLearner(kernel='linear')
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'linear3', 'Linear Kernel')
     #param_range = np.array([0.5, 1, 1.5, 2])
     #param_range = np.array([2, 3, 4, 5, 6, 9, 12])
     #param_range = np.array([0.01, 0.02, 0.03, 0.043, 0.05, 0.06])
     param_range = np.array([0.0001, 0.0005, 0.0008, 0.001, 0.005, 0.008])
     self.expHelper.model_complexity_exp('C', param_range)
 def learning_curve_iter21_bank(self):
     self.learner = ANNLearner(activation='relu',
                               alpha=0.01,
                               hidden_layer_sizes=(300, ),
                               learning_rate='constant',
                               solver='adam',
                               early_stopping=False)
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       '-iter-2')
     self.expHelper.learning_curve_exp()
Exemple #20
0
 def model_complexity_exp44(self):
     #TODO should we create a new learner object??
     self.learner = SVMLearner(kernel='linear')
     self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                       'linear1', 'Linear Kernel')
     #param_range = np.array([0.5, 1, 1.5, 2])
     #param_range = np.array([2, 3, 4, 5, 6, 9, 12])
     param_range = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.8, 0.9, 1])
     self.expHelper.model_complexity_exp('C', param_range)
     """self.learner = SVMLearner(kernel = 'linear')
 def model_complexity_exp_epoch2(self):
     #TODO should we create a new learner object??
     self.learner = ANNLearner(hidden_layer_sizes=(300, ),
                               alpha=0.0001,
                               early_stopping=False)
     self.expHelper = ExperimentHelper(self.splitter, self.learner, '3')
     #param_range = np.array([(100),(200,),(300,),(400,),(500,)])
     #param_range = np.array([0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1])
     param_range = np.array([1, 10, 50, 100, 200, 500, 1000])
     self.expHelper.model_complexity_exp('max_iter', param_range)
Exemple #22
0
    def model_complexity_exp3(self):
        #TODO should we create a new learner object??
        self.learner = SVMLearner(kernel='sigmoid')
        self.expHelper = ExperimentHelper(self.splitter, self.learner,
                                          'sigmoid', 'Sigmoid Kernel')
        #param_range = np.array([0.05, 0.1, 0.2, 0.3, 0.4, 0.5])
        #self.expHelper.model_complexity_exp('C', param_range)

        param_range = np.array([0.01, 0.03, 0.05, 0.07, 0.09])
        self.expHelper.model_complexity_exp('gamma', param_range)
Exemple #23
0
    def model_complexity_exp6(self):
        #TODO should we create a new learner object??
        #self.learner = SVMLearner(kernel = 'rbf', C =0.1)
        self.learner = SVMLearner(kernel='rbf', C=0.5)
        self.expHelper = ExperimentHelper(self.splitter, self.learner, 'rbf8',
                                          'rbf Kernel')
        #param_range = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7])
        #param_range = np.array([0.5,2, 3, 4, 5, 6])
        param_range = np.array([0.01, 0.03, 0.05, 0.07, 0.09])
        self.expHelper.model_complexity_exp('gamma', param_range)

        self.learner = SVMLearner(kernel='rbf', C=0.5)
        self.expHelper = ExperimentHelper(self.splitter, self.learner, 'rbf9',
                                          'rbf Kernel')
        param_range = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7])
        #param_range = np.array([0.5,2, 3, 4, 5, 6])
        #param_range = np.array([0.01, 0.03, 0.05, 0.07, 0.09])
        self.expHelper.model_complexity_exp('gamma', param_range)
        """self.learner = SVMLearner(kernel = 'rbf', C =0.2)
    def model_complexity_exp(self):
        scoring = 'accuracy'
        nn_model1 = mlrose.NeuralNetwork(hidden_nodes = [50,50,50,50], activation = 'relu', \
                                 algorithm = 'random_hill_climb', max_iters = 1000, \
                                 bias = True, is_classifier = True, learning_rate = 0.0001, \
                                 early_stopping = True, clip_max = 5, max_attempts = 100, \
                                 random_state = 3)

        expHelper = ExperimentHelper(self.splitter, nn_model1, 'RHC')
        param_range = np.array([0.0001, 0.001, 0.002, 0.003, 0.005, 0.008])
        #param_range = np.array([100, 200,300,400, 500])
        expHelper.model_complexity_exp('learning_rate', param_range)
    def model_complexity_exp_restart_rhc(self):
        #TODO should we create a new learner object??
        scoring = 'accuracy'
        nn_model1 = mlrose.NeuralNetwork(hidden_nodes = [50,50,50,50], activation = 'relu', \
                                 algorithm = 'random_hill_climb', max_iters = 1000, \
                                 bias = True, is_classifier = True, learning_rate = 0.0001, \
                                 early_stopping = True, clip_max = 5, max_attempts = 100, \
                                 random_state = 3, restarts = 0)

        expHelper = ExperimentHelper(self.splitter, nn_model1, 'RHC')
        param_range = [1, 10, 50, 100, 200, 300, 400, 500]
        expHelper.model_complexity_exp('restarts', param_range)
    def model_complexity_exp_max_attempt_ga(self):
        #TODO should we create a new learner object??
        scoring = 'accuracy'
        nn_model1 = mlrose.NeuralNetwork(hidden_nodes = [50,50,50,50], activation = 'relu', \
                                 algorithm = 'genetic_alg', max_iters = 1000, \
                                 bias = True, is_classifier = True, learning_rate = 0.0001, \
                                 early_stopping = True, clip_max = 5, max_attempts = 100, \
                                 pop_size= 2000, random_state = 3)

        expHelper = ExperimentHelper(self.splitter, nn_model1, 'GA')
        param_range = [20, 50, 100, 200, 300]
        expHelper.model_complexity_exp('max_attempts', param_range)
    def model_complexity_exp_epoch_no_stop_sa(self):
        #TODO should we create a new learner object??
        scoring = 'accuracy'

        nn_model1 = mlrose.NeuralNetwork(hidden_nodes = [50,50,50,50], activation = 'relu', \
                                 algorithm = 'simulated_annealing', max_iters = 1000, \
                                 bias = True, is_classifier = True, learning_rate = 0.0001, \
                                 early_stopping = False, clip_max = 5, max_attempts = 100, \
                                 random_state = 3)

        expHelper = ExperimentHelper(self.splitter, nn_model1, 'SA')
        param_range = [1, 10, 50, 100, 200, 500]
        expHelper.model_complexity_exp('max_iters', param_range)
 def experiment_run_test_bank_iter2(self):
     self.learner = ANNLearner(activation='relu',
                               alpha=0.06,
                               hidden_layer_sizes=(200, 200, 200, 200, 200,
                                                   200, 200),
                               learning_rate='constant',
                               solver='adam',
                               early_stopping=True,
                               max_iter=600,
                               momentum=0.4)
     print('100, 100, 100, 100, 100, 100,50 alpha 0.3')
     self.expHelper = ExperimentHelper(self.splitter, self.learner)
     self.expHelper.experiment_run_test()
     """ self.learner = ANNLearner(
Exemple #29
0
    def model_complexity_exp5(self):
        #TODO should we create a new learner object??
        self.learner = SVMLearner(kernel='rbf')
        self.expHelper = ExperimentHelper(self.splitter, self.learner, 'rbf1',
                                          'rbf Kernel')

        param_range = np.array([0.05, 0.1, 0.2, 0.3, 0.4, 0.5])
        self.expHelper.model_complexity_exp('C', param_range)

        self.learner = SVMLearner(kernel='rbf')
        self.expHelper = ExperimentHelper(self.splitter, self.learner, 'rbf2',
                                          'rbf Kernel')
        param_range = np.array([0.5, 1, 1.5, 2])

        self.expHelper.model_complexity_exp('C', param_range)

        self.learner = SVMLearner(kernel='rbf')
        self.expHelper = ExperimentHelper(self.splitter, self.learner, 'rbf3',
                                          'rbf Kernel')

        param_range = np.array([2, 3, 4, 5, 6, 9, 12])

        self.expHelper.model_complexity_exp('C', param_range)
    def model_complexity_exp_max_attempts_sa(self):
        #TODO should we create a new learner object??
        scoring = 'accuracy'
        decay = mlrose.decay.ExpDecay()
        nn_model1 = mlrose.NeuralNetwork(hidden_nodes = [50,50,50,50], activation = 'relu', \
                                 algorithm = 'simulated_annealing', max_iters = 1000, \
                                 bias = True, is_classifier = True, learning_rate = 0.0001, \
                                 early_stopping = True, clip_max = 5, max_attempts = 100, \
                                 schedule = decay,
                                 random_state = 3)

        expHelper = ExperimentHelper(self.splitter, nn_model1, 'SA')
        param_range = [20, 50, 100, 200, 300]
        expHelper.model_complexity_exp('max_attempts', param_range)
        print('completed max attempt sa nn')