LeaveOneOut Cross Validation in scikit learn -


does know how can remove error below?

nameerror                                 traceback (most recent call last) <ipython-input-31-d3625a93ead4> in <module>()      11 loo = leaveoneout(num_of_examples)      12 train_index, test_index in loo: ---> 13     print("%s %s" % (train, test))      14   nameerror: name 'train' not defined 

and code causing error below:

from sklearn import datasets import numpy np sklearn.preprocessing import standardscaler  iris = datasets.load_iris() x = iris.data[:, [2, 3]] y = iris.target x, y 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 getting error:

from sklearn.cross_validation import leaveoneout loo = leaveoneout(num_of_examples) train_index, test_index in loo:     print("%s %s" % (train, test)) 

you didn't define train , test in code. if want print train_index , test_index should do:

from sklearn.cross_validation import leaveoneout loo = leaveoneout(num_of_examples) train_index, test_index in loo:     print("%s %s" % (train_index, test_index)) 

in addition, this documentation may relevant.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -