Пример #1
0
 def __init__(self,
              estimator,
              param_grid,
              scoring=None,
              cv=4,
              refit=True,
              verbose=False,
              population_size=50,
              mutation_prob=0.10,
              tournament_size=3,
              generations_number=10,
              n_jobs=1,
              iid=True,
              pre_dispatch='2*n_jobs',
              error_score='raise',
              fit_params=None):
     super(EvolutionaryAlgorithmSearchCV,
           self).__init__(estimator, scoring, fit_params, n_jobs, iid,
                          refit, cv, pre_dispatch, error_score)
     _check_param_grid(param_grid)
     self.param_grid = param_grid
     self.possible_params = list(ParameterGrid(self.param_grid))
     self.individual_size = int(ceil(log(len(self.possible_params), 2)))
     self.population_size = population_size
     self.generations_number = generations_number
     self.best_estimator_ = None
     self.best_score_ = None
     self.best_params_ = None
     self._individual_evals = {}
     self.mutation_prob = mutation_prob
     self.tournament_size = tournament_size
Пример #2
0
 def __init__(self, estimator, param_grid, scoring=None, loss_func=None,
              score_func=None, fit_params=None, n_jobs=1, iid=True,
              refit=True, cv=None, verbose=0, pre_dispatch='2*n_jobs'):
     super(ExtendedGridSearchCV, self).__init__(
         estimator, scoring, loss_func, score_func, fit_params, n_jobs, iid,
         refit, cv, verbose, pre_dispatch)
     self.param_grid = param_grid
     _check_param_grid(param_grid)
Пример #3
0
    def __init__(self, estimator, param_grid, scoring=None, fit_params=None,
            iid=True, refit=True, cv=None, verbose=0):

        super(GridSearchCV, self).__init__(
            estimator, scoring, fit_params, iid,
            refit, cv, verbose)
        self.param_grid = param_grid
        _check_param_grid(param_grid)
Пример #4
0
 def __init__(self, estimator, param_grid=None, refit=True, cv=2, verbose=0):
     self.estimator = estimator
     _check_param_grid(param_grid)
     self.param_grid = param_grid
     self.refit = refit
     self.cv = cv
     self.verbose = verbose
     self.dataset = None
Пример #5
0
 def __init__(self, sc, estimator, param_grid, scoring=None, fit_params=None,
              n_jobs=1, iid=True, refit=True, cv=None, verbose=0,
              pre_dispatch='2*n_jobs', error_score='raise'):
     super(GridSearchCV, self).__init__(
         estimator, scoring, fit_params, n_jobs, iid,
         refit, cv, verbose, pre_dispatch, error_score)
     self.sc = sc
     self.param_grid = param_grid
     _check_param_grid(param_grid)
Пример #6
0
 def __init__(self, estimator, param_grid, dataset_filenames=None,
              sync=True, scoring=None,
              loss_func=None, score_func=None, fit_params=None, n_jobs=1, iid=True,
              refit=True, cv=None, verbose=0, pre_dispatch='2*n_jobs'):
     super(IPyGridSearchCV, self).__init__(
         estimator, scoring, loss_func, score_func, fit_params, n_jobs, iid,
         refit, cv, verbose, pre_dispatch)
     self.param_grid = param_grid
     self.dataset_filenames = dataset_filenames
     self.sync = sync
     _check_param_grid(param_grid)
Пример #7
0
 def __init__(self, estimator, param_grid, scoring=None, loss_func=None,
              score_func=None, fit_params=None, iid=True,
              refit=True, cv=None, verbose=0, client=None,
              return_train_scores=False, tmp_dir='.'):
     super(DistributedGridSearchCV, self).__init__(
         estimator, scoring=scoring, loss_func=loss_func,
         score_func=score_func, fit_params=fit_params, iid=iid,
         refit=refit, cv=cv, verbose=verbose, client=client,
         return_train_scores=return_train_scores, tmp_dir=tmp_dir)
     self.param_grid = param_grid
     _check_param_grid(param_grid)
    def __init__(self, estimator, param_grid, profile='net', grid_parallel=True, scoring=None, loss_func=None,
            score_func=None, fit_params=None, n_jobs=-1, iid=True,
            refit=True, cv=None, verbose=0, pre_dispatch='2*n_jobs',
            error_score='raise'):

        super(GridSearchCV, self).__init__(
            estimator=estimator, scoring=scoring, fit_params=fit_params, n_jobs=n_jobs, iid=iid,
            refit=refit, cv=cv, verbose=verbose, pre_dispatch=pre_dispatch)
        self.param_grid = param_grid
        self.profile = profile
        self.grid_parallel = grid_parallel
        grid_search._check_param_grid(param_grid)
Пример #9
0
    def __init__(self,
                 estimator,
                 param_grid,
                 scoring=None,
                 fit_params=None,
                 iid=True,
                 refit=True,
                 cv=None,
                 verbose=0):

        super(GridSearchCV, self).__init__(estimator, scoring, fit_params, iid,
                                           refit, cv, verbose)
        self.param_grid = param_grid
        _check_param_grid(param_grid)
    def __init__(self, estimator, param_grid, scoring=None, cv=None, inner_cv=None,
                 profile=None):
        self.scoring = scoring
        self.estimator = estimator

        if isinstance(param_grid, Mapping):
            self.param_grid = [param_grid]
        else:
            self.param_grid = param_grid

        self.scoring = scoring
        self.cv = cv
        self.inner_cv = inner_cv
        self.profile = profile

        _check_param_grid(param_grid)
