def exp11(): """ Show correlation for each feature """ poems = getPoemModel().poems scores = {} scores["affect"] = getAffectRatios() scores["cLength"] = getLogAverageCommentLength() scores["rating"] = getPoemScores() scores["typeToken"] = getCommentTypeTokenRatio(100) scores["numC"] = getNumberOfComments(True) # use log result = {} for k1, v1 in scores.items(): for feature in poems.values()[0].keys(): cor, p = getCorrelation(poems, v1, feature) if result.get(feature, None) is None: result[feature] = {k1: (cor, p)} else: result[feature][k1] = (cor, p) for k1 in sorted(result.keys(), key=lambda x: result[x]["affect"][1]): # sort by affect print "\\\\", k1, "& %0.2f & %0.4f" % result[k1]["affect"], "& %0.2f & %0.4f" % result[k1][ "typeToken" ], "& %0.2f & %0.4f" % result[k1]["cLength"], "& %0.2f & %0.4f" % result[k1][ "rating" ], "& %0.2f & %0.4f" % result[ k1 ][ "numC" ]
def exp04(): """ Can we predict poem rating? No, it seems like we cannot predict it so well. """ m = getPoemModel() poems = m.poems scores = getPoemScores() makePlots(poems, scores, "poem score", "../experiments/exp04.pdf") runPredictCV(poems, scores, DEFAULT_FEATURE_LIST)