Closed xiejiachen closed 8 years ago
In test.py you can change the variable data_set_slice to 800 to make the code use the first 800 data points as the training set, and set aside the remaining data points as the test set.
To print all the predictions, you can iterate over all the data points at the end of the script and print the result of calling classifier.predict(data_point).
error report: 'NaiveBayesClassifier' object has no attribute 'predict'
After checking source codes carefully, i remain not found function predict....
My mistake. I meant "classify"
Is that convenient for you to just give an out example, really thanks!
classifier = nb.NaiveBayesClassifier(featurizer) classifier.train(training_set[0], training_set[1]) for data_point in test_set[0]: print classifier.classify(data_point)
Hi, author.
If we let first 800 rows as train data, and last 200 rows as test data, how to output the prediction results both with train data and test data?
Yours