def rf_max_depth():
    """Run evaluation of different RF max depths"""

    rf_10 = rf.RF(
        label = 'RF with max depth 10', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 100, 
        max_depth = 10
    )
    rf_100 = rf.RF(
        label = 'RF with max depth 100', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 100, 
        max_depth = 100
    )
    rf_250 = rf.RF(
        label = 'RF with max depth 250', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 100, 
        max_depth = 250
    )
    rf_1000 = rf.RF(
        label = 'RF with max depth 1000', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 100, 
        max_depth = 1000
    )
    rf_none = rf.RF(
        label = 'RF with no max depth', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 100, 
        max_depth = None
    )

    run_training_and_tests(
        'system_selection_3_rf_max_depth', 
        'kaggle', 
        [
            rf_10, 
            rf_100, 
            rf_250, 
            rf_1000, 
            rf_none
        ], 
        n_iterations = 5, n_images = 10000, training_split = 0.5
    )
def rf_forest_size():
    """Run evaluation of different RF sizes"""

    rf_1 = rf.RF(
        label = 'RF with 1 tree', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 1
    )
    rf_10 = rf.RF(
        label = 'RF with 10 trees', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 10
    )
    rf_50 = rf.RF(
        label = 'RF with 50 trees', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 50
    )
    rf_100 = rf.RF(
        label = 'RF with 100 trees', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 100
    )
    rf_250 = rf.RF(
        label = 'RF with 250 trees', 
        preprocessing = hsv_saturation, 
        features = [greyscale_histogram(bins = 64)], 
        n_estimators = 250
    )

    run_training_and_tests(
        'system_selection_3_rf_forest_size', 
        'kaggle', 
        [
            rf_1, 
            rf_10, 
            rf_50, 
            rf_100, 
            rf_250
        ], 
        n_iterations = 5, n_images = 10000, training_split = 0.5
    )
예제 #3
0
def run_experiment():
    """Run experiment one, testing performance on kaggle data"""

    optimal_svm = svm.SVM(label='Optimised SVM model',
                          preprocessing=hsv_saturation_threshold,
                          features=[haralick],
                          kernel='poly',
                          degree=3)

    optimal_rf = rf.RF(label='Optimised RF model',
                       preprocessing=hsv_saturation,
                       features=[greyscale_histogram(bins=64)],
                       n_estimators=100,
                       max_depth=100)

    run_training_and_tests('experiment_1_NLM_performance',
                           'kaggle', [optimal_rf, optimal_svm],
                           n_iterations=10,
                           n_training_images=5000,
                           n_test_images=20000)
def initial_grey_histogram_bins_evaluation():
    """Run evaluation of grey histogram bin sizes"""

    rf_model_grey2 = rf.RF(
        label='grey 2 bin RF',
        preprocessing=[],
        features=[greyscale_histogram(bins=2)]
    )

    rf_model_grey4 = rf.RF(
        label='grey 4 bin RF',
        preprocessing=[],
        features=[greyscale_histogram(bins=4)]
    )

    rf_model_grey8 = rf.RF(
        label='grey 8 bin RF',
        preprocessing=[],
        features=[greyscale_histogram(bins=8)]
    )

    rf_model_grey16 = rf.RF(
        label='grey 16 bin RF',
        preprocessing=[],
        features=[greyscale_histogram(bins=16)]
    )

    rf_model_grey32 = rf.RF(
        label='grey 32 bin RF',
        preprocessing=[],
        features=[greyscale_histogram(bins=32)]
    )

    rf_model_grey64 = rf.RF(
        label='grey 64 bin RF',
        preprocessing=[],
        features=[greyscale_histogram(bins=64)]
    )

    svm_model_grey2 = svm.SVM(
        label='grey 2 bin SVM',
        preprocessing=[],
        features=[greyscale_histogram(bins=2)]
    )

    svm_model_grey4 = svm.SVM(
        label='grey 4 bin SVM',
        preprocessing=[],
        features=[greyscale_histogram(bins=4)]
    )


    svm_model_grey8 = svm.SVM(
        label='grey 8 bin SVM',
        preprocessing=[],
        features=[greyscale_histogram(bins=8)]
    )

    svm_model_grey16 = svm.SVM(
        label='grey 16 bin SVM',
        preprocessing=[],
        features=[greyscale_histogram(bins=16)]
    )

    svm_model_grey32 = svm.SVM(
        label='grey 32 bin SVM',
        preprocessing=[],
        features=[greyscale_histogram(bins=32)]
    )

    svm_model_grey64 = svm.SVM(
        label='grey 64 bin SVM',
        preprocessing=[],
        features=[greyscale_histogram(bins=64)]
    )

    run_training_and_tests(
        'system_selection_1_hist_grey',
        'kaggle',
        [
            rf_model_grey2,
            rf_model_grey4,
            rf_model_grey8,
            rf_model_grey16,
            rf_model_grey32,
            rf_model_grey64,
            svm_model_grey2,
            svm_model_grey4,
            svm_model_grey8,
            svm_model_grey16,
            svm_model_grey32,
            svm_model_grey64
        ],
        n_iterations=5, n_images=10000, training_split=0.5
    )
