Run t-SNE on the Iris dataset and display the first 5 embeddings. >>> main() # doctest: +ELLIPSIS t-SNE embedding (first 5 points): [[...
()
| 147 | |
| 148 | |
| 149 | def main() -> None: |
| 150 | """ |
| 151 | Run t-SNE on the Iris dataset and display the first 5 embeddings. |
| 152 | |
| 153 | >>> main() # doctest: +ELLIPSIS |
| 154 | t-SNE embedding (first 5 points): |
| 155 | [[... |
| 156 | """ |
| 157 | features, _labels = collect_dataset() |
| 158 | embedding = apply_tsne(features, n_components=2, n_iter=300) |
| 159 | |
| 160 | if not isinstance(embedding, np.ndarray): |
| 161 | raise TypeError("t-SNE embedding must be an ndarray") |
| 162 | |
| 163 | print("t-SNE embedding (first 5 points):") |
| 164 | print(embedding[:5]) |
| 165 | |
| 166 | # Optional visualization (Ruff/mypy compliant) |
| 167 | |
| 168 | # import matplotlib.pyplot as plt |
| 169 | # plt.scatter(embedding[:, 0], embedding[:, 1], c=labels, cmap="viridis") |
| 170 | # plt.title("t-SNE Visualization of the Iris Dataset") |
| 171 | # plt.xlabel("Dimension 1") |
| 172 | # plt.ylabel("Dimension 2") |
| 173 | # plt.show() |
| 174 | |
| 175 | |
| 176 | if __name__ == "__main__": |
no test coverage detected