Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cadc54

Browse files
committed
set coef_ to fortran layout after fit - this will enhance the test time performance for predicting singe data points.
1 parent 954b390 commit 6cadc54

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

sklearn/linear_model/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ def _validate_sample_weight(self, sample_weight, n_samples):
249249
return sample_weight
250250

251251
def _set_coef(self, coef_):
252-
"""Make sure that coef_ is 2d. """
253-
self.coef_ = array2d(coef_)
252+
"""Make sure that coef_ is fortran-style and 2d. """
253+
self.coef_ = np.asfortranarray(array2d(coef_))
254254

255255
def _allocate_parameter_mem(self, n_classes, n_features, coef_init=None,
256256
intercept_init=None):

sklearn/linear_model/stochastic_gradient.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ def _fit_multiclass(self, X, y, sample_weight):
183183
self.coef_[i] = coef
184184
self.intercept_[i] = intercept
185185

186+
self._set_coef(self.coef_)
187+
186188

187189
def _train_ova_classifier(i, c, X, y, coef_, intercept_, loss_function,
188190
penalty_type, alpha, rho, n_iter, fit_intercept,

0 commit comments

Comments
 (0)