Пример #11
0
    def fit(self, X, y):
        X, y = check_X_y(X,
                         y,
                         force_all_finite=False,
                         multi_output=self.multi_output)
        _check_param_grid(self.param_grid)

        cv = _check_cv(self.cv, X, y, classifier=is_classifier(self.estimator))

        self.scorer_ = check_scoring(self.estimator, scoring=self.scoring)

        if comm_rank == 0:
            self._fit_master(X, y, cv)
        else:
            self._fit_slave()

        return self
Пример #12
0
    def fit(self, X, y):
        if master:
            LOG.info("comm_size:" + str(comm_size))
        X, y = check_X_y(X, y, force_all_finite=False, multi_output=self.multi_output, accept_sparse='csr')
        _check_param_grid(self.param_grid)

        cv = check_cv(self.cv, X, y, classifier=is_classifier(self.estimator))
        if master:
            LOG.info("cv length:" + str(len(cv)))

        self.scorer_ = check_scoring(self.estimator, scoring=self.scoring)

        if master:
            self._fit_master(X, y, cv)
        else:
            self._fit_slave()
        return self
Пример #13
0
 def __init__(self, estimator, data_home, dataset, param_grid=None, refit=True, verbose=0, holdout=None,
              queue=None, scorer=None, fit_params=None, error_score='raise'):
     self.error_score = error_score
     if not scorer:
         scorer = estimator.score
     self.scorer = scorer
     self.dataset = dataset
     self.data_home = data_home
     self.estimator = estimator
     _check_param_grid(param_grid)
     self.param_grid = param_grid
     self.refit = refit
     self.verbose = verbose
     self.holdout = holdout
     if queue is None:
         queue = HTCondorQueue()
     self.queue = queue
     self.fit_params = fit_params
Пример #14
0
    def __init__(self,
                 estimator,
                 param_grid,
                 scoring=None,
                 fit_params=None,
                 iid=True,
                 refit=True,
                 cv=None,
                 get=None):

        super(GridSearchCV, self).__init__(estimator=estimator,
                                           scoring=scoring,
                                           fit_params=fit_params,
                                           iid=iid,
                                           refit=refit,
                                           cv=cv,
                                           get=get)
        _check_param_grid(param_grid)
        self.param_grid = param_grid
Пример #15
0
 def __init__(self, estimator, param_grid, scoring=None, cv=4,
              refit=True, verbose=False, population_size=50, mutation_prob=0.10,
              tournament_size=3, generations_number=10,
              n_jobs=1, iid=True, pre_dispatch='2*n_jobs', error_score='raise',
              fit_params=None):
     super(EvolutionaryAlgorithmSearchCV, self).__init__(
         estimator, scoring, fit_params, n_jobs, iid,
         refit, cv, pre_dispatch, error_score)
     _check_param_grid(param_grid)
     self.param_grid = param_grid
     self.possible_params = list(ParameterGrid(self.param_grid))
     self.individual_size = int(ceil(log(len(self.possible_params), 2)))
     self.population_size = population_size
     self.generations_number = generations_number
     self.best_estimator_ = None
     self.best_score_ = None
     self.best_params_ = None
     self._individual_evals = {}
     self.mutation_prob = mutation_prob
     self.tournament_size = tournament_size
Пример #16
0
 def __init__(self,
              estimator,
              param_grid,
              scoring=None,
              fit_params=None,
              n_duplicates=1,
              n_splits=100,
              iid=True,
              refit=True,
              cv=None,
              verbose=0):
     self.param_grid = param_grid
     _check_param_grid(param_grid)
     self.n_duplicates = n_duplicates
     self.n_splits = n_splits
     super(FlyGridCV, self).__init__(estimator=estimator,
                                     scoring=scoring,
                                     fit_params=fit_params,
                                     iid=iid,
                                     refit=refit,
                                     cv=cv,
                                     verbose=verbose)
Пример #17
0
 def __init__(self, param_grid, n_evaluations, random_state=None):
     """
     The aim of this class is to generate new points, where the function (estimator) will be computed.
     :type param_grid: OrderedDict, the grid with parameters to optimize on
     :type n_evaluations: int, the number of evaluations to do
     :type random_state: int | RandomState | None
     """
     assert isinstance(param_grid, dict), 'the passed param_grid should be of OrderedDict class'
     self.param_grid = OrderedDict(param_grid)
     _check_param_grid(self.param_grid)
     self.dimensions = list([len(param_values) for param, param_values in self.param_grid.items()])
     size = numpy.prod(self.dimensions)
     assert size > 1, 'The space of parameters contains only %i points' % size
     if n_evaluations > size / 2:
         warn('The number of evaluations was decreased to %i' % (size // 2), UserWarning)
         n_evaluations = size // 2
     self.n_evaluations = n_evaluations
     # results on different parameters
     self.grid_scores_ = OrderedDict()
     # all the tasks that are being computed or already computed
     self.queued_tasks_ = set()
     self.random_state = check_random_state(random_state)
     self.evaluations_done = 0