def error_over_speed(tau, ws):
    speeds = np.arange(0.1, 0.9, 0.1)
    y = []
    for s in speeds:
        tg_var = TARGET(speed=s,
                        max_speed=0.8,
                        size=20,
                        peak_cell_num=peak_cell_num)
        can = CAN(target=tg_var,
                  size=20,
                  tau=tau,
                  dt=tau / 10,
                  kappa=0.1,
                  beta=-8,
                  ws_param=ws,
                  h=0)
        can.init_network_activity(peak_cell_num=peak_cell_num, init_time=1)
        can.run(sim_time=20)
        y.append(can.slope_accuracy(s, 20, peak_cell_num))
    fig, ax = plt.subplots()
    ax.xaxis.set_ticks_position('bottom')
    ax.set_title("Error in relation to speed [Tau=" + str(tau) + "][WS=" +
                 str(ws) + "]")
    ax.set_xlabel("Speed [m/s]")
    ax.set_ylabel("Error")
    plt.plot(speeds, y, 'r-')
    plt.ylim(-20, 20)
예제 #2
0
 def __init__(self):
     init()
     self.n = 0
     self.balls = []
     self.player = PLAYER()
     self.target = TARGET()
     self.target.new()
     display.set_caption('Ball Game')
     self.clock = time.Clock()
     self.Font = font.SysFont("arial", 40)
예제 #3
0
파일: test.py 프로젝트: Aganonce/TARGET
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler

from target import TARGET


def plot_pca(X):
    pca = PCA(n_components=2)
    X_r1 = pca.fit_transform(X)

    fig, ax = plt.subplots()
    for i in range(len(X_r1)):
        plt.scatter(X_r1[i][0], X_r1[i][1], c='r')

    plt.xlabel('x1')
    plt.ylabel('x2')
    plt.title('PCA on TARGET')
    plt.show()


if __name__ == '__main__':
    infile = 'data/small_sample.csv'

    start = time.time()
    target = TARGET(verbose=True, workers=2,
                    nodes_per_thread=2).train_csv(infile)
    print('Runtime:', time.time() - start)

    for c in target.resf_:
        X = StandardScaler().fit_transform(target.resf_[c])
        plot_pca(X)
from can import CAN
from target import TARGET
import numpy as np
import matplotlib.pyplot as plt
import os.path
import math

peak_cell_num = 15
speed = 0.2

tg = TARGET(speed=speed, max_speed=0.8, size=20, peak_cell_num=peak_cell_num)


def single_run():
    #tau 0.05, ws 0.08
    can = CAN(target=tg,
              size=20,
              tau=0.05,
              dt=0.005,
              kappa=0.1,
              beta=-8,
              ws_param=0.08,
              h=0)
    can.init_network_activity(peak_cell_num=peak_cell_num, init_time=1)
    can.run(sim_time=15)
    can.plot_activities(u_out=True)
    #print(can.slope_accuracy(speed,20,peak_cell_num))
    #can.plot_single_cell(speed,20,0)
    #plt.show()