コード例 #1
0
 def _search_best(self, **Xy):
     # Fit/predict CV grid search
     self.cv.store = StoreMem()  # local store erased at each fit
     from epac.workflow.pipeline import Pipe
     self.cv.top_down(**Xy)
     #  Pump-up results
     cv_result_set = self.cv.reduce(store_results=False)
     key_val = [(result.key(), result[self.score]) \
             for result in cv_result_set]
     scores = np.asarray(zip(*key_val)[1])
     scores_opt = np.max(scores) if self.arg_max else  np.min(scores)
     idx_best = np.where(scores == scores_opt)[0][0]
     best_key = key_val[idx_best][0]
     # Find nodes that match the best
     nodes_dict = {n.get_signature(): n for n in self.cv.walk_true_nodes() \
         if n.get_signature() in key_split(best_key)}
     to_refit = Pipe(*[nodes_dict[k].estimator for k in key_split(best_key)])
     best_params = [dict(sig) for sig in key_split(best_key, eval=True)]
     return to_refit, best_params
コード例 #2
0
 def reduce(self, result):
     from epac.workflow.pipeline import Pipe
     #  Pump-up results
     cv_result_set = result
     key_val = [(result.key(), result[self.NodeBestSearchRefit.score])
                for result in cv_result_set]
     scores = np.asarray(zip(*key_val)[1])
     scores_opt = np.max(scores)\
         if self.NodeBestSearchRefit.arg_max else np.min(scores)
     idx_best = np.where(scores == scores_opt)[0][0]
     best_key = key_val[idx_best][0]
     # Find nodes that match the best
     nodes_dict = \
         {n.get_signature():
          n for n in self.NodeBestSearchRefit.children[0].walk_true_nodes()
          if n.get_signature() in key_split(best_key)}
     to_refit = Pipe(*[nodes_dict[k].wrapped_node
                     for k in key_split(best_key)])
     best_params = [dict(sig) for sig in key_split(best_key, eval=True)]
     return to_refit, best_params
コード例 #3
0
ファイル: splitters.py プロジェクト: neurospin/pylearn-epac
 def _search_best(self, **Xy):
     # Fit/predict CV grid search
     self.cv.store = StoreMem()  # local store erased at each fit
     from epac.workflow.pipeline import Pipe
     self.cv.top_down(**Xy)
     #  Pump-up results
     cv_result_set = self.cv.reduce(store_results=False)
     key_val = [(result.key(), result[self.score])
                for result in cv_result_set]
     scores = np.asarray(zip(*key_val)[1])
     scores_opt = np.max(scores) if self.arg_max else np.min(scores)
     idx_best = np.where(scores == scores_opt)[0][0]
     best_key = key_val[idx_best][0]
     # Find nodes that match the best
     nodes_dict = {n.get_signature(): n for n in self.cv.walk_true_nodes()
                   if n.get_signature() in key_split(best_key)}
     to_refit = Pipe(*[nodes_dict[k].wrapped_node
                       for k in key_split(best_key)])
     best_params = [dict(sig) for sig in key_split(best_key, eval=True)]
     return to_refit, best_params