Esempio n. 1
0
 def transform(self, **Xy):
     """
     Parameter
     ---------
     Xy: dictionary
         parameters for fit and transform
     """
     if conf.KW_SPLIT_TRAIN_TEST in Xy:
         Xy_train, Xy_test = train_test_split(Xy)
         res = self.estimator.fit(**_sub_dict(Xy_train, self.in_args_fit))
         # catch args_transform in ds, transform, store output in a dict
         Xy_out_tr = _as_dict(self.estimator.transform(
                     **_sub_dict(Xy_train, self.in_args_transform)),
                     keys=self.in_args_transform)
         Xy_out_te = _as_dict(self.estimator.transform(**_sub_dict(Xy_test,
                         self.in_args_transform)),
                         keys=self.in_args_transform)
         Xy_out = train_test_merge(Xy_out_tr, Xy_out_te)
     else:
         res = self.estimator.fit(**_sub_dict(Xy, self.in_args_fit))
         # catch args_transform in ds, transform, store output in a dict
         Xy_out = _as_dict(self.estimator.transform(**_sub_dict(Xy,
                                              self.in_args_transform)),
                        keys=self.in_args_transform)
     # update ds with transformed values
     Xy.update(Xy_out)
     return Xy
Esempio n. 2
0
 def transform(self, **Xy):
     """
     Parameter
     ---------
     Xy: dictionary
         parameters for fit and transform
     """
     if conf.KW_SPLIT_TRAIN_TEST in Xy:
         Xy_train, Xy_test = train_test_split(Xy)
         Xy_out = dict()
         # Train fit
         res = self.estimator.fit(**_sub_dict(Xy_train, self.in_args_fit))
         # Train predict
         Xy_out_tr = _as_dict(self.estimator.predict(**_sub_dict(Xy_train,
                                              self.in_args_predict)),
                        keys=self.out_args_predict)
         Xy_out_tr = _dict_suffix_keys(Xy_out_tr,
             suffix=conf.SEP + conf.TRAIN + conf.SEP + conf.PREDICTION)
         Xy_out.update(Xy_out_tr)
         # Test predict
         Xy_out_te = _as_dict(self.estimator.predict(**_sub_dict(Xy_test,
                                              self.in_args_predict)),
                        keys=self.out_args_predict)
         Xy_out_te = _dict_suffix_keys(Xy_out_te,
             suffix=conf.SEP + conf.TEST + conf.SEP + conf.PREDICTION)
         Xy_out.update(Xy_out_te)
         ## True test
         Xy_test_true = _sub_dict(Xy_test, self.out_args_predict)
         Xy_out_true = _dict_suffix_keys(Xy_test_true,
             suffix=conf.SEP + conf.TEST + conf.SEP + conf.TRUE)
         Xy_out.update(Xy_out_true)
     else:
         res = self.estimator.fit(**_sub_dict(Xy, self.in_args_fit))
         # catch args_transform in ds, transform, store output in a dict
         Xy_out = _as_dict(self.estimator.predict(**_sub_dict(Xy,
                                              self.in_args_predict)),
                        keys=self.out_args_predict)
         Xy_out = _dict_suffix_keys(Xy_out,
             suffix=conf.SEP + conf.PREDICTION)
         ## True test
         Xy_true = _sub_dict(Xy, self.out_args_predict)
         Xy_out_true = _dict_suffix_keys(Xy_true,
             suffix=conf.SEP + conf.TRUE)
         Xy_out.update(Xy_out_true)
     return Xy_out
Esempio n. 3
0
 def _wrapped_node_predict(self, **Xy):
     Xy_out = _as_dict(self.wrapped_node.predict(
         **_sub_dict(Xy, self.in_args_predict)),
         keys=self.out_args_predict)
     return Xy_out
Esempio n. 4
0
 def _wrapped_node_transform(self, **Xy):
     Xy_out = _as_dict(self.wrapped_node.transform(
         **_sub_dict(Xy, self.in_args_transform)),
         keys=self.in_args_transform)
     return Xy_out
Esempio n. 5
0
 def _wrapped_node_predict(self, **Xy):
     Xy_out = _as_dict(self.wrapped_node.predict(
         **_sub_dict(Xy, self.in_args_predict)),
         keys=self.out_args_predict)
     return Xy_out
Esempio n. 6
0
 def _wrapped_node_transform(self, **Xy):
     Xy_out = _as_dict(self.wrapped_node.transform(
         **_sub_dict(Xy, self.in_args_transform)),
         keys=self.in_args_transform)
     return Xy_out