Skip to content

Commit

Permalink
Fix: Remove some slow jaccard features (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon authored Feb 13, 2024
1 parent 8a153a1 commit 0480c93
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
51 changes: 0 additions & 51 deletions hcga/features/jaccard_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,6 @@ def degree_assortativity_coeff(graph):
return nx.degree_assortativity_coefficient(jaccard_similarity(graph))


def graph_clique_number(graph):
"""graph_clique_number"""
return max(len(c) for c in nx.clique.find_cliques(jaccard_similarity(graph)))


def num_max_cliques(graph):
"""num_max_cliques"""
return sum(1 for _ in nx.clique.find_cliques(jaccard_similarity(graph)))


def transitivity(graph):
"""transitivity"""
return nx.transitivity(jaccard_similarity(graph))
Expand All @@ -117,16 +107,6 @@ def global_efficiency(graph):
return nx.global_efficiency(jaccard_similarity(graph))


def node_connectivity(graph):
"""node_connectivity"""
return nx.node_connectivity(jaccard_similarity(graph))


def edge_connectivity(graph):
"""edge_connectivity"""
return nx.edge_connectivity(jaccard_similarity(graph))


class JaccardSimilarity(FeatureClass):
"""Jaccard Similarity class."""

Expand Down Expand Up @@ -164,7 +144,6 @@ def compute_features(self):
"Diameter of Jaccard similarity graph",
InterpretabilityScore(5),
)

self.add_feature(
"radius",
radius,
Expand All @@ -180,21 +159,6 @@ def compute_features(self):
InterpretabilityScore(4),
)

# Cliques
self.add_feature(
"graph_clique_number",
graph_clique_number,
"The size of the largest clique in the Jaccard similarity graph",
InterpretabilityScore(3),
)

self.add_feature(
"num_max_cliques",
num_max_cliques,
"The number of maximal cliques in the Jaccard similarity graph",
InterpretabilityScore(3),
)

# Clustering
self.add_feature(
"transitivity",
Expand Down Expand Up @@ -232,18 +196,3 @@ def compute_features(self):
"The global efficiency",
InterpretabilityScore(4),
)

# Node connectivity
self.add_feature(
"node_connectivity",
node_connectivity,
"Node connectivity",
InterpretabilityScore(4),
)

self.add_feature(
"edge_connectivity",
edge_connectivity,
"Edge connectivity",
InterpretabilityScore(4),
)
2 changes: 1 addition & 1 deletion hcga/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def convert_graph( # pylint: disable=too-many-branches
label = [label]

if isinstance(graph, nx.Graph):
A = nx.to_scipy_sparse_matrix(graph, weight="weight", format="coo")
A = nx.to_scipy_sparse_array(graph, weight="weight", format="coo")

if not node_features:
try:
Expand Down

0 comments on commit 0480c93

Please sign in to comment.