コード例 #1
0
def run(ptrain=0.01, ptest=0.1, ntrain=-25, ntest=25):

    import os
    putil.LOG_FILE = os.path.join(LOG_FILE_DIR, 'ksvm.txt')

    main = Task(name="Kernel SVM",
                desc='Kernel Support Vector Machine Baseline').start()

    dataset, validation_tester = make_trainset(cores=None,
                                               main=main,
                                               ptrain=float(ptrain))
    testset, tester = make_testset(cores=None, main=main, ptest=float(ptest))

    ksvm = train(dataset, main.subtask(name="Training KSVM"))

    tester.loss(ksvm, task=main)
    validation_tester.loss(ksvm, task=main)

    main.done("Program finished.")
コード例 #2
0
    # Print out arguments
    print('\n')
    args.print()
    print('\n\n')

    # Run program
    div.div('-', BR + BLUE, label='Main Program')
    main = Task(name='RF',
                desc="Random Feature Support Vector Classifier").start()

    # Generate color map if flag set
    if args.get('knn'):
        ckm = CKM(
            args.get('k'),
            IDCDataset(PATIENTS, p=0.01, process=True, task=main.subtask()))
        idim = args.get('k')
        feature = ckm.map
    elif args.get('hsv'):
        from skimage import color
        idim = 7500

        def feature(image):
            return np.reshape(color.rgb2hsv(image), [-1])
    elif args.get('hue'):
        from skimage import color
        idim = 7500

        def feature(image):
            return np.reshape(color.rgb2hsv(image)[:, :, 0], [-1])
    else: