def parse(self, jsonData):
        if jsonData['estimator'].endswith('Classifier'):
            from sklearn.tree import DecisionTreeClassifier
            self.estimator = DecisionTreeClassifier(criterion='gini')
            self.is_regr = False
        else:
            from sklearn.tree import DecisionTreeRegressor
            self.estimator = DecisionTreeRegressor(criterion='mse')
            self.is_regr = True
        self.params = {}

        import sys
        sys.path.insert(1, 'utils')
        import dict_utils
        self.params['max_depth'] = dict_utils.parse_related_properties(
            'max_depth', jsonData, None)
        self.params['min_samples_split'] = dict_utils.parse_related_properties(
            'min_samples_split', jsonData, 2)
        self.params['min_samples_leaf'] = dict_utils.parse_related_properties(
            'min_samples_leaf', jsonData, 1)
        self.params['max_leaf_nodes'] = dict_utils.parse_related_properties(
            'max_leaf_nodes', jsonData, None)

        sys.path.insert(1, 'output')
        import DecisionTree_OM
        self.output_manager = DecisionTree_OM.DecisionTree_OM(self)
示例#2
0
    def parse(self, jsonData):
        if jsonData['estimator'] == 'LinearSVC':
            from sklearn.svm import LinearSVC
            self.estimator = LinearSVC(random_state=0)
            self.is_regr = False
        elif jsonData['estimator'] == 'LinearSVR':
            from sklearn.svm import SVR
            self.estimator = SVR(kernel='linear')
            self.is_regr = True
        self.params = {}

        self.params['C'] = dict_utils.parse_related_properties('C_exp',
                                                               jsonData,
                                                               0,
                                                               is_exp=True)
        '''
        if 'C' in jsonData:
            self.params['C'] = [jsonData['C']]
        elif 'C_lower_exp' in jsonData and 'C_upper_exp' in jsonData:
            import numpy as np
            l = jsonData['C_lower_exp']
            u = jsonData['C_upper_exp']
            self.params['C'] = np.logspace(l, u, u-l+1)
        elif 'C_lower_exp' in jsonData:
            self.params['C'] = [jsonData['C_lower_exp']]
        elif 'C_upper_exp' in jsonData:
            self.params['C'] = [jsonData['C_upper_exp']]
        else:
            self.params['C'] = 1
        '''

        import sys
        sys.path.insert(1, 'output')
        import SVM_OM
        self.output_manager = SVM_OM.SVM_OM(self)
    def parse(self, jsonData):
        if jsonData['estimator'].endswith('Classifier'):
            from sklearn.ensemble import RandomForestClassifier
            self.estimator = RandomForestClassifier(criterion='gini')
            self.is_regr = False
        else:
            from sklearn.ensemble import RandomForestRegressor
            self.estimator = RandomForestRegressor(criterion='mse')
            self.is_regr = True
        self.params = {}

        import sys
        sys.path.insert(1, 'utils')
        import dict_utils
        self.params['n_estimators'] = dict_utils.parse_related_properties(
            'n_estimators', jsonData, 100)
        self.params['max_depth'] = dict_utils.parse_related_properties(
            'max_depth', jsonData, None)
        self.params['min_samples_split'] = dict_utils.parse_related_properties(
            'min_samples_split', jsonData, 2)
        self.params['min_samples_leaf'] = dict_utils.parse_related_properties(
            'min_samples_leaf', jsonData, 1)
        self.params[
            'min_weight_fraction_leaf'] = dict_utils.parse_related_properties(
                'min_weight_fraction_leaf', jsonData, 0.0)
        self.params['max_features'] = dict_utils.parse_related_properties(
            'max_features', jsonData, 'auto')
        self.params['max_leaf_nodes'] = dict_utils.parse_related_properties(
            'max_leaf_nodes', jsonData, None)
        self.params[
            'min_impurity_decrease'] = dict_utils.parse_related_properties(
                'min_impurity_decrease', jsonData, 0.0)
        self.params['n_jobs'] = dict_utils.parse_related_properties(
            'n_jobs', jsonData, None)
        self.params['verbose'] = dict_utils.parse_related_properties(
            'verbose', jsonData, 0)

        sys.path.insert(1, 'output')
        import RandomForest_OM
        self.output_manager = RandomForest_OM.RandomForest_OM(self)
示例#4
0
    def parse(self, jsonData):
        if jsonData['estimator'].endswith('Classifier'):
            from sklearn.neighbors import KNeighborsClassifier
            self.estimator = KNeighborsClassifier()
            self.is_regr = False
        else:
            from sklearn.neighbors import KNeighborsRegressor
            self.estimator = KNeighborsRegressor()
            self.is_regr = True
        self.params = {}

        import sys
        sys.path.insert(1, 'utils')
        import dict_utils
        self.params['n_neighbors'] = dict_utils.parse_related_properties(
            'n_neighbors', jsonData, 5)

        sys.path.insert(1, 'output')
        import Knn_OM  #as Knn_OM
        self.output_manager = Knn_OM.Knn_OM(self)