<p dir="auto">Minimum example is at bottom. The problem is that self.coef_ in SGDClassifier is set to F-order and is not unset from it when the chain of calls from the second fit() eventually hits fit_binary(). My solution, in forthcoming PR, is to make sure that coef_ is set back to C-order before training.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: from sklearn.linear_model import SGDClassifier

In [2]: X = np.random.rand(100, 10)

In [3]: y = np.random.randint(3, size=100)

In [4]: clf = SGDClassifier(warm_start=False)

In [5]: clf.fit(X, y)
Out[5]:
SGDClassifier(alpha=0.0001, class_weight=None, epsilon=0.1, eta0=0.0,
       fit_intercept=True, l1_ratio=0.15, learning_rate='optimal',
       loss='hinge', n_iter=5, n_jobs=1, penalty='l2', power_t=0.5,
       random_state=None, rho=None, shuffle=False, verbose=0,
       warm_start=False)

In [6]: clf.fit(X, y)
Out[6]:
SGDClassifier(alpha=0.0001, class_weight=None, epsilon=0.1, eta0=0.0,
       fit_intercept=True, l1_ratio=0.15, learning_rate='optimal',
       loss='hinge', n_iter=5, n_jobs=1, penalty='l2', power_t=0.5,
       random_state=None, rho=None, shuffle=False, verbose=0,
       warm_start=False)

In [7]: clf = SGDClassifier(warm_start=True)

In [8]: clf.fit(X, y)
Out[8]:
SGDClassifier(alpha=0.0001, class_weight=None, epsilon=0.1, eta0=0.0,
       fit_intercept=True, l1_ratio=0.15, learning_rate='optimal',
       loss='hinge', n_iter=5, n_jobs=1, penalty='l2', power_t=0.5,
       random_state=None, rho=None, shuffle=False, verbose=0,
       warm_start=True)

In [9]: clf.fit(X, y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-9-1a154f38b9fb&gt; in &lt;module&gt;()
----&gt; 1 clf.fit(X, y)

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in fit(self, X, y, coef_init, intercept_init, class_weight, sample_weight)
    522                          coef_init=coef_init, intercept_init=intercept_init,
    523                          class_weight=class_weight,
--&gt; 524                          sample_weight=sample_weight)
    525
    526

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in _fit(self, X, y, alpha, C, loss, learning_rate, coef_init, intercept_init, class_weight, sample_weight)
    421
    422         self._partial_fit(X, y, alpha, C, loss, learning_rate, self.n_iter,
--&gt; 423                           classes, sample_weight, coef_init, intercept_init)
    424
    425         # fitting is over, we can now transform coef_ to fortran order

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in _partial_fit(self, X, y, alpha, C, loss, learning_rate, n_iter, classes, sample_weight, coef_init, intercept_init)
    374             self._fit_multiclass(X, y, alpha=alpha, C=C,
    375                                  learning_rate=learning_rate,
--&gt; 376                                  sample_weight=sample_weight, n_iter=n_iter)
    377         elif n_classes == 2:
    378             self._fit_binary(X, y, alpha=alpha, C=C,

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in _fit_multiclass(self, X, y, alpha, C, learning_rate, sample_weight, n_iter)
    454                                 n_iter, self._expanded_class_weight[i], 1.,
    455                                 sample_weight)
--&gt; 456             for i in range(len(self.classes_)))
    457
    458         for i, (coef, intercept) in enumerate(result):

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self, iterable)
    512         try:
    513             for function, args, kwargs in iterable:
--&gt; 514                 self.dispatch(function, args, kwargs)
    515
    516             self.retrieve()

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in dispatch(self, func, args, kwargs)
    309         &quot;&quot;&quot;
    310         if self._pool is None:
--&gt; 311             job = ImmediateApply(func, args, kwargs)
    312             index = len(self._jobs)
    313             if not _verbosity_filter(index, self.verbose):

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __init__(self, func, args, kwargs)
    133         # Don't delay the application, to avoid keeping the input
    134         # arguments in memory
--&gt; 135         self.results = func(*args, **kwargs)
    136
    137     def get(self):

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in fit_binary(est, i, X, y, alpha, C, learning_rate, n_iter, pos_weight, neg_weight, sample_weight)
    281                      pos_weight, neg_weight,
    282                      learning_rate_type, est.eta0,
--&gt; 283                      est.power_t, est.t_, intercept_decay)
    284
    285

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/sgd_fast.so in sklearn.linear_model.sgd_fast.plain_sgd (sklearn/linear_model/sgd_fast.c:7362)()

ValueError: ndarray is not C-contiguous"><pre class="notranslate"><code class="notranslate">In [1]: from sklearn.linear_model import SGDClassifier

In [2]: X = np.random.rand(100, 10)

In [3]: y = np.random.randint(3, size=100)

In [4]: clf = SGDClassifier(warm_start=False)

In [5]: clf.fit(X, y)
Out[5]:
SGDClassifier(alpha=0.0001, class_weight=None, epsilon=0.1, eta0=0.0,
       fit_intercept=True, l1_ratio=0.15, learning_rate='optimal',
       loss='hinge', n_iter=5, n_jobs=1, penalty='l2', power_t=0.5,
       random_state=None, rho=None, shuffle=False, verbose=0,
       warm_start=False)

