예제 #1
0
 def fit(self, graphs, targets, randomize=True):
     """fit."""
     if self.balance:
         if randomize:
             bal_graphs, bal_targets = balance(graphs,
                                               targets,
                                               None,
                                               ratio=self.ratio)
         else:
             samp_graphs, samp_targets = subsample(
                 graphs, targets, subsample_size=self.subsample_size)
             x = self.transform(samp_graphs)
             self.model.fit(x, samp_targets)
             bal_graphs, bal_targets = balance(graphs,
                                               targets,
                                               self,
                                               ratio=self.ratio)
         size = len(bal_targets)
         logger.debug('Dataset size=%d' % (size))
         x = self.transform(bal_graphs)
         self.model = self.model.fit(x, bal_targets)
     else:
         x = self.transform(graphs)
         self.model = self.model.fit(x, targets)
     return self
예제 #2
0
    def model_selection(self, graphs, targets,
                        n_iter=30, subsample_size=None):
        """model_selection_randomized."""
        param_distr = {"r": list(range(1, 5)), "d": list(range(0, 10))}
        if subsample_size:
            graphs, targets = subsample(
                graphs, targets, subsample_size=subsample_size)

        pool = mp.Pool()
        scores = pool.map(_eval, [(graphs, targets, param_distr)] * n_iter)
        pool.close()
        pool.join()

        best_params = max(scores)[1]
        logger.debug("Best parameters:\n%s" % (best_params))
        self = EdenEstimator(**best_params)
        return self
예제 #3
0
    def model_selection(self, graphs, targets,
                        n_iter=30, subsample_size=None):
        """model_selection_randomized."""
        param_distr = {"r": list(range(1, 5)), "d": list(range(0, 10))}
        if subsample_size:
            graphs, targets = subsample(
                graphs, targets, subsample_size=subsample_size)

        pool = mp.Pool()
        scores = pool.map(_eval, [(graphs, targets, param_distr)] * n_iter)
        pool.close()
        pool.join()

        best_params = max(scores)[1]
        logger.debug("Best parameters:\n%s" % (best_params))
        self = EdenEstimator(**best_params)
        return self
예제 #4
0
 def fit(self, graphs, targets, randomize=True):
     """fit."""
     if self.balance:
         if randomize:
             bal_graphs, bal_targets = balance(
                 graphs, targets, None, ratio=self.ratio)
         else:
             samp_graphs, samp_targets = subsample(
                 graphs, targets, subsample_size=self.subsample_size)
             x = self.transform(samp_graphs)
             self.model.fit(x, samp_targets)
             bal_graphs, bal_targets = balance(
                 graphs, targets, self, ratio=self.ratio)
         size = len(bal_targets)
         logger.debug('Dataset size=%d' % (size))
         x = self.transform(bal_graphs)
         self.model = self.model.fit(x, bal_targets)
     else:
         x = self.transform(graphs)
         self.model = self.model.fit(x, targets)
     return self