예제 #1
0
 def __init__(self, pipeline_id, do_prep='True', prep_dict=None):
     self.pid = pipeline_id
     self.do_prep = do_prep == 'True'
     self.cat_idx = None
     self.float_idx = None
     self.prep_dict = prep_dict
     BaseHelper.__init__(self)
예제 #2
0
파일: svr.py 프로젝트: quanted/vb_django
 def __init__(self,
              pipeline_id=None,
              do_prep='True',
              prep_dict={'impute_strategy': 'impute_knn5'},
              gridpoints=4,
              inner_cv=None,
              groupcount=None,
              impute_strategy=None,
              float_idx=None,
              cat_idx=None,
              bestT=False,
              cv_splits=5,
              cv_repeats=2):
     self.pipeline_id = pipeline_id
     self.do_prep = do_prep == 'True' if type(do_prep) != bool else do_prep
     self.gridpoints = gridpoints
     self.inner_cv = inner_cv
     self.groupcount = groupcount
     self.bestT = bestT
     self.cat_idx = cat_idx
     self.float_idx = float_idx
     self.prep_dict = prep_dict
     self.cv_splits = cv_splits
     self.cv_repeats = cv_repeats
     self.impute_strategy = impute_strategy
     if impute_strategy:
         self.prep_dict["impute_strategy"] = self.impute_strategy
     BaseHelper.__init__(self)
예제 #3
0
 def __init__(self,
              pipeline_id=None,
              do_prep='True',
              functional_form_search="False",
              prep_dict={'impute_strategy': 'impute_knn5'},
              gridpoints=4,
              inner_cv=None,
              groupcount=None,
              bestT=False,
              cat_idx=None,
              float_idx=None,
              flex_kwargs={},
              cv_splits=5,
              cv_repeats=2):
     self.pipeline_id = pipeline_id
     self.do_prep = do_prep == 'True' if type(do_prep) != bool else do_prep
     self.functional_form_search = functional_form_search if type(
         functional_form_search
     ) == bool else functional_form_search == "True"
     self.gridpoints = gridpoints
     self.inner_cv = inner_cv
     self.groupcount = groupcount
     self.bestT = bestT
     self.cat_idx = cat_idx
     self.float_idx = float_idx
     self.prep_dict = prep_dict
     self.flex_kwargs = flex_kwargs
     self.cv_splits = cv_splits
     self.cv_repeats = cv_repeats
     self.flex_kwargs["robust"] = True
     BaseHelper.__init__(self)
예제 #4
0
    def __init__(self,
                 pipeline_id=None,
                 do_prep=True,
                 prep_dict={'impute_strategy': 'impute_knn5'},
                 inner_cv=None,
                 bestT=False,
                 cat_idx=None,
                 float_idx=None,
                 est_kwargs=None,
                 cv_splits=5,
                 cv_repeats=2):

        self.pipeline_id = pipeline_id
        self.do_prep = do_prep == 'True' if type(do_prep) != bool else do_prep
        self.bestT = bestT
        self.cat_idx = cat_idx
        self.float_idx = float_idx
        self.inner_cv = inner_cv
        self.prep_dict = prep_dict
        self.est_kwargs = est_kwargs
        self.cv_splits = cv_splits
        self.cv_repeats = cv_repeats
        # self.impute_strategy = impute_strategy
        # if impute_strategy:
        #     self.prep_dict["impute_strategy"] = self.impute_strategy
        BaseHelper.__init__(self)
예제 #5
0
 def __init__(self, pipeline_id=None, do_prep='True', prep_dict=None):
     self.pipeline_id = pipeline_id
     self.do_prep = do_prep == 'True' if type(do_prep) != bool else do_prep
     self.cat_idx = None
     self.float_idx = None
     self.prep_dict = prep_dict
     BaseHelper.__init__(self)
예제 #6
0
 def __init__(self,
              pipeline_id,
              do_prep='True',
              prep_dict=None,
              impute_strategy=None,
              gridpoints=4,
              inner_cv=None,
              groupcount=None,
              float_idx=None,
              cat_idx=None,
              bestT=False):
     self.pid = pipeline_id
     self.do_prep = do_prep == 'True'
     self.gridpoints = gridpoints
     self.groupcount = groupcount
     self.float_idx = float_idx
     self.cat_idx = cat_idx
     self.bestT = bestT
     self.inner_cv = inner_cv
     self.prep_dict = {
         'impute_strategy':
         self.hyper_parameters["impute_strategy"]["value"]
     } if prep_dict is None else prep_dict
     if impute_strategy:
         self.prep_dict["impute_strategy"] = impute_strategy
     self.flags = None
     BaseHelper.__init__(self)
예제 #7
0
 def __init__(self,
              pipeline_id,
              do_prep='True',
              prep_dict={'impute_strategy': 'impute_knn5'},
              gridpoints=4,
              inner_cv=None,
              groupcount=None,
              impute_strategy=None,
              bestT=False,
              cat_idx=None,
              float_idx=None):
     self.pid = pipeline_id
     self.do_prep = do_prep == 'True'
     self.gridpoints = gridpoints
     self.inner_cv = inner_cv
     self.groupcount = groupcount
     self.bestT = bestT
     self.cat_idx = cat_idx
     self.float_idx = float_idx
     self.prep_dict = prep_dict
     if impute_strategy:
         self.prep_dict["impute_strategy"] = impute_strategy
     BaseHelper.__init__(self)
예제 #8
0
 def __init__(self,
              pipeline_id,
              do_prep='True',
              functional_form_search=False,
              prep_dict={'impute_strategy': 'impute_knn5'},
              gridpoints=4,
              inner_cv=None,
              groupcount=None,
              bestT=False,
              cat_idx=None,
              float_idx=None,
              flex_kwargs={}):
     self.pid = pipeline_id
     self.do_prep = do_prep == 'True'
     self.functional_form_search = functional_form_search
     self.gridpoints = gridpoints
     self.inner_cv = inner_cv
     self.groupcount = groupcount
     self.bestT = bestT
     self.cat_idx = cat_idx
     self.float_idx = float_idx
     self.prep_dict = prep_dict
     self.flex_kwargs = flex_kwargs
     BaseHelper.__init__(self)
예제 #9
0
 def predict(self, features=None):
     train_idx_list, test_idx_list = zip(*list(self.get_cv().split(self.x, self.y)))
     n, k = self.x.shape
     data_idx = np.arange(n)
     yhat_dict = {}
     scores = {}
     for idx, (estimator_name, result) in enumerate(self.cv_results.items()):
         scores[estimator_name] = []
         yhat_dict[estimator_name] = []
         for r in range(self.cv_reps):
             yhat = np.empty([n, ])
             rows = []
             for s in range(self.cv_folds):  # s for split
                 m = r*self.cv_folds+s
                 cv_est = result['estimator'][m]
                 test_rows = test_idx_list[m]
                 yhat[test_rows] = cv_est.predict(self.x.iloc[test_rows])
                 rows.append(BaseHelper.score(self.y[test_rows], yhat[test_rows]))
             scores[estimator_name].append(rows)
             yhat_dict[estimator_name].append(yhat)
     self.cv_yhat_dict = yhat_dict
     return yhat_dict, scores