Skip to content

ValueError when VertexHistogram uses sparse matrices (dtype >f8 not supported by scipy.sparse) #125

@JohnLyu2

Description

@JohnLyu2

Describe the bug
VertexHistogram uses dtype=">f8" when building sparse matrices. Current scipy.sparse (my scipy version is 1.17.0) does not support that dtype and raises: ValueError: scipy.sparse does not support dtype >f8.

To Reproduce

from grakel.kernels import WeisfeilerLehman, VertexHistogram

# Two minimal graphs: path 0--1--2
# (adjacency: node -> list of neighbors, node_labels)
adj1 = {0: [1], 1: [0, 2], 2: [1]}
nl1 = {0: 0, 1: 1, 2: 0}
adj2 = {0: [1], 1: [0, 2], 2: [1]}
nl2 = {0: 1, 1: 0, 2: 1}

X = [(adj1, nl1, {}), (adj2, nl2, {})]

# Force the sparse path in VertexHistogram so csr_matrix(dtype=">f8") is used
wl = WeisfeilerLehman(
    n_iter=1,
    base_graph_kernel=(VertexHistogram, {"sparse": True}),
    normalize=True,
)
wl.fit_transform(X)  # raises ValueError: scipy.sparse does not support dtype >f8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions