def plotDSAgainst(nr): plt.close('all') nadja = createDataSetFromFile('nadja_'+str(nr)+'_fullSet.npz') line = createDataSetFromFile('line_'+str(nr)+'_fullSet.npz') stephan = createDataSetFromFile('stephan_'+str(nr)+'_fullSet.npz') nike = createDataSetFromFile('nike_'+str(nr)+'_fullSet.npz') julian = createDataSetFromFile('julian_'+str(nr)+'_fullSet.npz') nadja.plot(2,False) line.plot(2,False) #falsch stephan.plot(2,False) nike.plot(2,False) julian.plot(2,False) #falsch
def plotDSAgainst(nr): plt.close('all') nadja = createDataSetFromFile('nadja_' + str(nr) + '_fullSet.npz') line = createDataSetFromFile('line_' + str(nr) + '_fullSet.npz') stephan = createDataSetFromFile('stephan_' + str(nr) + '_fullSet.npz') nike = createDataSetFromFile('nike_' + str(nr) + '_fullSet.npz') julian = createDataSetFromFile('julian_' + str(nr) + '_fullSet.npz') nadja.plot(2, False) line.plot(2, False) #falsch stephan.plot(2, False) nike.plot(2, False) julian.plot(2, False) #falsch
def analyseDataSet(dataSetName): ds = createDataSetFromFile(dataSetName) signals = ds.getAllSignals() lengths = map(len,signals) power = map(normPower,signals) rot = map(normRot,signals) fused = map(normFused,signals) power_means = map(np.mean,power) rot_means = map(np.mean,rot) fused_means = map(np.mean,fused) print np.var(lengths) print np.var(power_means) print np.var(rot_means) print np.var(fused_means) return [np.var(lengths), np.var(power_means),np.var(rot_means),np.var(fused_means)]
def analyseDataSet(dataSetName): ds = createDataSetFromFile(dataSetName) signals = ds.getAllSignals() lengths = map(len, signals) power = map(normPower, signals) rot = map(normRot, signals) fused = map(normFused, signals) power_means = map(np.mean, power) rot_means = map(np.mean, rot) fused_means = map(np.mean, fused) print np.var(lengths) print np.var(power_means) print np.var(rot_means) print np.var(fused_means) return [ np.var(lengths), np.var(power_means), np.var(rot_means), np.var(fused_means) ]
def analyseBias(): dsNames = getAllDataSetNames() dataSets = [] for dsName in dsNames: dataSets.append(createDataSetFromFile(dsName)) meanDrifts = [] for gesture in range(0,10): signals = [] for dataSet in dataSets: signals.extend( dataSet.getAllSignals(gesture, 2)) signalSums = np.zeros((len(signals),9)) for i, signal in enumerate(signals): signalSums[i,:] = np.sum(signal[:,0:9],0) meanDrifts.append( np.mean(signalSums,0)) plt.figure() for meanDrift in meanDrifts: plt.plot(meanDrift) pass
def analyseBias(): dsNames = getAllDataSetNames() dataSets = [] for dsName in dsNames: dataSets.append(createDataSetFromFile(dsName)) meanDrifts = [] for gesture in range(0, 10): signals = [] for dataSet in dataSets: signals.extend(dataSet.getAllSignals(gesture, 2)) signalSums = np.zeros((len(signals), 9)) for i, signal in enumerate(signals): signalSums[i, :] = np.sum(signal[:, 0:9], 0) meanDrifts.append(np.mean(signalSums, 0)) plt.figure() for meanDrift in meanDrifts: plt.plot(meanDrift) pass
def plotGesturesVs(): pass #if __name__ == '__main__': ds1 = createDataSetFromFile('nadja_7_fullSet.npz') ds1signals = ds1.getAllSignals(7,2) ds2 = createDataSetFromFile('julian_7_fullSet.npz') ds2signals = ds2.getAllSignals(7,2) ds3 = createDataSetFromFile('julian_2_fullSet.npz') ds4 = createDataSetFromFile('julian_3_fullSet.npz') plt.switch_backend('Qt4Agg') axes, subs = plt.subplots(3, 1, True) print zip(map(len,ds1signals),map(len,ds2signals)) for i in range(0,3): label=['Gest. 1 X','Gest. 1 Y','Gest. 1 Z'] cmap = mpl.cm.Reds_r subs[0].plot(ds1signals[1][:,i] ,label=label[i] ,color=cmap(i / 3.0)) for i in range(0,3): label=['Gest. 2 X','Gest. 2 Y','Gest. 2 Z'] cmap = mpl.cm.Blues subs[0].plot(ds2signals[8][:,i] ,label=label[i] ,color=cmap((i+0.5) / 3.0)) subs[0].set_title('Fused') for i in range(3,6): label=['Gest. 1 X','Gest. 1 Y','Gest. 1 Z'] cmap = mpl.cm.Reds_r subs[1].plot(ds1signals[1][:,i] ,label=label[i-3] ,color=cmap((i-3) / 3.0)) for i in range(3,6): label=['Gest. 2 X','Gest. 2 Y','Gest. 2 Z'] cmap = mpl.cm.Blues subs[1].plot(ds2signals[8][:,i] ,label=label[i-3] ,color=cmap((i+1-3) / 3.0)) subs[1].set_title('Rotation') for i in range(6,9): label=['Gest. 1 X','Gest. 1 Y','Gest. 1 Z'] cmap = mpl.cm.Reds_r subs[2].plot(ds1signals[1][:,i] ,label=label[i-6] ,color=cmap((i-6) / 3.0)) for i in range(6,9): label=['Gest. 2 X','Gest. 2 Y','Gest. 2 Z'] cmap = mpl.cm.Blues subs[2].plot(ds2signals[8][:,i] ,label=label[i-6] ,color=cmap((i+1-6) / 3.0)) subs[2].set_title('Acceleration') subs[0].legend() subs[1].legend() subs[2].legend() for name in ['stephan','julian','nadja','line','nike']: ds1 = createDataSetFromFile(name+'_0_fullSet.npz') ds2 = createDataSetFromFile(name+'_1_fullSet.npz') ds3 = createDataSetFromFile(name+'_2_fullSet.npz') ds4 = createDataSetFromFile(name+'_3_fullSet.npz') plot3dFused([ds1, ds2,ds3,ds4],'Gyroscope trajectories for snap gestures') for j, signal in enumerate(createDataSetFromFile('nike_3_fullSet.npz').getAllSignals()): fig,axes = plt.subplots(2, 1, True) fused1 = signal[:,0:3] fusedInt1 = np.zeros(fused1.shape) fusedInt2 = np.zeros(fused1.shape) for i in range(1,fused1.shape[0]): fusedInt1[i] = np.sum(fused1[:i],0) fusedInt2[i] = fusedInt2[i-1]*0.95+fused1[i] axes[0].plot(fusedInt1) axes[1].plot(fusedInt2) plt.title(str(j))
totalTotalGestureRotation = [] totalTotalGestureAvgRotation = [] totalTotalGesturePerformer = [] lengthVariances = [] for gestureNr in range(0,10): totalSignalLengths = [] totalSignalPowers = [] totalSignalAvgPowers = [] totalSignalRotation = [] totalSignalAvgRotation = [] totalFileNames = [] totalGesturePerformer = [] for iFile in inputFiles: ds =createDataSetFromFile(iFile+'_'+str(gestureNr)+'_fullSet.npz') dataSets.append(ds) signals = ds.getAllSignals(gestureNr, 2) nSignals = len(signals) if nSignals > 0: signalLengths = np.zeros((nSignals,1)) signalPower = np.zeros((nSignals,1)) signalRotation = np.zeros((nSignals,1)) signalAvgPower = np.zeros((nSignals,1)) signalAvgRotation = np.zeros((nSignals,1)) for i in range(0,nSignals): signal = signals[i] #signal lenght rows, cols = signal.shape
def createGroundTruthCreation(): ds = createDataSetFromFile('julian_0_fullSet.npz')
def plotGesturesVs(): pass #if __name__ == '__main__': ds1 = createDataSetFromFile('nadja_7_fullSet.npz') ds1signals = ds1.getAllSignals(7, 2) ds2 = createDataSetFromFile('julian_7_fullSet.npz') ds2signals = ds2.getAllSignals(7, 2) ds3 = createDataSetFromFile('julian_2_fullSet.npz') ds4 = createDataSetFromFile('julian_3_fullSet.npz') plt.switch_backend('Qt4Agg') axes, subs = plt.subplots(3, 1, True) print zip(map(len, ds1signals), map(len, ds2signals)) for i in range(0, 3): label = ['Gest. 1 X', 'Gest. 1 Y', 'Gest. 1 Z'] cmap = mpl.cm.Reds_r subs[0].plot(ds1signals[1][:, i], label=label[i], color=cmap(i / 3.0)) for i in range(0, 3): label = ['Gest. 2 X', 'Gest. 2 Y', 'Gest. 2 Z'] cmap = mpl.cm.Blues subs[0].plot(ds2signals[8][:, i], label=label[i], color=cmap((i + 0.5) / 3.0)) subs[0].set_title('Fused') for i in range(3, 6): label = ['Gest. 1 X', 'Gest. 1 Y', 'Gest. 1 Z'] cmap = mpl.cm.Reds_r subs[1].plot(ds1signals[1][:, i], label=label[i - 3], color=cmap((i - 3) / 3.0)) for i in range(3, 6): label = ['Gest. 2 X', 'Gest. 2 Y', 'Gest. 2 Z'] cmap = mpl.cm.Blues subs[1].plot(ds2signals[8][:, i], label=label[i - 3], color=cmap((i + 1 - 3) / 3.0)) subs[1].set_title('Rotation') for i in range(6, 9): label = ['Gest. 1 X', 'Gest. 1 Y', 'Gest. 1 Z'] cmap = mpl.cm.Reds_r subs[2].plot(ds1signals[1][:, i], label=label[i - 6], color=cmap((i - 6) / 3.0)) for i in range(6, 9): label = ['Gest. 2 X', 'Gest. 2 Y', 'Gest. 2 Z'] cmap = mpl.cm.Blues subs[2].plot(ds2signals[8][:, i], label=label[i - 6], color=cmap((i + 1 - 6) / 3.0)) subs[2].set_title('Acceleration') subs[0].legend() subs[1].legend() subs[2].legend() for name in ['stephan', 'julian', 'nadja', 'line', 'nike']: ds1 = createDataSetFromFile(name + '_0_fullSet.npz') ds2 = createDataSetFromFile(name + '_1_fullSet.npz') ds3 = createDataSetFromFile(name + '_2_fullSet.npz') ds4 = createDataSetFromFile(name + '_3_fullSet.npz') plot3dFused([ds1, ds2, ds3, ds4], 'Gyroscope trajectories for snap gestures') for j, signal in enumerate( createDataSetFromFile('nike_3_fullSet.npz').getAllSignals()): fig, axes = plt.subplots(2, 1, True) fused1 = signal[:, 0:3] fusedInt1 = np.zeros(fused1.shape) fusedInt2 = np.zeros(fused1.shape) for i in range(1, fused1.shape[0]): fusedInt1[i] = np.sum(fused1[:i], 0) fusedInt2[i] = fusedInt2[i - 1] * 0.95 + fused1[i] axes[0].plot(fusedInt1) axes[1].plot(fusedInt2) plt.title(str(j))
totalTotalGestureRotation = [] totalTotalGestureAvgRotation = [] totalTotalGesturePerformer = [] lengthVariances = [] for gestureNr in range(0, 10): totalSignalLengths = [] totalSignalPowers = [] totalSignalAvgPowers = [] totalSignalRotation = [] totalSignalAvgRotation = [] totalFileNames = [] totalGesturePerformer = [] for iFile in inputFiles: ds = createDataSetFromFile(iFile + '_' + str(gestureNr) + '_fullSet.npz') dataSets.append(ds) signals = ds.getAllSignals(gestureNr, 2) nSignals = len(signals) if nSignals > 0: signalLengths = np.zeros((nSignals, 1)) signalPower = np.zeros((nSignals, 1)) signalRotation = np.zeros((nSignals, 1)) signalAvgPower = np.zeros((nSignals, 1)) signalAvgRotation = np.zeros((nSignals, 1)) for i in range(0, nSignals): signal = signals[i] #signal lenght rows, cols = signal.shape