Skip to content

Commit 5841424

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6cff5b8 commit 5841424

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

machine_learning/tsne.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ def compute_pairwise_affinities(data_x: np.ndarray, sigma: float = 1.0) -> np.nd
6565
n_samples = data_x.shape[0]
6666
sum_x = np.sum(np.square(data_x), axis=1)
6767
d = np.add(np.add(-2 * np.dot(data_x, data_x.T), sum_x).T, sum_x)
68-
p = np.exp(-d / (2 * sigma ** 2))
68+
p = np.exp(-d / (2 * sigma**2))
6969
np.fill_diagonal(p, 0)
7070
p /= np.sum(p)
7171
return (p + p.T) / (2 * n_samples)
7272

7373

74-
def compute_low_dim_affinities(embedding_y: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
74+
def compute_low_dim_affinities(
75+
embedding_y: np.ndarray,
76+
) -> tuple[np.ndarray, np.ndarray]:
7577
"""
7678
Computes low-dimensional similarities (Q matrix) using Student-t distribution.
7779
@@ -87,7 +89,9 @@ def compute_low_dim_affinities(embedding_y: np.ndarray) -> tuple[np.ndarray, np.
8789
(2, 2)
8890
"""
8991
sum_y = np.sum(np.square(embedding_y), axis=1)
90-
num = 1 / (1 + np.add(np.add(-2 * np.dot(embedding_y, embedding_y.T), sum_y).T, sum_y))
92+
num = 1 / (
93+
1 + np.add(np.add(-2 * np.dot(embedding_y, embedding_y.T), sum_y).T, sum_y)
94+
)
9195
np.fill_diagonal(num, 0)
9296
q = num / np.sum(num)
9397
return q, num

0 commit comments

Comments
 (0)