def main():
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1, projection='3d')
    param_values1 = list(range(1, 401))
    param_values2 = list(range(1, 31))
    file_name = '/media/nickyz/Data/scriptie_data/results/kalman_filter/trilateration/results_trilateration_{}_{}_{}.csv'
    results = []

    for i, param_value1 in enumerate(param_values1):
        for param_value2 in param_values2:
            try:
                results[i].append(
                    get_performance.main(
                        file_name.format(TIME_WINDOW, param_value1,
                                         param_value2), 'euc')[0])
            except IndexError:
                results.append([
                    get_performance.main(
                        file_name.format(TIME_WINDOW, param_value1,
                                         param_value2), 'euc')[0]
                ])

    min_tup = np.unravel_index(np.argmin(results), np.array(results).shape)
    print(np.min(results), np.max(results), param_values1[min_tup[0]],
          param_values2[min_tup[1]])
示例#2
0
def main():
    param_values1 = [float(i) for i in range(31, 51)]
    param_values2 = [float(i) for i in range(40001, 50001)]
    file_name = '/media/nickyz/Data/scriptie_data/results/dbl_irr_exp_filter/grid/sum/results_grid_normal_signal_sum_{}_{}_{}.csv'

    print('{')
    for window in TIME_WINDOWS:
        fig = plt.figure()
        ax = fig.add_subplot(1, 1, 1, projection='3d')
        results = []
        min_val = 10000000
        min_tup = None
        for i, param_value1 in enumerate(param_values1):
            for param_value2 in param_values2:
                new_val = get_performance.main(
                    file_name.format(window, param_value1, param_value2),
                    'euc')[0]
                if new_val < min_val:
                    min_val = new_val
                    min_tup = (param_value1, param_value2)
                # try:
                #     results[i].append(
                #         get_performance.main(file_name.format(window, param_value1, param_value2), 'euc')[0]
                #     )
                # except IndexError:
                #     results.append([get_performance.main(file_name.format(window, param_value1, param_value2), 'euc')[0]])

        # min_tup = np.unravel_index(np.argmin(results), np.array(results).shape)
        # print('            {}: ({}, {}),'.format(window, param_values1[min_tup[0]], param_values2[min_tup[1]]))
        print('            {}: ({}, {}),'.format(window, min_tup[0],
                                                 min_tup[1]))
        print(min_val)
    print('        }')
示例#3
0
def main():
    param_values = range(1, 36)

    file_names = [
        ('grid/std_estimation/results_grid_normal_signal_{}_{}.csv', 'Signal'),
        ('grid/std_estimation/results_grid_normal_frequency_{}_{}.csv',
         'Frequency'),
        ('grid/std_estimation/results_grid_normal_signal_sum_{}_{}.csv',
         'Signal Sum'),
    ]

    results = [[] for _ in file_names]

    for param_value in param_values:
        for i, file_name in enumerate(file_names):
            results[i].append(
                get_performance.main(
                    file_name[0].format(TIME_WINDOW, param_value), 'euc')[0])

    for i, file_name in enumerate(file_names):
        plt.plot(param_values, results[i])
        plt.xlabel('Variance')
        plt.ylabel('Average Euclidean Distance')
        plt.title(
            'Parameter plot to determine the standard deviation using the {}\n normal grid method and a time window of {}'
            .format(file_name[1], TIME_WINDOW))
        plt.show()
示例#4
0
def get_latex_table():
    results = {}
    for window in TIME_WINDOWS:
        base_files = get_files(window)

        for i, base_file in enumerate(base_files):
            dist, std = get_performance.main(base_file[0], 'euc')

            try:
                results[base_file[1]].append(dist)
            except KeyError:
                results[base_file[1]] = [dist]

    print('', end=" ")

    for window in TIME_WINDOWS:
        print('& ' + str(window), end=" ")

    print('\\\\')
    print('\\hline')

    for key in results:
        print(key, end=" ")

        for value in results[key]:
            print('& ' + str(round(value, 3)), end=" ")

        print('\\\\')
        print('\\hline')
示例#5
0
def main():
    param_values = range(0, 101)
    param_values = [param_value / 100 for param_value in param_values]

    file_names = [
        ('grid/alpha_estimation_signal/results_grid_normal_signal_{}_{}.csv',
         'Signal'),
        ('grid/alpha_estimation_frequency/results_grid_normal_frequency_{}_{}.csv',
         'Frequency'),
        ('grid/alpha_estimation_signal_sum/results_grid_normal_signal_sum_{}_{}.csv',
         'Signal Sum'),
    ]

    results = [[] for _ in file_names]

    for param_value in param_values:
        for i, file_name in enumerate(file_names):
            results[i].append(
                get_performance.main(
                    file_name[0].format(TIME_WINDOW, param_value), 'euc')[0])

    print(np.argmin(results[0]), np.argmin(results[1]), np.argmin(results[2]))

    for i, file_name in enumerate(file_names):
        plt.plot(param_values, results[i])
        plt.xlabel('Alpha')
        plt.ylabel('Average Euclidean Distance')
        plt.title(
            'Parameter plot to determine the alpha value using the {}\n normal grid method and a time window of {}'
            .format(file_name[1], TIME_WINDOW))
        plt.show()
示例#6
0
def main():
    param_values = [i for i in range(0, 41)]
    # results = []
    #
    # for param_value in param_values:
    #     results.append(
    #         get_performance.main(NAME.format(TIME_WINDOW, param_value), 'euc')[0]
    #     )
    #
    # # print(param_values[np.argmin(results)])
    #
    #
    # plt.plot(param_values, results)
    # plt.xlabel('Gamma')
    # plt.ylabel('Average Euclidean Distance')
    # plt.title('Parameter plot to determine the gamma for the trilateration method\n and a time window of {}'.format(TIME_WINDOW))
    # plt.show()
    #
    # results = []
    #
    # for param_value in param_values:
    #     results.append(
    #         get_performance.main('shift_' + NAME.format(TIME_WINDOW, param_value), 'euc')[0]
    #     )
    #
    # # print(param_values[np.argmin(results)])
    #
    #
    # plt.plot(param_values, results)
    # plt.xlabel('Gamma')
    # plt.ylabel('Average Euclidean Distance')
    # plt.title('Parameter plot to determine the gamma for the trilateration method\n and a time window of {}'.format(TIME_WINDOW))
    # plt.show()

    print('{')
    for window in TIME_WINDOWS:
        results = []

        for param_value in param_values:
            results.append(
                get_performance.main(NAME.format(window, param_value), 'euc')[0]
            )

        print('            {}: {},'.format(window, param_values[np.argmin(results)]))
    print('        }')
def main():
    param_values = [i / 100 for i in range(0, 301, 5)]
    file_name = 'trilateration/results_trilateration_{}_{}.csv'
    results = []

    for param_value in param_values:
        results.append(
            get_performance.main(file_name.format(TIME_WINDOW, param_value),
                                 'euc')[0])

    print(param_values[np.argmin(results)])

    plt.plot(param_values, results)
    plt.xlabel('Gamma')
    plt.ylabel('Average Euclidean Distance')
    plt.title(
        'Parameter plot to determine the gamma for the trilateration method\n and a time window of {}'
        .format(TIME_WINDOW))
    plt.show()
示例#8
0
def main():
    N = len(TIME_WINDOWS)
    results = []
    labels = ['Euclidean Distance', 'Method', 'Time Window']
    methods = []
    ps = []
    prev_length = 0

    for window in TIME_WINDOWS:
        base_files = get_files(window)
        methods = []

        for i, base_file in enumerate(base_files):
            dists = get_performance.main(base_file[0], 'euc', False)
            methods.append(base_file[2])

            # len_dif =
            # prev_length = len()

            for val in dists:
                results.append([val, base_file[1], window])

        # tri_shortness = len(part_results[0]) - len(part_results[-1])
        #
        # while tri_shortness > 0:
        #     part_results[-1].append(None)
        #     tri_shortness -= 1
        #
        # part_results.append([window for _ in part_results[0]])
        #
        # results += np.array(part_results).T.tolist()

    df = pd.DataFrame.from_records(results, columns=labels)

    g = sns.boxplot(x='Method',
                    y='Euclidean Distance',
                    hue='Time Window',
                    data=df)
    g.set_xticklabels(labels=methods, rotation=30)

    axes = g.axes
    axes.set_ylim(0, 40)
    plt.show()
示例#9
0
def main():
    param_values = [i / 10 for i in range(1, 1501)]
    file_name = 'irr_exp_filter/trilateration/results_trilateration_{}_{}.csv'

    print('{')
    for window in TIME_WINDOWS:
        results = []
        params = param_values
        for param_value in param_values:
            try:
                results.append(
                    get_performance.main(file_name.format(window, param_value),
                                         'euc')[0])
            except:
                if window == 60:
                    params = [i / 10 for i in range(1, 501)]
                else:
                    params = [i / 10 for i in range(1, 301)]
                break

        print('            {}: {},'.format(window,
                                           param_values[np.argmin(results)]))
    print('        }')
示例#10
0
def main():
    results = {}

    for time_window in TIME_WINDOWS:
        results[time_window] = {}
        filter_files = get_files(time_window)
        for i, filter_file in enumerate(filter_files):
            dist, std = get_performance.main(filter_file[0], 'euc')

            try:
                results[time_window][filter_file[1]][filter_file[2]] = dist
            except:
                results[time_window][filter_file[1]] = {filter_file[2]: dist}

    f, ((ax1, ax2, ax3, ax4), (ax5, ax6, ax7,
                               ax8)) = plt.subplots(2, 4, sharey='row')
    f.delaxes(ax8)

    filter_plot_map = {
        'Exponential': ax1,
        'Irregular Exponential': ax2,
        'Double Exponential': ax3,
        'Median': ax4,
        'Gauss Median': ax5,
        'Shift Median': ax6,
        'Kalman': ax7,
    }

    x_ticks = [
        'proxsig', 'proxfreq', 'proxsum', 'gridsig', 'gridfreq', 'gridsum',
        'normsumsig', 'normsumfreq', 'normsumsum', 'normhadsig', 'normhadfreq',
        'normhadsum', 'trilat'
    ]

    for time_window in results:
        for filter_method in filter_methods:
            subplot = filter_plot_map[filter_method]
            xs = []
            ys = []
            filter_results = results[time_window][filter_method]

            for base_method in x_ticks:
                xs.append(X_VALS[base_method])
                ys.append(filter_results[base_method])

            subplot.scatter(xs, ys, c=COLORS[time_window])
            subplot.set_xticks(xs)
            subplot.set_xticklabels(x_ticks)
            subplot.set_title(filter_method)
            plt.setp(subplot.xaxis.get_majorticklabels(), rotation=90)

    ax1.set_xticklabels([])
    ax2.set_xticklabels([])
    ax3.set_xticklabels([])
    ax1.set_ylim((0, 30))
    ax5.set_ylim((0, 30))
    ax1.set_ylabel('Average Euclidean Distance')
    ax5.set_ylabel('Average Euclidean Distance')
    ax7.legend(handles=LEGEND_ELEMENTS, bbox_to_anchor=(2.0, 0.4))

    plt.show()