Skip to content

Validation step fails when trying to set WRITEABLE flag to True #29182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ElenaKhaustova opened this issue Jun 4, 2024 · 2 comments · Fixed by #29018
Closed

Validation step fails when trying to set WRITEABLE flag to True #29182

ElenaKhaustova opened this issue Jun 4, 2024 · 2 comments · Fixed by #29018
Labels

Comments

@ElenaKhaustova
Copy link

ElenaKhaustova commented Jun 4, 2024

Describe the bug

Original issue: kedro-org/kedro#3674

Relates to #28824, #29103, #28899

The example below fails on validation step with ValueError: cannot set WRITEABLE flag to True of this array.

Steps/Code to Reproduce

import pickle

from sklearn.metrics import mean_absolute_error


with open("_data/X_test.pkl", "rb") as fh:
    X_test = pickle.load(fh)
with open("_data/y_test.pkl", "rb") as fh:
    y_test = pickle.load(fh)
with open("_data/regressor.pickle", "rb") as fh:
    regressor = pickle.load(fh)

y_pred = regressor.predict(X_test)
mae = mean_absolute_error(y_test, y_pred)

Attaching the contents of _data: _data.zip

Expected Results

No error is thrown.

Actual Results

Traceback (most recent call last):
  File "/test_scikit_learn_issue/test.py", line 13, in <module>
    mae = mean_absolute_error(y_test, y_pred)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/sklearn/utils/_param_validation.py", line 213, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/sklearn/metrics/_regression.py", line 216, in mean_absolute_error
    y_type, y_true, y_pred, multioutput = _check_reg_targets(
                                          ^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/sklearn/metrics/_regression.py", line 112, in _check_reg_targets
    y_true = check_array(y_true, ensure_2d=False, dtype=dtype)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/sklearn/utils/validation.py", line 1107, in check_array
    array.flags.writeable = True
    ^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot set WRITEABLE flag to True of this array

Versions

System:
    python: 3.11.9 (main, Apr 19 2024, 11:44:45) [Clang 14.0.6 ]
executable: /bin/python
   machine: macOS-10.16-x86_64-i386-64bit

Python dependencies:
      sklearn: 1.5.0
          pip: 24.0
   setuptools: 69.5.1
        numpy: 1.26.4
        scipy: 1.13.1
       Cython: None
       pandas: 2.2.2
   matplotlib: None
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 10
         prefix: libopenblas
       filepath: /lib/python3.11/site-packages/numpy/.dylibs/libopenblas64_.0.dylib
        version: 0.3.23.dev
threading_layer: pthreads
   architecture: Nehalem

       user_api: blas
   internal_api: openblas
    num_threads: 10
         prefix: libopenblas
       filepath: /lib/python3.11/site-packages/scipy/.dylibs/libopenblas.0.dylib
        version: 0.3.27
threading_layer: pthreads
   architecture: Nehalem

       user_api: openmp
   internal_api: openmp
    num_threads: 10
         prefix: libomp
       filepath: /lib/python3.11/site-packages/sklearn/.dylibs/libomp.dylib
        version: None
@adrinjalali
Copy link
Member

cc @jeremiedbb

@jeremiedbb
Copy link
Member

Same problem as reported in #29018 (comment). This will be fixed by #29018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants