Created
June 7, 2018 14:20
-
-
Save grohith327/66e7233715e0d0b13fd1cc981f907ea4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.utils import shuffle | |
from sklearn.cross_validation import train_test_split | |
import numpy as np | |
## Drop rest of the features and extract the target values | |
df = df.drop(['SepalWidthCm','PetalWidthCm'],axis=1) | |
Y = [] | |
target = df['Species'] | |
for val in target: | |
if(val == 'Iris-setosa'): | |
Y.append(-1) | |
else: | |
Y.append(1) | |
df = df.drop(['Species'],axis=1) | |
X = df.values.tolist() | |
## Shuffle and split the data into training and test set | |
X, Y = shuffle(X,Y) | |
x_train = [] | |
y_train = [] | |
x_test = [] | |
y_test = [] | |
x_train, x_test, y_train, y_test = train_test_split(X, Y, train_size=0.9) | |
x_train = np.array(x_train) | |
y_train = np.array(y_train) | |
x_test = np.array(x_test) | |
y_test = np.array(y_test) | |
y_train = y_train.reshape(90,1) | |
y_test = y_test.reshape(10,1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment