(self, clf_method='ERF', classifier=None, param_grid=None)
Initialize a new classifier instance
Initialize a new classifier instance
Initialize a new classifier instance
def __init__(self, clf_method='ERF', classifier=None, param_grid=None):
        """ Initialize a new classifier instance """

        # Set classifier
        self.features_selected = None
        self.predictions = None

        if classifier is not None:
            self.clf = classifier

            from sklearn.svm import LinearSVC
            import random
            if isinstance(self.clf, LinearSVC):
                self.clf.set_params().random_state = random.randint(0, 200)
        else:
            if clf_method == 'SVM':
                from sklearn import svm
                self.clf = svm.SVC()
            elif clf_method == 'ERF':
                from sklearn.ensemble import ExtraTreesClassifier
                self.clf = ExtraTreesClassifier(
                    n_estimators=100, max_depth=None, min_samples_split=1,
                    random_state=0)
            elif clf_method == 'GBC':
                from sklearn.ensemble import GradientBoostingClassifier
                self.clf = GradientBoostingClassifier(n_estimators=100,
                                                      max_depth=1)
            elif clf_method == 'Dummy':
                from sklearn.dummy import DummyClassifier
                self.clf = DummyClassifier(strategy='stratified')
            else:
                raise Exception('Unrecognized classification method')

        if isinstance(param_grid, dict):
            from sklearn.model_selection import GridSearchCV
            self.clf = GridSearchCV(estimator=self.clf,
                                    param_grid=param_grid)
def __init__ ( self , clf_method = 'ERF' , classifier = None , param_grid = None ) : # Set classifier self . features_selected = None self . predictions = None if classifier is not None : self . clf = classifier from sklearn . svm import LinearSVC import random if isinstance ( self . clf , LinearSVC ) : self . clf . set_params ( ) . random_state = random . randint ( 0 , 200 ) else : if clf_method == 'SVM' : from sklearn import svm self . clf = svm . SVC ( ) elif clf_method == 'ERF' : from sklearn . ensemble import ExtraTreesClassifier self . clf = ExtraTreesClassifier ( n_estimators = 100 , max_depth = None , min_samples_split = 1 , random_state = 0 ) elif clf_method == 'GBC' : from sklearn . ensemble import GradientBoostingClassifier self . clf = GradientBoostingClassifier ( n_estimators = 100 , max_depth = 1 ) elif clf_method == 'Dummy' : from sklearn . dummy import DummyClassifier self . clf = DummyClassifier ( strategy = 'stratified' ) else : raise Exception ( 'Unrecognized classification method' ) if isinstance ( param_grid , dict ) : from sklearn . model_selection import GridSearchCV self . clf = GridSearchCV ( estimator = self . clf , param_grid = param_grid )