How to use the scikit-learn.sklearn.externals.joblib.Parallel function in scikit-learn

To help you get started, we’ve selected a few scikit-learn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angadgill / Parallel-SGD / scikit-learn / sklearn / linear_model / stochastic_gradient.py View on Github external
self.average_intercept_ = np.atleast_1d(self.average_intercept_)
            self.standard_intercept_ = np.atleast_1d(self.standard_intercept_)
            self.t_ += n_iter * X.shape[0]

            if self.average <= self.t_ - 1.0:
                self.coef_ = self.average_coef_
                self.intercept_ = self.average_intercept_
            else:
                self.coef_ = self.standard_coef_
                self.intercept_ = self.standard_intercept_

        else:
            if self.n_jobs > 1:
                sgd_result = \
                    Parallel(n_jobs=self.n_jobs, backend='threading')(
                    delayed(plain_sgd)(self.coef_,
                              self.intercept_[0],
                              loss_function,
                              penalty_type,
                              alpha, C,
                              self.l1_ratio,
                              dataset,
                              n_iter/self.n_jobs,
                              int(self.fit_intercept),
                              int(self.verbose),
                              int(self.shuffle),
                              seed,
                              1.0, 1.0,
                              learning_rate_type,
                              self.eta0, self.power_t, self.t_,
                              intercept_decay) for _ in range(self.n_jobs))
github angadgill / Parallel-SGD / scikit-learn / sklearn / linear_model / stochastic_gradient.py View on Github external
def _fit_multiclass(self, X, y, alpha, C, learning_rate,
                        sample_weight, n_iter):
        """Fit a multi-class classifier by combining binary classifiers

        Each binary classifier predicts one class versus all others. This
        strategy is called OVA: One Versus All.
        """
        # Use joblib to fit OvA in parallel.
        result = Parallel(n_jobs=self.n_jobs, backend="threading",
                          verbose=self.verbose)(
            delayed(fit_binary)(self, i, X, y, alpha, C, learning_rate,
                                n_iter, self._expanded_class_weight[i], 1.,
                                sample_weight)
            for i in range(len(self.classes_)))

        for i, (_, intercept) in enumerate(result):
            self.intercept_[i] = intercept

        self.t_ += n_iter * X.shape[0]

        if self.average > 0:
            if self.average <= self.t_ - 1.0:
                self.coef_ = self.average_coef_
                self.intercept_ = self.average_intercept_
            else: