In [257]:
from generate_samples import load_rnn_samples, load_human_samples

In [258]:
rnn_poems = load_rnn_samples()

In [259]:
human_poems = load_human_samples()

Evaluation


In [273]:
from evaluate import eval_poems
from rhyme import RhymeEvaluator
import pandas as pd
%matplotlib inline
%autoreload 2
%reload_ext autoreload

In [274]:
evaluator = RhymeEvaluator()

In [263]:
rnn_scores, rnn_mean, rnn_std = eval_poems(evaluator, rnn_poems)


Mean score = 0.766685714286, standard deviation = 0.308113787539

In [264]:
human_scores, human_mean, human_std = eval_poems(evaluator, human_poems)


Mean score = 0.894175, standard deviation = 0.184304499285

In [284]:
rnn_df = pd.DataFrame(rnn_scores, columns=['Combined Score'])

In [334]:
ax = rnn_df.plot(kind='hist', bins=100, figsize=(10, 10), legend=False, fontsize=14)
ax.set_xlabel('Combined Score', fontsize=20)
ax.set_ylabel('Frequency', fontsize=20)
ax.set_title('Score Distribution for Generated Sample', fontsize=24)


Out[334]:
<matplotlib.text.Text at 0x12e8f2dd0>

In [309]:
human_df = pd.DataFrame(human_scores, columns=['Combined Score'])

In [335]:
ax = human_df.plot(kind='hist', bins=100, figsize=(10, 10), legend=False, fontsize=14)
ax.set_xlabel('Combined Score', fontsize=20)
ax.set_ylabel('Frequency', fontsize=20)
ax.set_title('Score Distribution for Training Data Sample', fontsize=24)


Out[335]:
<matplotlib.text.Text at 0x12ed6d450>

Individual


In [265]:
poem = human_poems[0]
poem


Out[265]:
[u'\u60b2\u6b4c\u5f53\u54ed\u6709\u4f59\u60b2',
 u'\u4eca\u5915\u540c\u541b\u9189\u59cb\u77e5',
 u'\u5374\u501a\u80e1\u5e8a\u7981\u4e0d\u5f97',
 u'\u4e00\u65f6\u53cc\u6cea\u5815\u91d1\u536e']

In [275]:
evaluator.rhyme_util.get_poem_tone_types(poem)


Out[275]:
['pp*pz*p', 'p**pzz*', 'z*pp***', '*ppz**p']

In [246]:
(max_combined, max_tone, max_rhyme), scores = evaluator.eval(poem, output_all_scores=True, output_split=True)

In [249]:
(max_combined, max_tone, max_rhyme)


Out[249]:
(0.9464285714285714, 0.9642857142857143, 1.0)

In [251]:
scores


Out[251]:
[(0.9464285714285714, 0.8928571428571429, 1.0),
 (0.48214285714285715, 0.9642857142857143, 0.0),
 (0.8571428571428572, 0.7142857142857143, 1.0),
 (0.39285714285714285, 0.7857142857142857, 0.0)]