def hist_hu_moments_haralick_evaluation():
    """Run comparative evaluation of hu moments, haralick texture
    attributes, colour histograms and greyscale histograms
    """

    rf_model_haralick = rf.RF(
        label='RF with haralick',
        preprocessing=[],
        features=[haralick]
    )

    rf_model_hu = rf.RF(
        label='RF with hu moments',
        preprocessing=[],
        features=[hu_moments]
    )

    rf_model_grey_hist = rf.RF(
        label='RF with grey hist',
        preprocessing=[],
        features=[greyscale_histogram(bins=64)]
    )

    rf_model_colour_hist = rf.RF(
        label='RF with colour hist',
        preprocessing=[],
        features=[colour_histogram(bins=16)]
    )

    svm_model_haralick = svm.SVM(
        label='SVM with haralick',
        preprocessing=[],
        features=[haralick]
    )

    svm_model_hu = svm.SVM(
        label='SVM with hu moments',
        preprocessing=[],
        features=[hu_moments]
    )

    svm_model_grey_hist = svm.SVM(
        label='SVM with grey hist',
        preprocessing=[],
        features=[greyscale_histogram(bins=64)]
    )

    svm_model_colour_hist = svm.SVM(
        label='SVM with colour hist',
        preprocessing=[],
        features=[colour_histogram(bins=16)]
    )

    run_training_and_tests(
        'system_selection_1_hist_hu_haralick',
        'kaggle',
        [
            rf_model_haralick,
            rf_model_hu,
            rf_model_grey_hist,
            rf_model_colour_hist,
            svm_model_haralick,
            svm_model_hu,
            svm_model_grey_hist,
            svm_model_colour_hist
        ],
        n_iterations=5, n_images=10000, training_split=0.5)
예제 #6
0
def greyscale_histogram_with_filters():
    """Run evaluation of greyscale histograms with filters"""

    rf_model_normal = rf.RF(label='RF with no preprocessing',
                            preprocessing=[],
                            features=[greyscale_histogram(bins=64)])

    rf_model_hsv = rf.RF(label='RF with hsv',
                         preprocessing=[hsv_model],
                         features=[greyscale_histogram(bins=64)])

    rf_model_hsv_is = rf.RF(label='RF with hsv and isolate saturation',
                            preprocessing=hsv_saturation,
                            features=[greyscale_histogram(bins=64)])

    rf_model_hsv_is_thresh = rf.RF(
        label='RF with hsv, isolate saturation, threshold',
        preprocessing=hsv_saturation_threshold,
        features=[greyscale_histogram(bins=64)])

    rf_model_hsv_is_c = rf.RF(
        label='RF with hsv, isolate saturation, contrast',
        preprocessing=hsv_saturation_contrast,
        features=[greyscale_histogram(bins=64)])

    svm_model_normal = svm.SVM(label='SVM with no preprocessing',
                               preprocessing=[],
                               features=[greyscale_histogram(bins=64)])

    svm_model_hsv = svm.SVM(label='SVM with hsv',
                            preprocessing=[hsv_model],
                            features=[greyscale_histogram(bins=64)])

    svm_model_hsv_is = svm.SVM(label='SVM with hsv and isolate saturation',
                               preprocessing=hsv_saturation,
                               features=[greyscale_histogram(bins=64)])

    svm_model_hsv_is_thresh = svm.SVM(
        label='SVM with hsv, isolate saturation, threshold',
        preprocessing=hsv_saturation_threshold,
        features=[greyscale_histogram(bins=64)])

    svm_model_hsv_is_c = svm.SVM(
        label='SVM with hsv, isolate saturation, contrast',
        preprocessing=hsv_saturation_contrast,
        features=[greyscale_histogram(bins=64)])

    run_training_and_tests('system_selection_2_grey_hist_preprocessing',
                           'kaggle', [
                               rf_model_normal,
                               rf_model_hsv,
                               rf_model_hsv_is,
                               rf_model_hsv_is_c,
                               rf_model_hsv_is_thresh,
                               svm_model_normal,
                               svm_model_hsv,
                               svm_model_hsv_is,
                               svm_model_hsv_is_c,
                               svm_model_hsv_is_thresh,
                           ],
                           n_iterations=5,
                           n_images=10000,
                           training_split=0.5)