def train(directory='./training_data'): X, Y = load_measurements(directory) classifier = KnockClassifier() for x, y in izip(X, Y): classifier.addData(max_distance(smooth_3d_measurements(x)), y) classifier.fit() return classifier
def plot(measurements, label='movement'): mpl.rcParams['legend.fontsize'] = 10 smoothed = smooth_3d_measurements(measurements, 10) X, Y, Z = [], [], [] for x, y, z in smoothed: X += [x] Y += [y] Z += [z] fig = plt.figure() ax = fig.gca(projection='3d') ax.plot(X, Y, Z, label=label) ax.set_xlabel('X axis') ax.set_ylabel('Y axis') ax.set_zlabel('Z axis') ax.legend() plt.show()