Skip to content

ValueError: buffer source array is read-only when running bench_mnist.py  #15851

@mayujsw

Description

@mayujsw

scikit-learn version : 0.22
Tried both python: 3.7.3 and python 3.7.5, the error is the same as below:

when running python bench_mnist.py --classifiers ExtraTrees, it will report below error:

MNIST dataset benchmark

Benchmark on the MNIST dataset. The dataset comprises 70,000 samples
and 784 features. Here, we consider the task of predicting
10 classes - digits from 0 to 9 from their raw images. By contrast to the
covertype dataset, the feature space is homogenous.

Example of output :
[..]

Classification performance:
===========================
Classifier               train-time   test-time   error-rate
------------------------------------------------------------
MLP_adam                     53.46s       0.11s       0.0224
Nystroem-SVM                112.97s       0.92s       0.0228
MultilayerPerceptron         24.33s       0.14s       0.0287
ExtraTrees                   42.99s       0.57s       0.0294
RandomForest                 42.70s       0.49s       0.0318
SampledRBF-SVM              135.81s       0.56s       0.0486
LinearRegression-SAG         16.67s       0.06s       0.0824
CART                         20.69s       0.02s       0.1219
dummy                         0.00s       0.01s       0.8973

Dataset statistics:

number of features: 784
number of classes: 10
data type: float32
number of train samples: 60000 (size=188MB)
number of test samples: 10000 (size=31MB)

Training Classifiers

Training ExtraTrees ... Traceback (most recent call last):
  File "bench_mnist.py", line 161, in <module>
    y_pred = estimator.predict(X_test)
  File "/usr/local/lib/python3.7/dist-packages/sklearn/ensemble/_forest.py", line 612, in predict
    proba = self.predict_proba(X)
  File "/usr/local/lib/python3.7/dist-packages/sklearn/ensemble/_forest.py", line 669, in predict_proba
    for e in self.estimators_)
  File "/usr/local/lib/python3.7/dist-packages/joblib/parallel.py", line 1003, in __call__
    if self.dispatch_one_batch(iterator):
  File "/usr/local/lib/python3.7/dist-packages/joblib/parallel.py", line 834, in dispatch_one_batch
    self._dispatch(tasks)
  File "/usr/local/lib/python3.7/dist-packages/joblib/parallel.py", line 753, in _dispatch
    job = self._backend.apply_async(batch, callback=cb)
  File "/usr/local/lib/python3.7/dist-packages/joblib/_parallel_backends.py", line 201, in apply_async
    result = ImmediateResult(func)
  File "/usr/local/lib/python3.7/dist-packages/joblib/_parallel_backends.py", line 582, in __init__
    self.results = batch()
  File "/usr/local/lib/python3.7/dist-packages/joblib/parallel.py", line 256, in __call__
    for func, args, kwargs in self.items]
  File "/usr/local/lib/python3.7/dist-packages/joblib/parallel.py", line 256, in <listcomp>
    for func, args, kwargs in self.items]
  File "/usr/local/lib/python3.7/dist-packages/sklearn/ensemble/_forest.py", line 449, in _accumulate_prediction
    prediction = predict(X, check_input=False)
  File "/usr/local/lib/python3.7/dist-packages/sklearn/tree/_classes.py", line 908, in predict_proba
    proba = self.tree_.predict(X)
  File "sklearn/tree/_tree.pyx", line 768, in sklearn.tree._tree.Tree.predict
  File "sklearn/tree/_tree.pyx", line 770, in sklearn.tree._tree.Tree.predict
  File "sklearn/tree/_tree.pyx", line 781, in sklearn.tree._tree.Tree.apply
  File "sklearn/tree/_tree.pyx", line 795, in sklearn.tree._tree.Tree._apply_dense
  File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper
  File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__
ValueError: buffer source array is read-only

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions