def test_visualize(self): model_dir = os.path.abspath('../data/model/20160620-173927') create_checkpoint_file(model_dir, 'model.ckpt-500000') argv = [model_dir, '--model_def', 'models.nn4' ] args = visualize.parse_arguments(argv) visualize.main(args)
def main(): if len(sys.argv) <= 1: print("ERROR: Missing Arguments") printHelp() elif sys.argv[1] == "test": print("Flask Tests") suite = unittest.TestLoader().loadTestsFromModule(flask_tests) unittest.TextTestRunner(verbosity=0).run(suite) print("Module Tests") suite = unittest.TestLoader().loadTestsFromModule(module_tests) unittest.TextTestRunner(verbosity=0).run(suite) print("Inference Tests") suite = unittest.TestLoader().loadTestsFromModule(inference_tests) unittest.TextTestRunner(verbosity=0).run(suite) elif sys.argv[1] == "run": application.run() elif sys.argv[1] == "data": visualize.main() else: print("ERROR: Invalid Arguments") printHelp()
import gmplot if len(sys.argv) < 2: print "Usage: python", sys.argv[0], "mode" sys.exit() mode = int(sys.argv[1]) # mode 1 draws the scatter plot the old way from training data if mode == 1: with open("category_list.txt") as f: category_list = f.read().splitlines() for i in category_list: print (i) for year in range(2003, 2015 + 1): visualize.main("train.csv", i, year, draw_heatmap=False) # mode 2 takes a csv file(col0=timestamp, col1=lat, col2=lon) # and draws a scatter plot elif mode == 2: fname = sys.argv[2] csvfile = open(fname) csv = csv.reader(csvfile, delimiter=",") xlist = [] ylist = [] for row in csv: timestamp = float(row[0]) lat = float(row[1]) lon = float(row[2]) xlist.append(lat)
def test_main_runs(self): self.assertTrue(main())
def get_columns(in_file): #,reg_type): try: data = pd.read_csv(in_file, encoding='latin1') except: sys.exit( colored('File ' + str(in_file) + ' does not seem to be a valid CSV file', 'red', attrs=['bold'])) #selecting only numeric columns in selected file dataint = data[data.columns[data.dtypes == 'int64']] datafloat = data[data.columns[data.dtypes == 'float64']] #setting a dummy name for row index so the data can be merged based on this index data.index.name = 'dummy_index' data = pd.merge(dataint, datafloat, on='dummy_index') columns = data.columns print( colored('Numeric columns in file %s' % (in_file), 'blue', attrs=['bold'])) for i in range(len(columns)): #+1 so user does not need to type in 0 print( colored(str(i + 1) + '-' + columns[i] + ' ' + str(data[columns[i]].dtypes), 'green', attrs=['bold'])) inp = '' chosen_columns = [] while (inp != 'q'): inp = input( colored( 'Choose one column and press Enter or type in \'0\' to finish selecting. (Type in \'a\' to choose all columns at once) ', 'white', attrs=['bold'])) if (inp == 'a'): chosen_columns = list(columns) break elif (int(inp) == 0): break elif (int(inp) in range(1, len(columns) + 1)): data[columns[int(inp) - 1]] chosen_columns.append(columns[int(inp) - 1]) else: print( colored('Invalid column. Please, select a valid column name ', 'red', attrs=['bold'])) selected_data = data[chosen_columns] #Prompting user for what kind of regression to perform mod = '' print(colored("1 - Logistic\n2 - Linear", 'green', attrs=['bold'])) mod = int( input( colored("Which type of regression do you want to perform? ", 'white', attrs=['bold']))) while (1 > 0): if (mod == 1): reg_type = 'logistic' break elif (mod == 2): reg_type = 'linear' break else: print( colored( "Invalid option. Please, select [1] for logistic regression or [2] for linear regression ", 'red', attrs=['underline', 'bold'])) mod = int( input( colored( "Which type of regression do you want to perform? ", 'cyan', attrs=['bold']))) check_data(selected_data, reg_type) print(colored("Chosen columns:", 'blue', attrs=['bold'])) for i in range(len(chosen_columns)): print( colored(str(i + 1) + '-' + chosen_columns[i], 'green', attrs=['bold'])) #asks the user for the dependent variable column target = int( input(colored('Choose the target column ', 'white', attrs=['bold']))) tar = selected_data[chosen_columns[target - 1]] target_name = chosen_columns[target - 1] print( colored("You chose '" + str(chosen_columns[target - 1]) + "' as your target column ", 'yellow', attrs=['bold'])) #removing target column from the chosen columns list, so the function can return x and y arrays separately chosen_columns.pop(target - 1) final_data = pd.DataFrame(selected_data[chosen_columns]) check_data(selected_data, reg_type) #plotting features against target column plo = '' plo = str( input( colored( "Do you want to visualize your data before analyzing it? [y/n]", 'white', attrs=['bold']))) #mod = int(input(colored("Which type of regression do you want to perform? ",'white',attrs=['bold']))) while (1 > 0): if (plo == 'y'): vi.main(final_data, tar) break elif (plo == 'n'): #reg_type = 'linear' break else: print( colored("Invalid option. Please, select y or n ", 'red', attrs=['underline', 'bold'])) plo = str( input( colored( "Do you want to visualize your data before analyzing it? [y/n] ", 'cyan', attrs=['bold']))) #adding bias column to x array add_bias(final_data) chosen_columns.insert(0, 'bias') return np.array(final_data), np.array( tar), reg_type, chosen_columns, target_name
try: pygame.display.quit() except: return running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False try: solve() except: running = False running = True pygame.init() pygame.display.init() while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False visualize.main() with open("solution.txt", "w") as file: file.write("") quit()
v = np.full((n, 1), .001) #each point will assign velocities to each of those points #v = np.random.uniform(0,0.01,n).reshape(-1,1) #each point should be assigned two other points at random rows_v12 = np.apply_along_axis(other_vertex_rows, 1, np.arange(n).reshape(-1, 1)) coords = tc.triangle_coords( n, p0, rows_v12 ) #instantiation of class for calculating point positions, and initialization of positions for each point #coords.step(dist_p0=v, personal_space=personal_space) #during each generation each point moves by dist_p0 with the objective of forming an equilateral triangle visualize.main( triangle_coords=coords, dist_p0=v, personal_space=personal_space, plt_type=plt_type ) #visualize points moving through successive calls of the coords.step() method ''' #Functionality to add: #points should be constrained such that their initial positions do not overlap or collide (i.e., no closer than a certain margin away from each other) #better visualization of triangles created by each triple (p0,p1,p2), perhaps overlapping with points #e.g., perhaps color-coding triangles according to whether they have reached equilateral shape #implement an option in step() method for a different objective, e.g.: step(objective) #..whereby the objective is for a point to move to a position where it is equidistant to each of the other two points #..therefore it should move to the closest position between itself and the maximal margin hyperspace between the other two points