def test_opt_model(): query = 'test' all_questions = geoserver_interface.download_questions(query) all_syntax_parses = questions_to_syntax_parses(all_questions) all_annotations = geoserver_interface.download_semantics(query) all_labels = geoserver_interface.download_labels(query) (tr_s, tr_a, tr_q), (te_s, te_a, te_q) = split([all_syntax_parses, all_annotations, all_questions], 0.5) tm = train_tag_model(all_syntax_parses, all_annotations) cm = train_semantic_model(tm, tr_s, tr_a) # te_m = questions_to_match_parses(te_q, all_labels) prs = evaluate_opt_model(cm, te_s, te_a, all_questions, np.linspace(-2, 2, 21)) ps, rs = zip(*prs.values()) plt.plot(prs.keys(), ps, 'o', label='precision') plt.plot(prs.keys(), rs, 'o', label='recall') plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) plt.show()
def test_rule_model(): query = 'test' all_questions = geoserver_interface.download_questions(query) all_syntax_parses = questions_to_syntax_parses(all_questions) all_annotations = geoserver_interface.download_semantics(query) all_labels = geoserver_interface.download_labels(query) (tr_s, tr_a), (te_s, te_a) = split((all_syntax_parses, all_annotations), 0.5) tm = train_tag_model(all_syntax_parses, all_annotations) cm = train_semantic_model(tm, tr_s, tr_a) unary_prs, core_prs, is_prs, cc_prs, core_tree_prs = evaluate_rule_model( cm, te_s, te_a, np.linspace(0, 1, 101)) plt.plot(core_tree_prs.keys(), core_tree_prs.values(), 'o') plt.show() plt.plot(unary_prs.keys(), unary_prs.values(), 'o') plt.show() plt.plot(core_prs.keys(), core_prs.values(), 'o') plt.show() plt.plot(is_prs.keys(), is_prs.values(), 'o') plt.show() plt.plot(cc_prs.keys(), cc_prs.values(), 'o') plt.show()
def test_opt_model(): query = 'test' all_questions = geoserver_interface.download_questions(query) all_syntax_parses = questions_to_syntax_parses(all_questions) all_annotations = geoserver_interface.download_semantics(query) all_labels = geoserver_interface.download_labels(query) (tr_s, tr_a, tr_q), (te_s, te_a, te_q) = split([all_syntax_parses, all_annotations, all_questions], 0.5) tm = train_tag_model(all_syntax_parses, all_annotations) cm = train_semantic_model(tm, tr_s, tr_a) # te_m = questions_to_match_parses(te_q, all_labels) prs = evaluate_opt_model(cm, te_s, te_a, all_questions, np.linspace(-2,2,21)) ps, rs = zip(*prs.values()) plt.plot(prs.keys(), ps, 'o', label='precision') plt.plot(prs.keys(), rs, 'o', label='recall') plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) plt.show()
def test_rule_model(): query = 'test' all_questions = geoserver_interface.download_questions(query) all_syntax_parses = questions_to_syntax_parses(all_questions) all_annotations = geoserver_interface.download_semantics(query) all_labels = geoserver_interface.download_labels(query) (tr_s, tr_a), (te_s, te_a) = split((all_syntax_parses, all_annotations), 0.5) tm = train_tag_model(all_syntax_parses, all_annotations) cm = train_semantic_model(tm, tr_s, tr_a) unary_prs, core_prs, is_prs, cc_prs, core_tree_prs = evaluate_rule_model(cm, te_s, te_a, np.linspace(0,1,101)) plt.plot(core_tree_prs.keys(), core_tree_prs.values(), 'o') plt.show() plt.plot(unary_prs.keys(), unary_prs.values(), 'o') plt.show() plt.plot(core_prs.keys(), core_prs.values(), 'o') plt.show() plt.plot(is_prs.keys(), is_prs.values(), 'o') plt.show() plt.plot(cc_prs.keys(), cc_prs.values(), 'o') plt.show()