Пример #1
0
def run(classifier1, classifier2):
    parser = LC_QaudParser()
    query_builder = Orchestrator(None, classifier1, classifier2, parser, auto_train=False)

    print "train_question_classifier"
    scores = query_builder.train_question_classifier(file_path="../data/LC-QUAD/data_v8.json", test_size=0.5)
    print scores
    y_pred = query_builder.question_classifier.predict(query_builder.X_test)
    print(classification_report(query_builder.y_test, y_pred))

    print "double_relation_classifer"
    scores = query_builder.train_double_relation_classifier(file_path="../data/LC-QUAD/data_v8.json", test_size=0.5)
    print scores
    y_pred = query_builder.double_relation_classifer.predict(query_builder.X_test)
    print(classification_report(query_builder.y_test, y_pred))
Пример #2
0
if __name__ == "__main__":
    args = Struct()
    base_path = "./learning/treelstm/"
    args.save = os.path.join(base_path, "checkpoints/")
    args.expname = "lc_quad"
    args.mem_dim = 150
    args.hidden_dim = 50
    args.num_classes = 2
    args.input_dim = 300
    args.sparse = ""
    args.lr = 0.01
    args.wd = 1e-4
    args.data = os.path.join(base_path, "data/lc_quad/")
    args.cuda = False

    parser = LC_QaudParser()
    kb = parser.kb

    base_dir = "./output"
    question_type_classifier_path = os.path.join(base_dir,
                                                 "question_type_classifier")
    utility.makedirs(question_type_classifier_path)
    question_type_classifier = SVMClassifier(
        os.path.join(question_type_classifier_path, "svm.model"))

    o = Orchestrator(None, question_type_classifier, None, parser, True)
    raw_entities = [{
        "surface":
        "",
        "uris": [{
            "confidence": 1,