Skip to content

Instantly share code, notes, and snippets.

@vihar
Created May 11, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vihar/54a840ec67f61560ec4f43e22abf52c2 to your computer and use it in GitHub Desktop.
Save vihar/54a840ec67f61560ec4f43e22abf52c2 to your computer and use it in GitHub Desktop.
# Importing Modules
from sklearn import datasets
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
# Loading dataset
iris_df = datasets.load_iris()
# Defining Model
model = TSNE(learning_rate=100)
# Fitting Model
transformed = model.fit_transform(iris_df.data)
# Plotting 2d t-Sne
x_axis = transformed[:, 0]
y_axis = transformed[:, 1]
plt.scatter(x_axis, y_axis, c=iris_df.target)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment