Open tomaszek0 opened 2 years ago
This issue has arisen at an awkward moment, because I'm currently on vacation with limited time and access to computers and no access to a computer running any version of Windows. I'll be home a week from now.
Meanwhile: I don't understand what you mean by, "I did not fix the environmental variables according to the instruction - specific to the Linux system." Are you talking about the instruction in the sklearn-gbmi README to set the environment variable USE_CYTHONIZE to 1? That instruction isn't necessarily specific to Linux. However, I know little about building software under Windows, which I generally don't use. I'd advise you to make sure you're doing whatever the Windows-appropriate thing is to produce the same effect.
If that isn't obvious or doesn't work, I'd suggest Googling for information about using Cython under Windows; for example:
https://www.quora.com/How-do-I-install-Cython-on-Windows-10
(That particular page may or may not be helpful, but Googling "windows cython" yields many more pages.)
Thank you for the tips. I followed the instructions at https://realpython.com/cpython-source-code-guide/ and https://smirnov-am.github.io/cython/. I installed Visual Studio 2022 with C / C ++ compilers. I also updated setuptools. Then I installed cython and sklearn-gbmi. I'm stuck- the value error still is displayed.
I realized a couple of days ago that I'd forgotten about this. Unfortunately, I'm afraid I still can't help. I can't reproduce this problem, and Windows is an alien environment to me, so I have no further ideas to offer. If you're still having this problem, I think you'll have to seek advice from somebody with experience in building Python packages with Cython under Windows.
I had the same error as @tomaszek0. I am working on Windows 10 with Python 3.7.8 At first I had to figure out how to get the package installed, in order to do that I found out that I had to download Visual Code. When I finally to it to be installed, the same error appeared: (I'll post it here for reference and with a bit of formatting for better readability)
File "d:/path/main.py", line 2, in <module>
from utils.computeDataSetProperties import getDataPropPost, getDataPropPre
File ""d:/path/computeDataSetProperties.py", line 10, in <module>
from sklearn_gbmi import h
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn_gbmi\__init__.py", line 46, in <module>
from .sklearn_gbmi import *
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn_gbmi\sklearn_gbmi.py", line 13, in <module>
from .partial_dependence import partial_dependence
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn_gbmi\partial_dependence.py", line 19, in <module>
from ._partial_dependence_tree import _partial_dependence_tree
File "_tree.pxd", line 85, in init sklearn_gbmi._partial_dependence_tree
ValueError: sklearn.tree._tree.TreeBuilder size changed, may indicate binary incompatibility. Expected 80 from C header, got 72 from PyObject
Then I switched to the WSL and then this error appeared:
File "/mnt/d/path/main.py", line 2, in <module>
from utils.computeDataSetProperties import getDataPropPost, getDataPropPre
File "/mnt/d/path/computeDataSetProperties.py", line 10, in <module>
from sklearn_gbmi import h
File "/home/user/.local/lib/python3.8/site-packages/sklearn_gbmi/__init__.py", line 46, in <module>
from .sklearn_gbmi import *
File "/home/user/.local/lib/python3.8/site-packages/sklearn_gbmi/sklearn_gbmi.py", line 13, in <module>
from .partial_dependence import partial_dependence
File "/home/user/.local/lib/python3.8/site-packages/sklearn_gbmi/partial_dependence.py", line 19, in <module>
from ._partial_dependence_tree import _partial_dependence_tree
File "_criterion.pxd", line 21, in init sklearn_gbmi._partial_dependence_tree
ValueError: sklearn.tree._criterion.Criterion size changed, may indicate binary incompatibility. Expected 352 from C header, got 328 from PyObject
I tried the fix from the readme but it did not work
So I tried your example version on Colab and got the first error.
I am using Win10 and currently trying to compute the H-statistic for Gradient-boosting models. I installed sklearn-gbmi but running the code given the "value error". So, I installed Cython according to the instructions on Github here. I did not fix the environmental variables according to the instruction - specific to the Linux system. I got the same value error again. I executed the following code:
A complete example of how to use the sklearn_gbmi module.
import numpy as np import pandas as pd from sklearn.ensemble import GradientBoostingRegressor from sklearn.inspection import plot_partial_dependence from sklearn_gbmi import *
ValueError Traceback (most recent call last) Input In [2], in <cell line: 10>() 7 from sklearn.ensemble import GradientBoostingRegressor 9 from sklearn.inspection import plot_partial_dependence ---> 10 from sklearn_gbmi import *
File ~\anaconda3\lib\site-packages\sklearn_gbmi__init__.py:46, in
1 """
2 PURPOSE
3
(...)
43 gbm.
44 """
---> 46 from .sklearn_gbmi import *
File ~\anaconda3\lib\site-packages\sklearn_gbmi\sklearn_gbmi.py:13, in
9 import math
11 import numpy as np
---> 13 from .partial_dependence import partial_dependence
16 def h(gbm, array_or_frame, indices_or_columns = 'all'):
17 """
18 PURPOSE
19
(...)
68 fitting gbm.
69 """
File ~\anaconda3\lib\site-packages\sklearn_gbmi\partial_dependence.py:19, in
15 import numpy as np
17 from sklearn.tree._tree import DTYPE
---> 19 from ._partial_dependence_tree import _partial_dependence_tree
21 def partial_dependence(gbrt, target_variables, grid):
22 target_variables = np.asarray(target_variables, dtype=np.int32, order='C').ravel()
File _tree.pxd:85, in init sklearn_gbmi._partial_dependence_tree()
ValueError: sklearn.tree._tree.TreeBuilder size changed, may indicate binary incompatibility. Expected 80 from C header, got 72 from PyObject