def doGridSearch(self):
     # params = {'base_estimator__max_depth': 10}
     # self.classifier.set_params(**params)
     # parameters = {'base_estimator__max_depth': np.arange(2, 12, 1)}
     # parameters = {'base_estimator__max_depth':np.arange(2, 12, 1),
     #               'base_estimator__min_samples_split':np.arange(2, 100, 1)}
     # parameters = {'base_estimator__max_depth': [7,8,9,10], 'learning_rate':[.1, .01, .001, .0001], 'n_estimators':[100, 110,120,130,150,170,200]}
     parameters = {
         'base_estimator__max_depth': [3, 4, 5],
         'learning_rate': np.arange(.0001, .9, .05),
         'n_estimators': np.arange(10, 300, 20)
     }
     clf = GridSearchCV(self.classifier, parameters, refit=True, cv=self.cv)
     clf.fit(self.X_train, self.y_train)
     a = pd.DataFrame(clf.best_params_, index=[0])
     a.to_csv('{}/images/{}/{}/{}_{}_gridsearch.csv'.format(
         '.', self.datasetName, self.algoname, self.datasetName,
         self.algoname))
     self.classifier = clf.best_estimator_
     self.classifier.set_params(**clf.best_params_)
     timing.getTimingData(self.X_train,
                          self.y_train,
                          self.classifier,
                          self.algoname,
                          self.datasetName,
                          prefix='GS')
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy(prefix='GS')
     self.generateFinalLC(prefix='GS')
Exemplo n.º 2
0
 def generateFinalModel(self):
     params = {'n_neighbors': 1, 'metric': 'manhattan', 'weights': 'uniform'}
     self.classifier.set_params(**params)
     timing.getTimingData(self.X_train, self.y_train,self.classifier,self.algoname, self.datasetName)
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy()
     self.generateFinalLC()
