Skip to content

Instantly share code, notes, and snippets.

@grohith327
Created June 13, 2018 16:32
Show Gist options
  • Save grohith327/fe5251580026c43f0c6f088e342544f5 to your computer and use it in GitHub Desktop.
Save grohith327/fe5251580026c43f0c6f088e342544f5 to your computer and use it in GitHub Desktop.
import numpy as np
from sklearn.cross_validation import train_test_split
## Retrieve features
X = df.values.tolist()
Y = []
## Convert classes in Strings to Integers
for val in target:
if(val == 'Iris-setosa'):
Y.append(0)
elif(val == 'Iris-virginica'):
Y.append(2)
else:
Y.append(1)
## Make them as numpy array
X = np.array(X)
Y = np.array(Y)
## Shuffle and split the data into training and test set
x_train, x_test, y_train, y_test = train_test_split(X,Y,train_size=0.9)
## Make them as numpy arrays
x_train = np.array(x_train)
y_train = np.array(y_train)
x_test = np.array(x_test)
y_test = np.array(y_test)
@kanuptiwari
Copy link

after the scatter plot the whole window disappears and the code exits with 1

@kanuptiwari
Copy link

Screenshot (110)
Screenshot (111)
Screenshot (110)
Screenshot (111)

@grohith327
Copy link
Author

The code did run successfully. The accuracy is printed in the output.

@kanuptiwari
Copy link

Okay I thought the graph that you showed in the article should also be printed.??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment