Ejemplo n.º 1
0
    def fit(self,
            data_train,
            labels_train,
            verbose=False,
            unit_test=False,
            max_iter=-1):
        param_grid = {
            'max_depth': np.arange(3, 10),
            'n_estimators': [10, 50, 100, 200]
        }
        if unit_test:
            param_grid = [{'max_depth': [3], 'n_estimators': [10]}]

        rf = RandomForestClassifier(max_depth=2, random_state=0)

        self.clf = GridSearchCV(rf, param_grid, verbose=verbose)
        self.clf.fit(data_train, labels_train)

        self.accuracy_tuple_train = compute_accuracy_tuple(
            labels_train, self.clf.predict(data_train))
Ejemplo n.º 2
0
    def fit(self,
            data_train,
            labels_train,
            verbose=False,
            unit_test=False,
            max_iter=-1):
        param_grid = [{
            'C': [1, 10, 100, 1000],
            'kernel': ['linear']
        }, {
            'C': [1, 10, 100, 1000],
            'gamma': [0.001, 0.0001],
            'kernel': ['rbf']
        }]
        if unit_test:
            param_grid = [{'C': [1], 'kernel': ['linear']}]
        svc = SVC_(max_iter=max_iter)

        self.clf = GridSearchCV(svc, param_grid, verbose=verbose)
        self.clf.fit(data_train, labels_train)
        self.accuracy_tuple_train = compute_accuracy_tuple(
            labels_train, self.clf.predict(data_train))
        return self.clf.score(data_train, labels_train)
Ejemplo n.º 3
0
 def score(self, data_test, labels_test):
     labels_pred = self.predict_scmap_cluster(data_test, labels_test)
     self.test_tuple = compute_accuracy_tuple(labels_test, labels_pred)
     return np.mean(labels_pred == labels_test)
Ejemplo n.º 4
0
 def score(self, data_test, labels_test):
     self.accuracy_tuple_test = compute_accuracy_tuple(
         labels_test, self.clf.predict(data_test))
     return self.clf.score(data_test, labels_test)