Exemplo n.º 3
0
 def doGridSearch(self):
     # parameters = {"C": np.arange(0.001, 2.5, 0.25)}
     parameters = {
         "C": np.arange(0.001, 2.5, 0.25),
         "gamma": np.arange(1 / self.features.shape[1], 2.1, 0.1)
     }
     clf = GridSearchCV(self.classifier, parameters, refit=True, cv=self.cv)
     clf.fit(self.X_train, self.y_train)
     js = json.dumps(clf.best_params_)
     filename = '{}/images/{}/{}/{}_{}_GSP.json'.format(
         '.', self.datasetName, self.algoname, self.datasetName,
         self.algoname)
     f = open(filename, "w")
     f.write(js)
     f.close()
     self.classifier = clf.best_estimator_
     self.classifier.set_params(**clf.best_params_)
     timing.getTimingData(self.X_train,
                          self.y_train,
                          self.classifier,
                          self.algoname,
                          self.datasetName,
                          prefix='GS')
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy(prefix='GS')
     self.generateFinalLC(prefix='GS')
    def doGridSearch(self):
        dimension = self.features.shape[1]
        # parameters = {'solver':['lbfgs', 'adam'], "alpha": np.logspace(-5, 3, 20),'max_iter':np.arange(2, 1000, 10),
        #               'hidden_layer_sizes': [(h,) * l for l in [1, 2, 3] for h in [dimension, dimension // 2, dimension * 2]]}
        parameters = {
            'alpha':
            np.logspace(-5, 3, 20),
            'max_iter': [2**x for x in range(10)],
            'hidden_layer_sizes':
            [(h, ) * l for l in [1, 2, 3]
             for h in [dimension, dimension // 2, dimension * 2]]
        }

        clf = GridSearchCV(self.classifier, parameters, refit=True, cv=self.cv)
        clf.fit(self.X_train, self.y_train)
        js = json.dumps(clf.best_params_)
        filename = '{}/images/{}/{}/{}_{}_GSP.json'.format(
            '.', self.datasetName, self.algoname, self.datasetName,
            self.algoname)
        f = open(filename, "w")
        f.write(js)
        f.close()
        self.classifier = clf.best_estimator_
        self.classifier.set_params(**clf.best_params_)
        timing.getTimingData(self.X_train,
                             self.y_train,
                             self.classifier,
                             self.algoname,
                             self.datasetName,
                             prefix='GS')
        self.classifier.fit(self.X_train, self.y_train)
        self.generateFinalAccuracy(prefix='GS')
        self.generateFinalLC(prefix='GS')
 def generateFinalModel(self):
     params = {"C": 2.251, "gamma": 0.2625,'class_weight':'balanced'}
     self.classifier.set_params(**params)
     timing.getTimingData(self.X_train, self.y_train,self.classifier,self.algoname, self.datasetName)
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy()
     self.generateFinalLC()
Exemplo n.º 6
0
 def generateFinalModel(self):
     params = {'max_depth': 22, 'class_weight': 'balanced'}
     self.classifier.set_params(**params)
     timing.getTimingData(self.X_train, self.y_train, self.classifier,
                          self.algoname, self.datasetName)
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy()
     self.generateFinalLC()
 def generateFinalModel(self):
     params = {
         'base_estimator__max_depth': 20,
         'n_estimators': 100,
         'learning_rate': .01
     }
     self.classifier.set_params(**params)
     timing.getTimingData(self.X_train, self.y_train, self.classifier,
                          self.algoname, self.datasetName)
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy()
     self.generateFinalLC()
 def generateFinalModel(self):
     params = {
         "alpha": 0.003359818286283781,
         "hidden_layer_sizes": [32, 32, 32],
         "max_iter": 128
     }
     self.classifier.set_params(**params)
     timing.getTimingData(self.X_train, self.y_train, self.classifier,
                          self.algoname, self.datasetName)
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy()
     self.generateFinalLC()
Exemplo n.º 9
0
 def generateFinalModel(self):
     params = {
         "alpha": 0.0004832930238571752,
         "hidden_layer_sizes": [20, 20, 20],
         "max_iter": 256
     }
     self.classifier.set_params(**params)
     timing.getTimingData(self.X_train, self.y_train, self.classifier,
                          self.algoname, self.datasetName)
     self.classifier.fit(self.X_train, self.y_train)
     self.generateFinalAccuracy()
     self.generateFinalLC()
Exemplo n.º 10
0
    def doGridSearch(self):
        parameters = {"n_neighbors":np.arange(1,50,1), "metric":['manhattan', 'chebyshev', 'euclidean']}

        clf = GridSearchCV(self.classifier, parameters, refit=True, cv=self.cv)
        clf.fit(self.X_train, self.y_train)
        a = pd.DataFrame(clf.best_params_, index=[0])
        a.to_csv('{}/images/{}/{}/{}_{}_gridsearch.csv'.format('.', self.datasetName, self.algoname,
                                                                       self.datasetName, self.algoname))
        self.classifier = clf.best_estimator_
        self.classifier.set_params(**clf.best_params_)
        timing.getTimingData(self.X_train, self.y_train, self.classifier, self.algoname, self.datasetName,prefix='GS')
        self.classifier.fit(self.X_train, self.y_train)
        self.generateFinalAccuracy(prefix='GS')
        self.generateFinalLC(prefix='GS')
Exemplo n.º 11
0
    def doGridSearch(self):
        parameters = {
            'max_depth': np.arange(8, 24, 1),
            "min_samples_split": np.arange(2, 100, 5)
        }

        clf = GridSearchCV(self.classifier, parameters, refit=True, cv=self.cv)
        clf.fit(self.X_train, self.y_train)
        a = pd.DataFrame(clf.best_params_, index=[0])
        a.to_csv('{}/images/{}/{}/{}_{}_gridsearch.csv'.format(
            '.', self.datasetName, self.algoname, self.datasetName,
            self.algoname))
        self.classifier = clf.best_estimator_
        self.classifier.set_params(**clf.best_params_)
        timing.getTimingData(self.X_train,
                             self.y_train,
                             self.classifier,
                             self.algoname,
                             self.datasetName,
                             prefix='GS')
        self.classifier.fit(self.X_train, self.y_train)
        self.generateFinalAccuracy(prefix='GS')
        self.generateFinalLC(prefix='GS')
    def doGridSearch(self):
        parameters = {
            'base_estimator__max_depth': np.arange(5, 22, 1),
            'learning_rate': np.arange(.0001, .9, .05),
            'n_estimators': np.arange(10, 300, 20)
        }

        clf = GridSearchCV(self.classifier, parameters, refit=True, cv=self.cv)
        clf.fit(self.X_train, self.y_train)
        a = pd.DataFrame(clf.best_params_, index=[0])
        a.to_csv('{}/images/{}/{}/{}_{}_gridsearch.csv'.format(
            '.', self.datasetName, self.algoname, self.datasetName,
            self.algoname))
        self.classifier = clf.best_estimator_
        self.classifier.set_params(**clf.best_params_)
        timing.getTimingData(self.X_train,
                             self.y_train,
                             self.classifier,
                             self.algoname,
                             self.datasetName,
                             prefix='GS')
        self.classifier.fit(self.X_train, self.y_train)
        self.generateFinalAccuracy(prefix='GS')
        self.generateFinalLC(prefix='GS')