<p dir="auto">I'm trying to fit a logistic regression on a sparse matrix, but I'm failing due to some ValueError:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="model = LogisticRegression(
    C=1,
    solver='sag',
    random_state=0,
    tol=0.0001,
    max_iter=100,
    verbose=1,
    warm_start=True,
    n_jobs=64,
    penalty='l2',
    dual=False,
    multi_class='ovr',
)
model.fit(train_data.inputs, train_data.targets)"><pre class="notranslate"><span class="pl-s1">model</span> <span class="pl-c1">=</span> <span class="pl-v">LogisticRegression</span>(
    <span class="pl-v">C</span><span class="pl-c1">=</span><span class="pl-c1">1</span>,
    <span class="pl-s1">solver</span><span class="pl-c1">=</span><span class="pl-s">'sag'</span>,
    <span class="pl-s1">random_state</span><span class="pl-c1">=</span><span class="pl-c1">0</span>,
    <span class="pl-s1">tol</span><span class="pl-c1">=</span><span class="pl-c1">0.0001</span>,
    <span class="pl-s1">max_iter</span><span class="pl-c1">=</span><span class="pl-c1">100</span>,
    <span class="pl-s1">verbose</span><span class="pl-c1">=</span><span class="pl-c1">1</span>,
    <span class="pl-s1">warm_start</span><span class="pl-c1">=</span><span class="pl-c1">True</span>,
    <span class="pl-s1">n_jobs</span><span class="pl-c1">=</span><span class="pl-c1">64</span>,
    <span class="pl-s1">penalty</span><span class="pl-c1">=</span><span class="pl-s">'l2'</span>,
    <span class="pl-s1">dual</span><span class="pl-c1">=</span><span class="pl-c1">False</span>,
    <span class="pl-s1">multi_class</span><span class="pl-c1">=</span><span class="pl-s">'ovr'</span>,
)
<span class="pl-s1">model</span>.<span class="pl-en">fit</span>(<span class="pl-s1">train_data</span>.<span class="pl-s1">inputs</span>, <span class="pl-s1">train_data</span>.<span class="pl-s1">targets</span>)</pre></div>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/base.py:253: UserWarning: Trying to unpickle estimator StandardScaler from version 0.20.0 when using version 0.20.3. This might lead to breaking code or invalid results. Use at your own risk.
  UserWarning)
[Parallel(n_jobs=64)]: Using backend ThreadingBackend with 64 concurrent workers.
Traceback (most recent call last):
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/IPython/core/interactiveshell.py&quot;, line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File &quot;&lt;ipython-input-4-5936f410e945&gt;&quot;, line 58, in &lt;module&gt;
    model.fit(train_data_cadd.inputs, train_data_cadd.targets)
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/comet_ml/monkey_patching.py&quot;, line 244, in wrapper
    return_value = original(*args, **kwargs)
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/logistic.py&quot;, line 1363, in fit
    for class_, warm_start_coef_ in zip(classes_, warm_start_coef))
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py&quot;, line 930, in __call__
    self.retrieve()
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py&quot;, line 833, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/multiprocessing/pool.py&quot;, line 644, in get
    raise self._value
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/multiprocessing/pool.py&quot;, line 119, in worker
    result = (True, func(*args, **kwds))
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/_parallel_backends.py&quot;, line 567, in __call__
    return self.func(*args, **kwargs)
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py&quot;, line 225, in __call__
    for func, args, kwargs in self.items]
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py&quot;, line 225, in &lt;listcomp&gt;
    for func, args, kwargs in self.items]
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/logistic.py&quot;, line 792, in logistic_regression_path
    is_saga=(solver == 'saga'))
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/sag.py&quot;, line 305, in sag_solver
    dataset, intercept_decay = make_dataset(X, y, sample_weight, random_state)
  File &quot;/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/base.py&quot;, line 84, in make_dataset
    seed=seed)
  File &quot;sklearn/utils/seq_dataset.pyx&quot;, line 259, in sklearn.utils.seq_dataset.CSRDataset.__cinit__
