Skip to content
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

Plot mistake #28

Open
karakol15 opened this issue Mar 2, 2020 · 4 comments
Open

Plot mistake #28

karakol15 opened this issue Mar 2, 2020 · 4 comments

Comments

@karakol15
Copy link

There is a problem in the visualization part. When I am trying to plot the graph in the example, I see the following mistake:


TypeError Traceback (most recent call last)
in
12 ice_plot(ice_df, frac_to_plot=0.1,
13 color_by='x3', cmap=PuOr,
---> 14 ax=ice_ax);
15
16 ice_ax.set_xlabel('$X_2$');

C:\ProgramData\Anaconda3\lib\site-packages\pycebox\ice.py in ice_plot(ice_data, frac_to_plot, plot_points, point_kwargs, x_quantile, plot_pdp, centered, centered_quantile, color_by, cmap, ax, pdp_kwargs, **kwargs)
128 if frac_to_plot < 1.:
129 n_cols = ice_data.shape[1]
--> 130 icols = np.random.choice(n_cols, size=frac_to_plot * n_cols, replace=False)
131 plot_ice_data = ice_data.iloc[:, icols]
132 else:

mtrand.pyx in mtrand.RandomState.choice()

TypeError: 'float' object cannot be interpreted as an integer

@vnguyendc
Copy link

Following

@mhwombat
Copy link

mhwombat commented Dec 1, 2020

I've experienced the same problem with the tutorial. In case it helps, here are the modules reported by pip list.

Package                       Version
----------------------------- -------------------
absl-py                       0.11.0
alembic                       1.4.3
argon2-cffi                   20.1.0
astunparse                    1.6.3
async-generator               1.10
attrs                         20.2.0
backcall                      0.2.0
backports.functools-lru-cache 1.6.1
beautifulsoup4                4.9.3
bleach                        3.2.1
blinker                       1.4
bokeh                         2.2.3
Bottleneck                    1.3.2
brotlipy                      0.7.0
cachetools                    4.1.1
certifi                       2020.6.20
certipy                       0.1.3
cffi                          1.14.3
chardet                       3.0.4
click                         7.1.2
cloudpickle                   1.6.0
conda                         4.9.0
conda-package-handling        1.7.2
cryptography                  3.2
cycler                        0.10.0
Cython                        0.29.21
cytoolz                       0.11.0
dask                          2.30.0
decorator                     4.4.2
defusedxml                    0.6.0
dill                          0.3.2
distributed                   2.30.0
entrypoints                   0.3
fastcache                     1.1.0
featureimpact                 2.2.0
fsspec                        0.8.4
gast                          0.3.3
geographiclib                 1.50
geopy                         2.0.0
gmpy2                         2.1.0b1
google-auth                   1.23.0
google-auth-oauthlib          0.4.2
google-pasta                  0.2.0
graphviz                      0.14.2
grpcio                        1.33.2
h5py                          2.10.0
HeapDict                      1.0.1
idna                          2.10
imagecodecs                   2020.5.30
imageio                       2.9.0
importlib-metadata            2.0.0
ipykernel                     5.3.4
ipympl                        0.5.8
ipython                       7.18.1
ipython-genutils              0.2.0
ipywidgets                    7.5.1
jedi                          0.17.2
Jinja2                        2.11.2
joblib                        0.17.0
json5                         0.9.5
jsonschema                    3.2.0
jupyter-client                6.1.7
jupyter-core                  4.6.3
jupyter-telemetry             0.0.5
jupyterhub                    1.1.0
jupyterlab                    2.2.8
jupyterlab-pygments           0.1.2
jupyterlab-server             1.2.0
Keras                         2.4.3
Keras-Preprocessing           1.1.2
kiwisolver                    1.3.0
llvmlite                      0.34.0
locket                        0.2.0
Mako                          1.1.3
Markdown                      3.3.3
MarkupSafe                    1.1.1
matplotlib                    3.3.2
mistune                       0.8.4
mock                          4.0.2
mpmath                        1.1.0
msgpack                       1.0.0
nbclient                      0.5.1
nbconvert                     6.0.7
nbformat                      5.0.8
nest-asyncio                  1.4.1
networkx                      2.5
notebook                      6.1.4
numba                         0.51.2
numexpr                       2.7.1
numpy                         1.18.5
oauthlib                      3.0.1
olefile                       0.46
opt-einsum                    3.3.0
packaging                     20.4
pamela                        1.0.0
pandas                        1.1.3
pandocfilters                 1.4.2
parso                         0.7.1
partd                         1.1.0
patsy                         0.5.1
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        8.0.1
pip                           20.2.4
plotly                        4.12.0
prometheus-client             0.8.0
prompt-toolkit                3.0.8
protobuf                      3.13.0
psutil                        5.7.3
ptyprocess                    0.6.0
pyasn1                        0.4.8
pyasn1-modules                0.2.8
pycebox                       0.0.1
pycosat                       0.6.3
pycparser                     2.20
pycurl                        7.43.0.6
Pygments                      2.7.2
PyJWT                         1.7.1
pyOpenSSL                     19.1.0
pyparsing                     2.4.7
pyrsistent                    0.17.3
PySocks                       1.7.1
python-dateutil               2.8.1
python-editor                 1.0.4
python-json-logger            2.0.1
pytz                          2020.1
PyWavelets                    1.1.1
PyYAML                        5.3.1
pyzmq                         19.0.2
requests                      2.24.0
requests-oauthlib             1.3.0
retrying                      1.3.3
rpy2                          3.3.6
rsa                           4.6
ruamel-yaml-conda             0.15.80
ruamel.yaml                   0.16.12
ruamel.yaml.clib              0.2.2
scikit-image                  0.17.2
scikit-learn                  0.23.2
scipy                         1.5.2
seaborn                       0.11.0
Send2Trash                    1.5.0
setuptools                    49.6.0.post20201009
shap                          0.36.0
simplegeneric                 0.8.1
six                           1.15.0
slicer                        0.0.4
sortedcontainers              2.2.2
soupsieve                     2.0.1
SQLAlchemy                    1.3.20
statsmodels                   0.12.1
sympy                         1.6.2
tables                        3.6.1
tblib                         1.6.0
tensorboard                   2.3.0
tensorboard-plugin-wit        1.7.0
tensorflow                    2.3.1
tensorflow-estimator          2.3.0
termcolor                     1.1.0
terminado                     0.9.1
testpath                      0.4.4
threadpoolctl                 2.1.0
tifffile                      2020.10.1
toolz                         0.11.1
tornado                       6.0.4
tqdm                          4.51.0
traitlets                     5.0.5
tslearn                       0.4.1
typing-extensions             3.7.4.3
tzlocal                       2.1
urllib3                       1.25.11
vincent                       0.4.4
wcwidth                       0.2.5
webencodings                  0.5.1
Werkzeug                      1.0.1
wheel                         0.35.1
widgetsnbextension            3.5.1
wrapt                         1.12.1
xgboost                       1.2.1
xlrd                          1.2.0
zict                          2.0.0
zipp                          3.4.0
Note: you may need to restart the kernel to use updated packages.


