"""Pass a directory argument, read inputs, targets and predictions from that directory, and plot.""" executable = "../../../bin_test/testPerturbModelParameterLWR" if (not os.path.isfile(executable)): print "" print "ERROR: Executable '" + executable + "' does not exist." print "Please call 'make install' in the build directory first." print "" sys.exit(-1) fig_number = 1 directory = "/tmp/testPerturbModelParameterLWR/" # Call the executable with the directory to which results should be written command = executable + " " + directory #print command subprocess.call(command, shell=True) for dim in [1, 2]: fig = plt.figure(dim) cur_directory = directory + "/" + str(dim) + "D" if (getDataDimFromDirectory(cur_directory) == 1): ax = fig.gca() else: ax = Axes3D(fig) plotFunctionApproximatorTrainingFromDirectory(cur_directory, ax) plt.show()
fa_names = ["RBFN","GPR","IRFRLS","LWR", "LWPR", "GMR"] for fa_name in fa_names: # Call the executable with the directory to which results should be written command = executable+" "+directory+" "+fa_name #print command subprocess.call(command, shell=True) for fa_name in fa_names: print("Plotting "+fa_name+" results") fig = plt.figure(fig_number,figsize=(15,5)) fig_number = fig_number+1 for dim in [1, 2]: cur_directory = directory+fa_name+"_"+str(dim)+"D"; if (getDataDimFromDirectory(cur_directory)==1): ax = fig.add_subplot(1, 3, 1) ax2 = None else: ax = fig.add_subplot(1, 3, 2, projection='3d') ax2 = fig.add_subplot(1, 3, 3, projection='3d') plotFunctionApproximatorTrainingFromDirectory(cur_directory,ax,ax2) ax.set_title(fa_name+" ("+str(dim)+"D data)") if ax2 != None: ax2.set_title(fa_name+" ("+str(dim)+"D basis functions)") plt.show()
print "" sys.exit(-1); # Call the executable with the directory to which results should be written directory = "/tmp/demoTrainFunctionApproximators" subprocess.call([executable, directory]) # Plot the results in each directory function_approximator_names = ["WLS","LWR","LWPR","IRFRLS","GMR","RBFN","GPR"] fig_number = 1; for name in function_approximator_names: fig = plt.figure(fig_number) directory_fa = directory +"/"+ name if (getDataDimFromDirectory(directory_fa)==1): ax = fig.add_subplot(111) else: ax = fig.add_subplot(111, projection='3d') fig_number += 1; try: if (name=="WLS" or name=="LWR" or name=="LWPR" or name=="GMR"): plotLocallyWeightedLinesFromDirectory(directory_fa,ax) elif (name=="RBFN" or name=="GPR" or name=="IRFRLS"): plotBasisFunctionsFromDirectory(directory_fa,ax) plotDataFromDirectory(directory_fa,ax) ax.set_ylim(-1.0,1.5) except IOError: print "WARNING: Could not find data for function approximator "+name
# Call the executable with the directory to which results should be written directory = "/tmp/demoTrainFunctionApproximators" subprocess.call([executable, directory]) # Plot the results in each directory function_approximator_names = [ "WLS", "LWR", "LWPR", "IRFRLS", "GMR", "RBFN", "GPR" ] fig_number = 1 for name in function_approximator_names: fig = plt.figure(fig_number) directory_fa = directory + "/" + name if (getDataDimFromDirectory(directory_fa) == 1): ax = fig.add_subplot(111) else: ax = fig.add_subplot(111, projection='3d') fig_number += 1 try: if (name == "WLS" or name == "LWR" or name == "LWPR" or name == "GMR"): plotLocallyWeightedLinesFromDirectory(directory_fa, ax) elif (name == "RBFN" or name == "GPR" or name == "IRFRLS"): plotBasisFunctionsFromDirectory(directory_fa, ax) plotDataFromDirectory(directory_fa, ax) ax.set_ylim(-1.0, 1.5) except IOError:
def plotFunctionApproximatorTrainingFromDirectory(directory, ax): """zzz.""" plotDataFromDirectory(directory, ax) data_read_successfully = True cur_directory_number = 0 while data_read_successfully: cur_dir = directory + "/perturbation" + str(cur_directory_number) + "/" data_read_successfully = plotLocallyWeightedLinesFromDirectory(cur_dir, ax) cur_directory_number += 1 if __name__ == "__main__": """Pass a directory argument, read inputs, targets and predictions from that directory, and plot.""" if len(sys.argv) == 2: directory = str(sys.argv[1]) else: print "\nUsage: " + sys.argv[0] + " <directory> (data is read from directory)\n" sys.exit() fig = plt.figure() if getDataDimFromDirectory(directory) == 1: ax = fig.gca() else: ax = Axes3D(fig) plotFunctionApproximatorTrainingFromDirectory(directory, ax) plt.show()