Exemplo n.º 1
0
def generate_toy(num_x):

    # get the x features
    df = DataFrame(np.random.randn(cts.num_examples, num_x), columns=util.get_feature_names(cts.x, num_x))
    df = concat([df, df.apply(lambda row: Series(util.get_labels(row)), axis=1)], axis=1)

    return df
Exemplo n.º 2
0
def plot_all(w_learned, data_df):

    for i in range(len(cts.w_rules[0, :])):

        (x1_line_rule, x2_line_rule) = get_plot_data(cts.w_rules[:, i], data_df)
        (x1_line_learned, x2_line_learned) = get_plot_data(w_learned[:, i], data_df)
        plt.plot(x1_line_rule, x2_line_rule, 'k-',
                 x1_line_learned, x2_line_learned, 'r-')

    n = int(math.pow(2, cts.num_c))

    for i in range(n):
        binary_string = get_binary_string(i)

        condition = True
        for index, name in enumerate(util.get_feature_names('c', cts.num_c)):
            condition &= (data_df[name] == int(binary_string[index]))

        my_filter = data_df[condition]
        plt.plot(my_filter[cts.x1], my_filter[cts.x2], 's', color=colorsys.hsv_to_rgb(*(i*1.0/n, 0.8, 0.8)))

    plt.show()
Exemplo n.º 3
0
def get_feature_names():
    response=jsonify({'features': util.get_feature_names()})
    response.headers.add('Access-Control-Allow-Origin', '*')
    return response