@mhwombat
Copy link

mhwombat commented Dec 1, 2020

To be precise, I may be getting the error in a different place:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-aa8436012d96> in <module>
     16 data_ax.set_title('Data');
     17 
---> 18 ice_plot(ice_df, frac_to_plot=0.1,
     19          c='k', alpha=0.25,
     20          ax=ice_ax);

/opt/conda/lib/python3.8/site-packages/pycebox/ice.py in ice_plot(ice_data, frac_to_plot, plot_points, point_kwargs, x_quantile, plot_pdp, centered, centered_quantile, color_by, cmap, ax, pdp_kwargs, **kwargs)
    128     if frac_to_plot < 1.:
    129         n_cols = ice_data.shape[1]
--> 130         icols = np.random.choice(n_cols, size=frac_to_plot * n_cols, replace=False)
    131         plot_ice_data = ice_data.iloc[:, icols]
    132     else:

mtrand.pyx in numpy.random.mtrand.RandomState.choice()

TypeError: 'float' object cannot be interpreted as an integer

@SunnyW4869
Copy link

SunnyW4869 commented Nov 16, 2021

supposed to be solved by modified line as follow #27
icols = np.random.choice(n_cols, size=int(frac_to_plot * n_cols), replace=False)

but for me it still doesn't work, showed the same error information even the log showed the modified line with int() in ice.py

Please check

Update

Restarting the kernel did the trick
Modifying line 130 as described in #27 is the solution for this issue.

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

No branches or pull requests

4 participants