def plot(self): plot_scatter(None, self.data_x, self.data_y, size=20, pch='x', colour="red", title=self.name)
def display(self): plot_hist(list(self.knockouts_hist), title="Knockout size distribution", colour="blue") lines = [ "%s, %s" % (x, y) for x, y in zip(self.solution.solutions['Size'], self.solution.solutions['Fitness']) ] plot_scatter( lines, None, None, 20, "*", "blue", "Correlation between number of knockouts and fitness")
def handle(self) -> None: g2v = Garm2Vec() filepath = self.argument("filepath") full_filepath = os.path.abspath(os.path.expanduser(filepath)) description = self.argument("description") vector = g2v.get_one([full_filepath, description]) data = [f"{x},{y}" for x, y in enumerate(vector)] plot_scatter( f=data, xs=None, ys=None, title="Garm2Vec", pch="o", size=40, colour="default", )
def scatter(x_data, y_data, title, n_points=None): """ x_data: iterable of floats X data to plot y_data: iterable of floats Y data to plot title: string Title of the graph n_points: int How many of points (most recent) to plot. If None, plot all. """ # bashplotlib.scatter.plot_scatter only accepts **files** (well, the pypi # release only accepts files. [PR43](https://github.com/glamp/bashplotlib/pull/43) # was merged but not released on pypi. # So we fake it. The code for `plot_scatter` will call `open(xs)`, so we just # write things to a temp file. /shrug. x_stream = tempfile.NamedTemporaryFile() y_stream = tempfile.NamedTemporaryFile() for i, ts in enumerate(x_data[-n_points:]): # timestamps are pd.datetime64 objects which store the number of # nanoseconds since the Unix epoch in the `value` attribute. ns = ts.value ms = ts.value / 1000 x_stream.write((str(i) + "\n").encode("utf-8")) x_stream.seek(0) for yval in y_data[-n_points:]: y_stream.write((str(yval) + "\n").encode("utf-8")) y_stream.seek(0) plot_scatter( f=None, xs=x_stream.name, ys=y_stream.name, size=20, pch="x", colour="red", title=title, ) # bashplotlib does not close files... x_stream.close() y_stream.close()
def updater_routine(self, net_version, in_line_testing = False): for ii in tqdm(range(1+net_version, 1+net_version+self.n_epochs)): if ii < self.sequential_after_n_epochs: loss, val_loss = self.update_1step() else: loss, val_loss = self.update_sequence() new_loss = np.array([loss, val_loss])[np.newaxis,:] self.loss_history = np.append(self.loss_history, new_loss, axis = 0) if ii >= self.plot_last_n and not ii % self.visualize_every_n: print(f'iteration = {ii}') print(f'training loss = {loss}') print(f'validation loss = {val_loss}') loss_array = self.loss_history[-self.plot_last_n:,0] val_loss_array = self.loss_history[-self.plot_last_n:,1] np.savetxt("loss_hist.csv", np.concatenate((np.arange(1,loss_array.shape[0]+1)[:,np.newaxis],loss_array[:,np.newaxis]), axis = 1), delimiter=",") np.savetxt("val_loss_hist.csv", np.concatenate((np.arange(1,val_loss_array.shape[0]+1)[:,np.newaxis],val_loss_array[:,np.newaxis]), axis = 1), delimiter=",") try: plot_scatter(f = "loss_hist.csv",xs = None, ys = None, size = 30, colour = 'white',pch = '*', title = 'training loss') plot_scatter(f = "val_loss_hist.csv",xs = None, ys = None, size = 30, colour = 'yellow',pch = '*', title = 'validation loss') except Exception: pass if not ii % self.save_every_n: net_name = self.net_name +'_' +str(ii) self.obs_net.save_net_params(net_name = net_name) # inline testing for debugging only if in_line_testing: self.test_net(reset_every = self.training_sequence_max_length, save_test_result = True, save_name = net_name) loss_array = self.loss_history[1:,0] val_loss_array = self.loss_history[1:,1] tr_loss_filename = self.net_name + "_tr_loss.csv" val_loss_filename =self.net_name + "_val_loss.csv" np.savetxt(tr_loss_filename, np.concatenate((np.arange(1,loss_array.shape[0]+1)[:,np.newaxis],loss_array[:,np.newaxis]), axis = 1), delimiter=",") np.savetxt(val_loss_filename, np.concatenate((np.arange(1,val_loss_array.shape[0]+1)[:,np.newaxis],val_loss_array[:,np.newaxis]), axis = 1), delimiter=",")
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2019 red <red@red-Swift-SF113-31> # # Distributed under terms of the MIT license. """ """ from bashplotlib.scatterplot import plot_scatter x_coords = [-10, 20, 30] y_coords = [-10, 20, 30] width = 10 char = 'x' color = 'default' title = 'My Test Graph' plot_scatter(None, x_coords, y_coords, width, char, color, title)
def display(self): plot_hist(list(self.knockouts_hist), title="Knockout size distribution", colour="blue") lines = ["%s, %s" % (x, y) for x, y in zip(self.solution.solutions['Size'], self.solution.solutions['Fitness'])] plot_scatter(lines, None, None, 20, "*", "blue", "Correlation between number of knockouts and fitness")
def plot_production_envelope_cli(envelope, objective, key, grid=None, width=None, height=None, title=None, points=None, points_colors=None, axis_font_size=None, color="blue"): scatterplot.plot_scatter(None, envelope[key], envelope["objective_upper_bound"], "*")
method = 'ticker' buy_value = 50650 #Set the buy value interval = 5 #Minutes xy_file = "xy.txt" count = 0 file = open(xy_file, 'w') file.close() while (True): file = open(xy_file, 'a') try: page = requests.get("https://www.mercadobitcoin.net/api/" + search + "/" + method + "/") except Exception as e: continue count += 1 data_json = json.loads(str(BeautifulSoup(page.content, 'html.parser'))) percent = (abs(float(data_json['ticker']['last']) - buy_value) / buy_value) * 100 file.write(str(count) + "," + data_json['ticker']['last'] + "\n") file.close() if float(data_json['ticker']['last']) >= buy_value: symb = u"\u2191" else: symb = u"\u2193" plot_scatter( xy_file, "", "", 30, "*", "red", data_json['ticker']['last'] + " " + symb + " " + str(percent) + "%") time.sleep((interval - int(percent)) * 60) print chr(27) + "[2J"