Skip to content

Instantly share code, notes, and snippets.

@lisanka93
Created August 3, 2020 16:29
Show Gist options
  • Save lisanka93/66b1e8fccec90eb0507f8938b40cb700 to your computer and use it in GitHub Desktop.
Save lisanka93/66b1e8fccec90eb0507f8938b40cb700 to your computer and use it in GitHub Desktop.
training naive bayes classifier and printing accuracy
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