Skip to content

Commit

Permalink
more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
d-schindler committed Apr 18, 2024
1 parent 9ec9f12 commit a830445
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pygenstability/data_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
# attributes
self.adjacency_ = None

def fit(self, X):
def get_graph(self, X):
"""Construct graph from samples-by-features matrix."""

# if precomputed take X as adjacency matrix
Expand Down Expand Up @@ -132,9 +132,10 @@ def labels_(self):
return labels

def fit(self, X):
"""Construct graph and run PyGenStability for multiscale data clustering."""

# construct graph
self.adjacency_ = csr_matrix(super().fit(X))
self.adjacency_ = csr_matrix(self.get_graph(X))

# run PyGenStability
self.results_ = pgs_run(self.adjacency_, **self.pgs_kwargs)
Expand Down Expand Up @@ -198,5 +199,9 @@ def plot_robust_partitions(
ax.scatter(x_coord, y_coord, s=node_size, c=partition, zorder=10, cmap=cmap)

# set labels
ax.set(xlabel="x", ylabel="y", title=f"Robust Partion {m+1}")
ax.set(
xlabel="x",
ylabel="y",
title=f"Robust Partion {m+1} (with {len(np.unique(partition))} clusters)",
)
plt.show()

0 comments on commit a830445

Please sign in to comment.