Skip to content
Browse files

set coef_ to fortran layout after fit - this will enhance the test ti…

…me performance for predicting singe data points.
  • Loading branch information...
1 parent 954b390 commit 6cadc54d1d0680b843b376fd9ef2d8bff90a2c8f @pprett committed Jan 9, 2012
Showing with 4 additions and 2 deletions.
  1. +2 −2 sklearn/linear_model/base.py
  2. +2 −0 sklearn/linear_model/stochastic_gradient.py
View
4 sklearn/linear_model/base.py
@@ -249,8 +249,8 @@ def _validate_sample_weight(self, sample_weight, n_samples):
return sample_weight
def _set_coef(self, coef_):
- """Make sure that coef_ is 2d. """
- self.coef_ = array2d(coef_)
+ """Make sure that coef_ is fortran-style and 2d. """
+ self.coef_ = np.asfortranarray(array2d(coef_))
def _allocate_parameter_mem(self, n_classes, n_features, coef_init=None,
intercept_init=None):
View
2 sklearn/linear_model/stochastic_gradient.py
@@ -183,6 +183,8 @@ def _fit_multiclass(self, X, y, sample_weight):
self.coef_[i] = coef
self.intercept_[i] = intercept
+ self._set_coef(self.coef_)
+
def _train_ova_classifier(i, c, X, y, coef_, intercept_, loss_function,
penalty_type, alpha, rho, n_iter, fit_intercept,

0 comments on commit 6cadc54

Please sign in to comment.
Something went wrong with that request. Please try again.