Advertisement
gk231192

Module 10.3 tSNE

Jul 7th, 2025
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. # Apply t-SNE; Continued after PCA Code
  2. tsne = TSNE(n_components=2, perplexity=30, n_iter=1000, random_state=42)
  3. X_tsne = tsne.fit_transform(X_scaled)
  4.  
  5. # Plot t-SNE
  6. plt.figure(figsize=(8, 6))
  7. plt.scatter(X_tsne[:, 0], X_tsne[:, 1], c=target, cmap='coolwarm', alpha=0.6)
  8. plt.xlabel('t-SNE Component 1')
  9. plt.ylabel('t-SNE Component 2')
  10. plt.title('t-SNE on Titanic Data')
  11. plt.colorbar(label='Survived')
  12. plt.grid(True)
  13. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement