some improvements
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -68,7 +68,7 @@ def sentiment_score(s):
|
||||
#(pos, neg, neu)^T
|
||||
return s[0] - s[1]
|
||||
|
||||
def plot_sentiment_space(predicted_sentiment_vectors, top_sentiments, top_emojis, style='bo'):
|
||||
def plot_sentiment_space(predicted_sentiment_vectors, top_sentiments, top_emojis, style='bo', additional_patches = None):
|
||||
# sentiment score axis
|
||||
top_X = np.array([sentiment_score(x) for x in top_sentiments])
|
||||
pred_X = np.array([sentiment_score(x) for x in predicted_sentiment_vectors])
|
||||
@ -86,6 +86,9 @@ def plot_sentiment_space(predicted_sentiment_vectors, top_sentiments, top_emojis
|
||||
for i in range(len(top_X)):
|
||||
plt.text(top_X[i], top_Y[i], top_emojis[i])
|
||||
plt.plot(pred_X, pred_Y, style)
|
||||
for p_tuple in additional_patches:
|
||||
ax_1.add_artist(p_tuple[0])
|
||||
p_tuple[0].set_alpha(0.4)
|
||||
plt.savefig("val-error_sentiment-plot" + str(datetime.datetime.now()) + ".png", bbox_inches='tight')
|
||||
|
||||
# sentiment score axis
|
||||
@ -105,6 +108,9 @@ def plot_sentiment_space(predicted_sentiment_vectors, top_sentiments, top_emojis
|
||||
for i in range(len(top_X)):
|
||||
plt.text(top_X[i], top_Y[i], top_emojis[i])
|
||||
plt.plot(pred_X, pred_Y, style)
|
||||
for p_tuple in additional_patches:
|
||||
ax_2.add_artist(p_tuple[1])
|
||||
p_tuple[1].set_alpha(0.4)
|
||||
plt.savefig("val-error_positive-negative-plot" + str(datetime.datetime.now()) + ".png", bbox_inches='tight')
|
||||
plt.show()
|
||||
|
||||
|
Reference in New Issue
Block a user