Skip to content

Commit

Permalink
add sentiment unit histogram vis
Browse files Browse the repository at this point in the history
  • Loading branch information
openai-sys-okta-integration committed Jul 12, 2017
1 parent 83d940d commit 9b8b1ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sst_binary_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from encoder import Model
from matplotlib import pyplot as plt
from utils import sst_binary, train_with_reg_cv

model = Model()
Expand All @@ -8,7 +9,15 @@
vaXt = model.transform(vaX)
teXt = model.transform(teX)

# classification results
full_rep_acc, c, nnotzero = train_with_reg_cv(trXt, trY, vaXt, vaY, teXt, teY)
print('%05.2f test accuracy'%full_rep_acc)
print('%05.2f regularization coef'%c)
print('%05d features used'%nnotzero)

# visualize sentiment unit
sentiment_unit = trXt[:, 2388]
plt.hist(sentiment_unit[trY==0], bins=25, alpha=0.5, label='neg')
plt.hist(sentiment_unit[trY==1], bins=25, alpha=0.5, label='pos')
plt.legend()
plt.show()

0 comments on commit 9b8b1ae

Please sign in to comment.