Esempio n. 1
0
def n_fold_cv(n, samples, labels):
    (sample_groups, sample_labels) = split_groups(n, samples, labels)

    p = {}
    r = {}
    sz = {}

    for i in range(n):
        train_samples = [
            x for j in range(n) if j != i for x in sample_groups[j]
        ]
        train_labels = [
            x for j in range(n) if j != i for x in sample_labels[j]
        ]

        test_samples = sample_groups[i]
        test_labels = sample_labels[i]

        algs = ml.run(train_samples, train_labels, test_samples, test_labels)

        for alg in algs:
            key = alg.__class__.__name__
            if key not in p:
                p[key] = 0.0
                r[key] = 0.0

            p[key] += alg.P()
            r[key] += alg.R()

    fmt = "{0:30}{1:<20}{2:<20}"
    print "N-fold Cross Validation:\n----------------------------------------"
    print fmt.format("Algo", "P", "R")
    for key in p.keys():
        print fmt.format(key, p[key] / n, r[key] / n)
Esempio n. 2
0
def run_test(train_samples, train_labels, test_samples, test_labels):
    algs = ml.run(train_samples, train_labels, test_samples, test_labels)

    print ""

    fmt = "{0:30}{1:<20}{2:<20}"
    print "Test set results:\n----------------------------------------"
    print fmt.format("Algo", "P", "R")
    for alg in algs:
        key = alg.__class__.__name__
        print fmt.format(key, alg.P(), alg.R())
Esempio n. 3
0
def generete_embeddings(code):
    # printAst(*parse(code))
    parser_res = parse(code)
    emb = ml.run(parser_res)
    return emb
Esempio n. 4
0
def test(request):
    animal = ml.run()
    print(animal)
    return HttpResponse(animal)
Esempio n. 5
0
File: train.py Progetto: necla-ml/ML
                        type=int,
                        help='print frequency')
    parser.add_argument('--output-dir',
                        default='data/coco/checkpoints',
                        help='path where to save')
    parser.add_argument('--resume', default='', help='resume from checkpoint')
    parser.add_argument('--aspect-ratio-group-factor', default=0, type=int)
    parser.add_argument(
        "--test-only",
        dest="test_only",
        help="Only test the model",
        action="store_true",
    )
    parser.add_argument(
        "--pretrained",
        dest="pretrained",
        help="Use pre-trained models from the modelzoo",
        action="store_true",
    )

    # distributed training parameters
    #parser.add_argument('--world-size', default=2, type=int, help='number of distributed processes')
    #parser.add_argument('--dist-url', default='env://', help='url used to set up distributed training')

    args = parser.parse_args()

    if args.output_dir:
        utils.mkdir(args.output_dir)

    ml.run(main, args, name='train')