def plotErrorResSize(): matplotlib.rcParams.update({'font.size': 25}) npzFile = '2016-04-28-09-57_bigRunOnlySnap.npz' npz2 = '2016-04-28-15-18_bigRunOnlySnap.npz' projectPath = 'C:\Users\Steve\Documents\Uni\BAThesis\\src\\errorResSize.pdf' pp = PdfPages(projectPath) a = np.load(getProjectPath()+npzFile) errors = a['errors'] errors = np.mean(errors,2).squeeze() b = np.load(getProjectPath()+npz2) errors2 = b['errors'] errors2 = np.mean(errors2,2).squeeze() plt.figure(figsize=(10,7.5)) plt.plot(errors, 'o', linestyle='-', linewidth=3, label='ridge para = 0.01') #plt.plot(errors2, 'o', linestyle='-', linewidth=3, label='ridge para = 0.1') plt.grid() plt.minorticks_on() plt.grid(which='minor', axis='y') plt.xlabel('Reservoir size') ticks = np.arange(0, 8) labels = [25,50,100,200,400,800,1600,3200] plt.xticks(ticks, labels) plt.ylabel('Validation error') plt.ylim(0,1) plt.tight_layout() pp.savefig() pp.close()
def writeToReportFile(text): print getProjectPath() + 'results/report.csv' with open(getProjectPath() + 'results/report.csv', 'ab') as csvfile: spamwriter = csv.writer(csvfile, delimiter=';', quotechar='|', quoting=csv.QUOTE_MINIMAL) spamwriter.writerow(text)
def createDataSetFromFile(fileName): data = np.load(getProjectPath()+'dataSets/'+fileName) fused = data['fused'] gyro = data['gyro'] acc = data['acc'] targets = data['targets'] means = data['means'] stds = data['stds'] gestures = data['gestures'] return DataSet(fused, gyro, acc, targets,means, stds, gestures)
def createDataSetFromFile(fileName): data = np.load(getProjectPath() + 'dataSets/' + fileName) fused = data['fused'] gyro = data['gyro'] acc = data['acc'] targets = data['targets'] means = data['means'] stds = data['stds'] gestures = data['gestures'] return DataSet(fused, gyro, acc, targets, means, stds, gestures)
def evaluateNPZ(npzFile): pp = PdfPages(getProjectPath()+"error_space_"+npzFile+".pdf") a = np.load(getProjectPath()+npzFile) plotMinErrors(a['errors'], a['params'], a['paraRanges'], pp, getSpecificColorMap()) i = 0 inputSignalAxis = -1 inputScalingAxis = -1 normAxis = -1 for node, param in a['params']: if param == 'spectral_radius': inputSignalAxis = i elif param == 'output_dim': inputScalingAxis = i elif param == 'ridge_param': normAxis = i i =i+1 plotAlongAxisErrors(a['errors'], a['params'], a['paraRanges'], normAxis, inputSignalAxis, inputScalingAxis, pp, getSpecificColorMap()) pp.close()
optDict = 'bestParas' #=========================================================================== # Pick datasets to train on, and datasets to test on #=========================================================================== inputFiles = ['nike', 'julian', 'nadja', 'line'] testFiles = ['stephan'] # If desired add a specific file to test on, e.g. randTestFiles = ['lana_0_0.npz'] randTestFiles = [] #=========================================================================== # Setup project directory #=========================================================================== now = datetime.datetime.now() resultsPath = getProjectPath() + 'results/' pdfFileName = now.strftime("%Y-%m-%d-%H-%M") + '_' + name + '.pdf' pdfFilePath = resultsPath + 'pdf/' + pdfFileName npzFileName = now.strftime("%Y-%m-%d-%H-%M") + '_' + name + '.npz' npzFilePath = resultsPath + 'npz/' + npzFileName bestFlowPath = resultsPath + 'nodes/' + now.strftime( "%Y-%m-%d-%H-%M") + '_' + name + '.p' pp = PdfPages(pdfFilePath) #=========================================================================== # Add labels for gestures #=========================================================================== totalGestureNames = ['left','right','forward','backward','bounce up','bounce down','turn left','turn right','shake lr','shake ud', \ 'tap 1','tap 2','tap 3','tap 4','tap 5','tap 6','no gesture'] gestureNames = [] for i in usedGestures:
def writeToFile(self, fileName): np.savez(getProjectPath()+'dataSets/'+fileName, \ fused=self.fused,gyro=self.gyro,acc=self.acc,targets=self.targets,means=self.means,stds=self.stds,gestures=self.gestures)
def writeToReportFile(text): print getProjectPath()+'results/report.csv' with open(getProjectPath()+'results/report.csv', 'ab') as csvfile: spamwriter = csv.writer(csvfile, delimiter=';', quotechar='|', quoting=csv.QUOTE_MINIMAL) spamwriter.writerow(text)
#=========================================================================== # Pick datasets to train on, and datasets to test on #=========================================================================== inputFiles = ['nike','julian','nadja','line'] testFiles = ['stephan'] # If desired add a specific file to test on, e.g. randTestFiles = ['lana_0_0.npz'] randTestFiles = [] #=========================================================================== # Setup project directory #=========================================================================== now = datetime.datetime.now() resultsPath = getProjectPath()+'results/' pdfFileName = now.strftime("%Y-%m-%d-%H-%M")+'_'+name+'.pdf' pdfFilePath = resultsPath+'pdf/'+pdfFileName npzFileName = now.strftime("%Y-%m-%d-%H-%M")+'_'+name+'.npz' npzFilePath = resultsPath+'npz/'+npzFileName bestFlowPath = resultsPath+'nodes/'+now.strftime("%Y-%m-%d-%H-%M")+'_'+name+'.p' pp = PdfPages(pdfFilePath) #=========================================================================== # Add labels for gestures #=========================================================================== totalGestureNames = ['left','right','forward','backward','bounce up','bounce down','turn left','turn right','shake lr','shake ud', \ 'tap 1','tap 2','tap 3','tap 4','tap 5','tap 6','no gesture'] gestureNames = [] for i in usedGestures: