import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import p2funcs as p2f

vegetables = [
    "cucumber", "tomato", "lettuce", "asparagus", "potato", "wheat", "barley"
]
farmers = [
    "Farmer Joe", "Upland Bros.", "Smith Gardening", "Agrifun",
    "Organiculture", "BioGoods Ltd.", "Cornylee Corp."
]

harvest = np.array([[0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0],
                    [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0],
                    [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0],
                    [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0],
                    [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0],
                    [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1],
                    [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3]])

p2f.plot_mpl_heatmap(harvest,
                     vegetables,
                     farmers,
                     cmap="autumn",
                     cbarlabel="harvest [t/year]",
                     output='show')
Example #2
0
    opt_t2_gamma = 0

    for gamma in t2_gamma_list:

        amat_dict.update({gamma: []})

        t2_auc_mat, t2_kpcas, t2_models = p2f.m_test5_2_rocplot(
            toy_X_scaled, toy_y, gamma, toy_label, filepath, plotpath, 'tier1')

        amat_dict[gamma].append(t2_auc_mat)

        p2f.plot_mpl_heatmap(
            t2_auc_mat,
            t2_kpcas,
            t2_models,
            cmap="autumn",
            cbarlabel=
            "Mean area under ROC curve after 10-fold cross validation",
            output='save',
            path='%s%s_tier2_heatmap_gamma_%s.png' %
            (filepath, nowtime, gamma))

        p2f.js_heatmap(t2_auc_mat, t2_kpcas, t2_models,
                       "hmapgamma%s" % (gamma),
                       "%s%sheatmap_gamma%s.js" % (plotpath, nowtime, gamma))

        t2_mmas.append(np.mean(t2_auc_mat))

    amat_dict_list.append(amat_dict)

    # Select optimal t1 gamma
    for i in range(len(t2_mmas)):
Example #3
0
    print('\n### TIER 1 GRID SEARCH ###')

    for gamma in t1_gamma_list:

        amat_dict.update({gamma: []})

        t1_auc_mat, t1_kpcas, t1_models = p2f.m_test5_2_rocplot(
            toy_X_scaled, toy_y, gamma, toy_label, filepath, plotpath, 'tier1')

        amat_dict[gamma].append(t1_auc_mat)

        p2f.plot_mpl_heatmap(
            t1_auc_mat,
            t1_kpcas,
            t1_models,
            cmap="Oranges",
            cbarlabel=
            "Mean area under ROC curve after 10-fold cross validation",
            output='save',
            path='%s%s_tier1_gs' % (filepath, nowtime))

        t1_mmas.append(np.mean(t1_auc_mat))

    amat_dict_list.append(amat_dict)

    # Select optimal t1 gamma
    for i in range(len(t1_mmas)):
        if t1_mmas[i] > max_t1_mma:
            max_t1_mma = t1_mmas[i]
            opt_t1_gamma = t1_gamma_list[i]