The Wayback Machine - https://web.archive.org/web/20201208095351/https://github.com/scikit-learn/scikit-learn/issues/18963
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

sklearn.feature_extraction.grid_to_graph may reorder vertices #18963

Open
bthirion opened this issue Dec 3, 2020 · 2 comments · May be fixed by #18964
Open

sklearn.feature_extraction.grid_to_graph may reorder vertices #18963

bthirion opened this issue Dec 3, 2020 · 2 comments · May be fixed by #18964

Comments

@bthirion
Copy link
Member

@bthirion bthirion commented Dec 3, 2020

Describe the bug

In grid_to_graph, you expect the vertices to correspond to the implicit order defined by the mask. This is not always the case, due to the occurrence of isolated vertices that are dismissed in the reindexing of the vertices.

Steps/Code to Reproduce

import numpy as np
from sklearn.feature_extraction import grid_to_graph

mask = np.zeros((2, 3)).astype('bool')
mask[0, 0] = 1
mask[0, 2] = 1
mask[1, 2] = 1
print(grid_to_graph(2, 3, 1, mask.ravel()).todense())

Expected Results

[[1 0 0]
[0 1 1]
[0 1 1]]

Actual Results

[[1 1 0]
[1 1 0]
[0 0 1]]

Versions

System:
machine: Linux-4.4.0-187-generic-x86_64-with-Ubuntu-16.04-xenial
python: 3.5.2 (default, Oct 7 2020, 17:19:02) [GCC 5.4.0 20160609]
executable: /usr/bin/python3

BLAS:
lib_dirs: /usr/lib
macros: HAVE_CBLAS=None
cblas_libs: openblas, openblas

Python deps:
scipy: 1.1.0
Cython: 0.29
pip: 18.1
pandas: 0.23.4
sklearn: 0.22.dev0
setuptools: 40.4.3
numpy: 1.15.4

@CryoFantom
Copy link

@CryoFantom CryoFantom commented Dec 5, 2020

Hello, I'm new in contributing, is this open and does it need help ?

@cmarmo cmarmo added Bug and removed Bug: triage labels Dec 7, 2020
@bthirion
Copy link
Member Author

@bthirion bthirion commented Dec 8, 2020

Hi @CryoFantom
#18964 is taking care of it, it mostly needs a review.

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

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.