ValueError: Buffer dtype mismatch, expected 'int' but got 'long'"><pre class="notranslate"><span class="pl-c1">/</span><span class="pl-s1">opt</span><span class="pl-c1">/</span><span class="pl-s1">modules</span><span class="pl-c1">/</span><span class="pl-s1">i12g</span><span class="pl-c1">/</span><span class="pl-s1">anaconda</span><span class="pl-c1">/</span><span class="pl-c1">3</span><span class="pl-c1">-</span><span class="pl-c1">5.0</span>.<span class="pl-c1">1</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python3</span>.<span class="pl-c1">6</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">sklearn</span><span class="pl-c1">/</span><span class="pl-s1">base</span>.<span class="pl-s1">py</span>:<span class="pl-c1">253</span>: <span class="pl-v">UserWarning</span>: <span class="pl-v">Trying</span> <span class="pl-s1">to</span> <span class="pl-s1">unpickle</span> <span class="pl-s1">estimator</span> <span class="pl-v">StandardScaler</span> <span class="pl-k">from</span> <span class="pl-s1">version</span> <span class="pl-c1">0.20</span><span class="pl-c1">.0</span> <span class="pl-s1">when</span> <span class="pl-s1">using</span> <span class="pl-s1">version</span> <span class="pl-c1">0.20</span>.<span class="pl-c1">3.</span> <span class="pl-v">This</span> <span class="pl-s1">might</span> <span class="pl-s1">lead</span> <span class="pl-s1">to</span> <span class="pl-s1">breaking</span> <span class="pl-s1">code</span> <span class="pl-c1">or</span> <span class="pl-s1">invalid</span> <span class="pl-s1">results</span>. <span class="pl-v">Use</span> <span class="pl-s1">at</span> <span class="pl-s1">your</span> <span class="pl-s1">own</span> <span class="pl-s1">risk</span>.
  <span class="pl-v">UserWarning</span>)
[<span class="pl-v">Parallel</span>(<span class="pl-s1">n_jobs</span><span class="pl-c1">=</span><span class="pl-c1">64</span>)]: <span class="pl-v">Using</span> <span class="pl-s1">backend</span> <span class="pl-v">ThreadingBackend</span> <span class="pl-k">with</span> <span class="pl-c1">64</span> <span class="pl-s1">concurrent</span> <span class="pl-s1">workers</span>.
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/IPython/core/interactiveshell.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2862</span>, <span class="pl-s1">in</span> <span class="pl-s1">run_code</span>
    <span class="pl-en">exec</span>(<span class="pl-s1">code_obj</span>, <span class="pl-s1">self</span>.<span class="pl-s1">user_global_ns</span>, <span class="pl-s1">self</span>.<span class="pl-s1">user_ns</span>)
  <span class="pl-v">File</span> <span class="pl-s">"&lt;ipython-input-4-5936f410e945&gt;"</span>, <span class="pl-s1">line</span> <span class="pl-c1">58</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
    <span class="pl-s1">model</span>.<span class="pl-en">fit</span>(<span class="pl-s1">train_data_cadd</span>.<span class="pl-s1">inputs</span>, <span class="pl-s1">train_data_cadd</span>.<span class="pl-s1">targets</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/comet_ml/monkey_patching.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">244</span>, <span class="pl-s1">in</span> <span class="pl-s1">wrapper</span>
    <span class="pl-s1">return_value</span> <span class="pl-c1">=</span> <span class="pl-en">original</span>(<span class="pl-c1">*</span><span class="pl-s1">args</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/logistic.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1363</span>, <span class="pl-s1">in</span> <span class="pl-s1">fit</span>
    <span class="pl-k">for</span> <span class="pl-s1">class_</span>, <span class="pl-s1">warm_start_coef_</span> <span class="pl-c1">in</span> <span class="pl-en">zip</span>(<span class="pl-s1">classes_</span>, <span class="pl-s1">warm_start_coef</span>))
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">930</span>, <span class="pl-s1">in</span> <span class="pl-s1">__call__</span>
    <span class="pl-s1">self</span>.<span class="pl-en">retrieve</span>()
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">833</span>, <span class="pl-s1">in</span> <span class="pl-s1">retrieve</span>
    <span class="pl-s1">self</span>.<span class="pl-s1">_output</span>.<span class="pl-en">extend</span>(<span class="pl-s1">job</span>.<span class="pl-en">get</span>(<span class="pl-s1">timeout</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">timeout</span>))
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/multiprocessing/pool.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">644</span>, <span class="pl-s1">in</span> <span class="pl-s1">get</span>
    <span class="pl-s1">raise</span> <span class="pl-s1">self</span>.<span class="pl-s1">_value</span>
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/multiprocessing/pool.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">119</span>, <span class="pl-s1">in</span> <span class="pl-s1">worker</span>
    <span class="pl-s1">result</span> <span class="pl-c1">=</span> (<span class="pl-c1">True</span>, <span class="pl-en">func</span>(<span class="pl-c1">*</span><span class="pl-s1">args</span>, <span class="pl-c1">**</span><span class="pl-s1">kwds</span>))
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/_parallel_backends.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">567</span>, <span class="pl-s1">in</span> <span class="pl-s1">__call__</span>
    <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">func</span>(<span class="pl-c1">*</span><span class="pl-s1">args</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">225</span>, <span class="pl-s1">in</span> <span class="pl-s1">__call__</span>
    <span class="pl-s1">for</span> <span class="pl-s1">func</span>, <span class="pl-s1">args</span>, <span class="pl-s1">kwargs</span> <span class="pl-c1">in</span> <span class="pl-s1">self</span>.<span class="pl-s1">items</span>]
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">225</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">listcomp</span><span class="pl-c1">&gt;</span>
    <span class="pl-s1">for</span> <span class="pl-s1">func</span>, <span class="pl-s1">args</span>, <span class="pl-s1">kwargs</span> <span class="pl-c1">in</span> <span class="pl-s1">self</span>.<span class="pl-s1">items</span>]
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/logistic.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">792</span>, <span class="pl-s1">in</span> <span class="pl-en">logistic_regression_path</span>
    <span class="pl-s1">is_saga</span><span class="pl-c1">=</span>(<span class="pl-s1">solver</span> <span class="pl-c1">==</span> <span class="pl-s">'saga'</span>))
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/sag.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">305</span>, <span class="pl-s1">in</span> <span class="pl-s1">sag_solver</span>
    <span class="pl-s1">dataset</span>, <span class="pl-s1">intercept_decay</span> <span class="pl-c1">=</span> <span class="pl-en">make_dataset</span>(<span class="pl-v">X</span>, <span class="pl-s1">y</span>, <span class="pl-s1">sample_weight</span>, <span class="pl-s1">random_state</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/opt/modules/i12g/anaconda/3-5.0.1/lib/python3.6/site-packages/sklearn/linear_model/base.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">84</span>, <span class="pl-s1">in</span> <span class="pl-s1">make_dataset</span>
    <span class="pl-s1">seed</span><span class="pl-c1">=</span><span class="pl-s1">seed</span>)
  <span class="pl-v">File</span> <span class="pl-s">"sklearn/utils/seq_dataset.pyx"</span>, <span class="pl-s1">line</span> <span class="pl-c1">259</span>, <span class="pl-s1">in</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">utils</span>.<span class="pl-s1">seq_dataset</span>.<span class="pl-v">CSRDataset</span>.<span class="pl-s1">__cinit__</span>
