Skip to content

Instantly share code, notes, and snippets.

@MarynaLongnickel
Created June 16, 2018 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarynaLongnickel/14e6abbc3e598152fb46caf2914f367d to your computer and use it in GitHub Desktop.
Save MarynaLongnickel/14e6abbc3e598152fb46caf2914f367d to your computer and use it in GitHub Desktop.
train, test = train_test_split(data, test_size = 0.3)
cols = train.columns[:-1]
gnb = MultinomialNB()
gnb.fit(train[cols], train['sentiment'])
y_pred = gnb.predict(test[cols])
print("Number of mislabeled points out of a total {} points : {}, performance {:05.2f}%"
.format(
test.shape[0],
(test["sentiment"] != y_pred).sum(),
100*(1-(test["sentiment"] != y_pred).sum()/test.shape[0])
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment