June 2016
Beginner to intermediate
304 pages
6h 24m
English
Let's see how to split our data properly into training and testing datasets.
from sklearn import cross_validation X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.25, random_state=5) classifier_gaussiannb_new = GaussianNB() classifier_gaussiannb_new.fit(X_train, y_train)
Here, we allocated 25% of the data for testing, as specified by the test_size parameter. The remaining 75% of the data will be used for training.
y_test_pred = classifier_gaussiannb_new.predict(X_test)
accuracy = 100.0 ...