コード例 #1
0
def train_and_test(
    train_set,
    test_set,
    ontology,
    model,
    recreate_ontology,
    verbose,
):
    """ An aggregate command for both training and testing. """
    api.train(
        trainset_dir=os.path.abspath(train_set),
        ontology_path=os.path.abspath(ontology),
        model_path=os.path.abspath(model),
        recreate_ontology=recreate_ontology,
        verbose=verbose,
    )
    click.echo(u"Training completed successfully!")

    precision, recall, f1_score, accuracy = api.test(
        testset_path=os.path.abspath(test_set),
        ontology_path=os.path.abspath(ontology),
        model_path=os.path.abspath(model),
        recreate_ontology=recreate_ontology,
        verbose=verbose,
    )
    click.echo()
    click.echo(u"Precision: {0:.2f}%".format(precision * 100))
    click.echo(u"Recall: {0:.2f}%".format(recall * 100))
    click.echo(u"F1-score: {0:.2f}%".format(f1_score * 100))
    click.echo(u"Accuracy: {0:.2f}%".format(accuracy * 100))
コード例 #2
0
ファイル: cli.py プロジェクト: Rowl1ng/magpie
def train_and_test(
    train_set,
    test_set,
    ontology,
    model,
    recreate_ontology,
    verbose,
):
    """ An aggregate command for both training and testing. """
    api.train(
        trainset_dir=os.path.abspath(train_set),
        ontology_path=os.path.abspath(ontology),
        model_path=os.path.abspath(model),
        recreate_ontology=recreate_ontology,
        verbose=verbose,
    )
    click.echo(u"Training completed successfully!")

    precision, recall, f1_score, accuracy = api.test(
        testset_path=os.path.abspath(test_set),
        ontology_path=os.path.abspath(ontology),
        model_path=os.path.abspath(model),
        recreate_ontology=recreate_ontology,
        verbose=verbose,
    )
    click.echo()
    click.echo(u"Precision: {0:.2f}%".format(precision * 100))
    click.echo(u"Recall: {0:.2f}%".format(recall * 100))
    click.echo(u"F1-score: {0:.2f}%".format(f1_score * 100))
    click.echo(u"Accuracy: {0:.2f}%".format(accuracy * 100))
コード例 #3
0
def test(testset_dir, ontology, model, recreate_ontology, verbose):
    """ Test a model on a given dataset """
    precision, recall, f1_score, accuracy = api.test(
        testset_path=os.path.abspath(testset_dir),
        ontology_path=os.path.abspath(ontology),
        model_path=os.path.abspath(model),
        recreate_ontology=recreate_ontology,
        verbose=verbose,
    )
    click.echo()
    click.echo(u"Precision: {0:.2f}%".format(precision * 100))
    click.echo(u"Recall: {0:.2f}%".format(recall * 100))
    click.echo(u"F1-score: {0:.2f}%".format(f1_score * 100))
    click.echo(u"Accuracy: {0:.2f}%".format(accuracy * 100))
コード例 #4
0
ファイル: cli.py プロジェクト: Rowl1ng/magpie
def test(testset_dir, ontology, model, recreate_ontology, verbose):
    """ Test a model on a given dataset """
    precision, recall, f1_score, accuracy = api.test(
        testset_path=os.path.abspath(testset_dir),
        ontology_path=os.path.abspath(ontology),
        model_path=os.path.abspath(model),
        recreate_ontology=recreate_ontology,
        verbose=verbose,
    )
    click.echo()
    click.echo(u"Precision: {0:.2f}%".format(precision * 100))
    click.echo(u"Recall: {0:.2f}%".format(recall * 100))
    click.echo(u"F1-score: {0:.2f}%".format(f1_score * 100))
    click.echo(u"Accuracy: {0:.2f}%".format(accuracy * 100))