Esempio n. 1
0
    print Z.shape
    s = 0
    print Z[0, 0]
    print Z[399, 399]
    for x in range(400):
        for y in range(400):
            s = s + Z[x, y]
    print s
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.get_cmap("coolwarm"), linewidth=0, antialiased=True)
    fig.colorbar(surf, shrink=0.5, aspect=5)

    #    plt.savefig('3dgauss.png')
    #    plt.clf()

    plt.show()


if __name__ == "__main__":
    headers, attacks = preprocessing.get_header_data()
    headers.remove("protocol_type")
    headers.remove("attack")
    headers.remove("difficulty")

    df_training_20, df_training_full, gmms_20, gmms_full = preprocessing.get_preprocessed_training_data()
    df_test_20, df_test_full, gmms_test_20, gmms_test_full = preprocessing.get_preprocessed_test_data()

    title = "training20_only"
    logger.debug("#################################################")
    logger.debug(title)
    test()
            df_abnormal.drop('protocol_type', 1, inplace=True)
            df_abnormal.reset_index(drop=True)
            df_abnormal = df_abnormal[0:10]

            gmm_normals_protcl = gmms[0][protocol_index]
            gmm_abnormals_protcl = gmms[1][protocol_index]
            gmms_protcl = [gmm_normals_protcl, gmm_abnormals_protcl]

            generate_plots(df_abnormal,
                           df_normal,
                           headers,
                           gmms_protcl,
                           attack_type,
                           path=path,
                           protcls_name=protocol_type)


if __name__ == '__main__':
    import time
    start = time.time()

    df_training_20, df_training_full, gmms_training_20, gmms_training_full = preprocessing.get_preprocessed_training_data(
    )
    df_test_plus, df_test_21, gmms_test_plus, gmms_test_21 = preprocessing.get_preprocessed_test_data(
    )

    generate_plots_for_df(df_training_20, gmms_training_20, "training20")
    generate_plots_for_df(df_training_full, gmms_training_full, "trainingfull")
    generate_plots_for_df(df_test_plus, gmms_test_plus, "testplus")
    generate_plots_for_df(df_test_21, gmms_test_21, "test21")
Esempio n. 3
0
                           Y,
                           Z,
                           rstride=1,
                           cstride=1,
                           cmap=plt.get_cmap('coolwarm'),
                           linewidth=0,
                           antialiased=True)
    fig.colorbar(surf, shrink=0.5, aspect=5)

    #    plt.savefig('3dgauss.png')
    #    plt.clf()

    plt.show()


if __name__ == '__main__':
    headers, attacks = preprocessing.get_header_data()
    headers.remove('protocol_type')
    headers.remove('attack')
    headers.remove('difficulty')

    df_training_20, df_training_full, gmms_20, gmms_full = preprocessing.get_preprocessed_training_data(
    )
    df_test_20, df_test_full, gmms_test_20, gmms_test_full = preprocessing.get_preprocessed_test_data(
    )

    title = "training20_only"
    logger.debug("#################################################")
    logger.debug(title)
    test()
            df_abnormal = df_abnormal[(df_abnormal["attack"] == i)] # only select for 1 class 
            df_abnormal = df_abnormal[(df_abnormal["protocol_type"] == protocol_index)]

            if 1 >  len(df_abnormal) :
                continue

            df_abnormal.drop('attack',1,inplace=True) # remove useless 
            df_abnormal.drop('difficulty',1,inplace=True) # remove useless 
            df_abnormal.drop('protocol_type',1,inplace=True)
            df_abnormal.reset_index(drop=True)
            df_abnormal = df_abnormal[0:10]

            gmm_normals_protcl = gmms[0][protocol_index]
            gmm_abnormals_protcl = gmms[1][protocol_index]
            gmms_protcl = [gmm_normals_protcl, gmm_abnormals_protcl]

            generate_plots(df_abnormal, df_normal, headers, gmms_protcl, attack_type, path=path, protcls_name = protocol_type)

if __name__ == '__main__':
    import time
    start = time.time()

    df_training_20, df_training_full, gmms_training_20, gmms_training_full = preprocessing.get_preprocessed_training_data()
    df_test_plus, df_test_21, gmms_test_plus, gmms_test_21 = preprocessing.get_preprocessed_test_data()

    generate_plots_for_df(df_training_20, gmms_training_20, "training20")
    generate_plots_for_df(df_training_full, gmms_training_full, "trainingfull")
    generate_plots_for_df(df_test_plus, gmms_test_plus, "testplus")
    generate_plots_for_df(df_test_21, gmms_test_21, "test21")