Created
August 3, 2020 16:29
-
-
Save lisanka93/66b1e8fccec90eb0507f8938b40cb700 to your computer and use it in GitHub Desktop.
training naive bayes classifier and printing accuracy
This file contains hidden or 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
naive_bayes.fit(training_data,y_train) | |
predictions = naive_bayes.predict(testing_data) | |
# accuracy: 0.7391304347826086 | |
print('accuracy: {}'.format(accuracy_score(y_test, predictions))) | |
#using cross-validation | |
X_whole = count_vector.fit_transform(covid_data['prep_arg']) | |
y_whole = covid_data['concern'] | |
scores = cross_val_score(naive_bayes, X_whole, y_whole, cv=StratifiedShuffleSplit(n_splits=10, test_size=0.2, random_state=100)) | |
# 0.6652173913043478 | |
print(scores.mean()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment