Skip to content

Commit

Permalink
add legend to cluster plot
Browse files Browse the repository at this point in the history
  • Loading branch information
svirpioj committed Aug 30, 2023
1 parent 4206df6 commit 0eef64f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions opusfilter/autogen_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ def plot(self, plt):
"""Plot clustering and histograms"""
plt.figure(figsize=(10, 10))
data_t = PCA(n_components=2).fit_transform(self.standard_data)
colors = ['orange' if lbl == self.noisy_label else 'blue' for lbl in self.labels]
plt.scatter(data_t[:, 0], data_t[:, 1], c=colors, marker=',', s=1)
for label_id in [self.noisy_label, self.clean_label]:
points = np.where(self.labels == label_id)
plt.scatter(data_t[points, 0], data_t[points, 1],
c='orange' if label_id == self.noisy_label else 'blue',
label='noisy' if label_id == self.noisy_label else 'clean',
marker=',', s=1)
plt.legend()
plt.title('Clusters')
noisy_samples = self.df.iloc[np.where(self.labels == self.noisy_label)]
clean_samples = self.df.iloc[np.where(self.labels == self.clean_label)]
Expand Down

0 comments on commit 0eef64f

Please sign in to comment.