<span class="pl-v">ValueError</span>: <span class="pl-v">Buffer</span> <span class="pl-s1">dtype</span> <span class="pl-s1">mismatch</span>, <span class="pl-s1">expected</span> <span class="pl-s">'int'</span> <span class="pl-s1">but</span> <span class="pl-s1">got</span> <span class="pl-s">'long'</span></pre></div>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; sklearn.__version__
Out[5]: '0.20.3'
&gt;&gt;&gt; train_data.inputs
Out[6]: 
&lt;28034374x904 sparse matrix of type '&lt;class 'numpy.float32'&gt;'
	with 2223406363 stored elements in Compressed Sparse Row format&gt;"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">__version__</span>
<span class="pl-v">Out</span>[<span class="pl-c1">5</span>]: <span class="pl-s">'0.20.3'</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">train_data</span>.<span class="pl-s1">inputs</span>
<span class="pl-v">Out</span>[<span class="pl-c1">6</span>]: 
<span class="pl-c1">&lt;</span><span class="pl-c1">28034374</span><span class="pl-s1">x904</span> <span class="pl-s1">sparse</span> <span class="pl-s1">matrix</span> <span class="pl-s1">of</span> <span class="pl-s1">type</span> <span class="pl-s">'&lt;class '</span><span class="pl-s1">numpy</span>.<span class="pl-s1">float32</span><span class="pl-s">'&gt;'</span>
	<span class="pl-k">with</span> <span class="pl-c1">2223406363</span> <span class="pl-s1">stored</span> <span class="pl-s1">elements</span> <span class="pl-c1">in</span> <span class="pl-v">Compressed</span> <span class="pl-v">Sparse</span> <span class="pl-v">Row</span> <span class="pl-s1">format</span><span class="pl-c1">&gt;</span></pre></div>
<p dir="auto">Is there some way I can still train my data?</p>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/Hoeze/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Hoeze">@Hoeze</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="302607874" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/10758" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/10758/hovercard?comment_id=476755852&amp;comment_type=issue_comment" href="https://github.com/scikit-learn/scikit-learn/issues/10758#issuecomment-476755852">#10758 (comment)</a></em></p>
<p dir="auto">Classification report computes <del>micro-averages</del> weighted macro-averages:<br>
<a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/metrics/classification.py#L1265">https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/metrics/classification.py#L1265</a></p>
<p dir="auto">However, that <del>is not documented and</del> can not be changed.<br>
I wonder whether we should add an "average" keyword <del>or just document it</del>?</p>