In [6]: clf.fit(X, y)
Out[6]:
SGDClassifier(alpha=0.0001, class_weight=None, epsilon=0.1, eta0=0.0,
       fit_intercept=True, l1_ratio=0.15, learning_rate='optimal',
       loss='hinge', n_iter=5, n_jobs=1, penalty='l2', power_t=0.5,
       random_state=None, rho=None, shuffle=False, verbose=0,
       warm_start=False)

In [7]: clf = SGDClassifier(warm_start=True)

In [8]: clf.fit(X, y)
Out[8]:
SGDClassifier(alpha=0.0001, class_weight=None, epsilon=0.1, eta0=0.0,
       fit_intercept=True, l1_ratio=0.15, learning_rate='optimal',
       loss='hinge', n_iter=5, n_jobs=1, penalty='l2', power_t=0.5,
       random_state=None, rho=None, shuffle=False, verbose=0,
       warm_start=True)

In [9]: clf.fit(X, y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-9-1a154f38b9fb&gt; in &lt;module&gt;()
----&gt; 1 clf.fit(X, y)

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in fit(self, X, y, coef_init, intercept_init, class_weight, sample_weight)
    522                          coef_init=coef_init, intercept_init=intercept_init,
    523                          class_weight=class_weight,
--&gt; 524                          sample_weight=sample_weight)
    525
    526

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in _fit(self, X, y, alpha, C, loss, learning_rate, coef_init, intercept_init, class_weight, sample_weight)
    421
    422         self._partial_fit(X, y, alpha, C, loss, learning_rate, self.n_iter,
--&gt; 423                           classes, sample_weight, coef_init, intercept_init)
    424
    425         # fitting is over, we can now transform coef_ to fortran order

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in _partial_fit(self, X, y, alpha, C, loss, learning_rate, n_iter, classes, sample_weight, coef_init, intercept_init)
    374             self._fit_multiclass(X, y, alpha=alpha, C=C,
    375                                  learning_rate=learning_rate,
--&gt; 376                                  sample_weight=sample_weight, n_iter=n_iter)
    377         elif n_classes == 2:
    378             self._fit_binary(X, y, alpha=alpha, C=C,

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in _fit_multiclass(self, X, y, alpha, C, learning_rate, sample_weight, n_iter)
    454                                 n_iter, self._expanded_class_weight[i], 1.,
    455                                 sample_weight)
--&gt; 456             for i in range(len(self.classes_)))
    457
    458         for i, (coef, intercept) in enumerate(result):

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self, iterable)
    512         try:
    513             for function, args, kwargs in iterable:
--&gt; 514                 self.dispatch(function, args, kwargs)
    515
    516             self.retrieve()

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in dispatch(self, func, args, kwargs)
    309         """
    310         if self._pool is None:
--&gt; 311             job = ImmediateApply(func, args, kwargs)
    312             index = len(self._jobs)
    313             if not _verbosity_filter(index, self.verbose):

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __init__(self, func, args, kwargs)
    133         # Don't delay the application, to avoid keeping the input
    134         # arguments in memory
--&gt; 135         self.results = func(*args, **kwargs)
    136
    137     def get(self):

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/stochastic_gradient.pyc in fit_binary(est, i, X, y, alpha, C, learning_rate, n_iter, pos_weight, neg_weight, sample_weight)
    281                      pos_weight, neg_weight,
    282                      learning_rate_type, est.eta0,
--&gt; 283                      est.power_t, est.t_, intercept_decay)
    284
    285

/Users/sergeyk/.virtual_envs/system/lib/python2.7/site-packages/sklearn/linear_model/sgd_fast.so in sklearn.linear_model.sgd_fast.plain_sgd (sklearn/linear_model/sgd_fast.c:7362)()

ValueError: ndarray is not C-contiguous
</code></pre></div>
<p dir="auto">Can we get a copy for code block like the following?</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/7d5aa0b71b8736ce87c1d596e2494734fbe53a127855d994156b4ee44c1bf8b3/68747470733a2f2f6661726d352e737461746963666c69636b722e636f6d2f343930342f33303735303433383032375f633934383734333139365f622e6a7067"><img src="https://camo.githubusercontent.com/7d5aa0b71b8736ce87c1d596e2494734fbe53a127855d994156b4ee44c1bf8b3/68747470733a2f2f6661726d352e737461746963666c69636b722e636f6d2f343930342f33303735303433383032375f633934383734333139365f622e6a7067" alt="" data-canonical-src="https://farm5.staticflickr.com/4904/30750438027_c948743196_b.jpg" style="max-width: 100%;"></a></p>
<p dir="auto">Tensorflow has it and I just submitted PR for <code class="notranslate">scikit-image</code> and I would love to submit PR for <code class="notranslate">scikit-learn</code> using this <a href="https://github.com/choldgraf/sphinx-copybutton">sphinx-copybutton</a> extension.</p>