Skip to content

Commit

Permalink
add precomputed option
Browse files Browse the repository at this point in the history
  • Loading branch information
d-schindler committed Apr 17, 2024
1 parent ebbf04d commit 12df4b7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pygenstability/data_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ def __init__(
def fit(self, X):
"""Construct graph from samples-by-features matrix."""

# if precomputed take X as adjacency matrix
if self.method == "precomputed":
assert (
X.shape[0] == X.shape[1]
), "Precomputed matrix should be a square matrix."
self.adjacency_ = X
return self.adjacency_

# compute normalised distance matrix
D = squareform(pdist(X, metric=self.metric))
D_norm = D / np.amax(D)
Expand Down

0 comments on commit 12df4b7

Please sign in to comment.