Does anybody know how i can remove the error below?
NameError Traceback (most recent call last)
<ipython-input-31-d3625a93ead4> in <module>()
11 loo = LeaveOneOut(num_of_examples)
12 for train_index, test_index in loo:
---> 13 print("%s %s" % (train, test))
14
NameError: name 'train' is not defined
And the code that causing the error is like below:
from sklearn import datasets
import numpy as np
from sklearn.preprocessing import StandardScaler
iris = datasets.load_iris()
X = iris.data[:, [2, 3]]
y = iris.target
X, y
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
sc = StandardScaler()
sc.fit(X_train)
X_train_std = sc.transform(X_train)
X_test_std = sc.transform(X_test)
num_of_examples = len(X_train_std)
This is where i am getting error:
from sklearn.cross_validation import LeaveOneOut
loo = LeaveOneOut(num_of_examples)
for train_index, test_index in loo:
print("%s %s" % (train, test))