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