Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# log-transform y
df['y'] = np.log(df['y'])
model = Prophet(weekly_seasonality=True, yearly_seasonality=True)
model.fit(df)
periods = PERIODS if not render else GRAPH_PERIODS
future_data = model.make_future_dataframe(periods=periods, freq='d')
forecast_data = model.predict(future_data)
if render:
matplotlib.pyplot.gcf()
fig = model.plot(forecast_data, xlabel='Date', ylabel='log($)')
return mpld3.fig_to_html(fig)
forecast_data_orig = forecast_data # make sure we save the original forecast data
forecast_data_orig['yhat'] = np.exp(forecast_data_orig['yhat'])
forecast_data_orig['yhat_lower'] = np.exp(forecast_data_orig['yhat_lower'])
forecast_data_orig['yhat_upper'] = np.exp(forecast_data_orig['yhat_upper'])
df['y_log'] = df['y'] #copy the log-transformed data to another column
df['y'] = df['y_orig'] #copy the original data to 'y'
# print(forecast_data_orig)
d = forecast_data_orig['yhat'].to_dict()
predictions = []
for i, k in enumerate(list(d.keys())[-PERIODS:]):
w = maya.when(f'{i+1} days from now')
predictions.append({
fig = pylab.figure()
for ifo in ifos:
trigs = columns_from_file_list(file_list,
['snr', 'end_time'],
ifo, start, end)
print(trigs)
pylab.scatter(trigs['end_time'], trigs['snr'], label=ifo,
color=ifo_color[ifo])
fmt = '.12g'
mpld3.plugins.connect(fig, mpld3.plugins.MousePosition(fmt=fmt))
pylab.legend()
pylab.xlabel('Time (s)')
pylab.ylabel('SNR')
pylab.grid()
return mpld3.fig_to_html(fig)
mpld3.plugins.connect(fig, tooltip, TopToolbar())
# set tick marks as blank
ax.axes.get_xaxis().set_ticks([])
ax.axes.get_yaxis().set_ticks([])
# set axis as blank
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
ax.legend(numpoints=1) # show legend with only one dot
mpld3.display() # show the plot
# uncomment the below to export to html
html = mpld3.fig_to_html(fig)
name = 'name.%s.html' % ('en' if english else 'es')
mpld3.save_html(fig, name)
def money_scatter_plot(data_df):
x = data_df['Current Equip. Value']
y = data_df['Round Kills']
fig = plt.figure()
plt.scatter(x, y)
plt.xlabel('Equipment Value ($)')
plt.ylabel('# of Kills In Round')
plt.yticks([0, 1, 2, 3, 4, 5])
plt.suptitle('Kills/Round vs. Equipment Value')
return mpld3.fig_to_html(fig, no_extras=True)
voffset=10, hoffset=10)#, css=self.css)
mpld3.plugins.connect(fig, tooltip)
if scatter_inc:
tooltip = mpld3.plugins.PointHTMLTooltip(scatter_inc, np.array(labels)[inc_indx].tolist(),
voffset=10, hoffset=10)#, css=self.css)
mpld3.plugins.connect(fig, tooltip)
if self.output_dir:
self.logger.debug("Save to %s", self.output_dir)
with open(self.output_dir, "w") as fp:
mpld3.save_html(fig, fp)
html = mpld3.fig_to_html(fig)
plt.close(fig)
return html
def fig_to_html(fig):
return mpld3.fig_to_html(fig)
self.x[i] = []
self.y[i] = []
if self.xlim_pipe is not None and output is None:
import matplotlib.animation
self.ani = matplotlib.animation.FuncAnimation(self.fig, self.xlim_change_check,
frames=10, interval=20000,
repeat=True, blit=False)
threading.Timer(0.1, self.xlim_timer).start()
if output is None:
pylab.draw()
pylab.show(block=block)
elif output.endswith(".html"):
import mpld3
html = mpld3.fig_to_html(self.fig)
f_out = open(output, 'w')
f_out.write(html)
f_out.close()
else:
pylab.savefig(output, bbox_inches='tight', dpi=200)
stat2 = f['foreground/stat2']
time1 = f['foreground/time1']
time2 = f['foreground/time2']
ifo1 = f.attrs['detector_1']
ifo2 = f.attrs['detector_2']
pylab.scatter(time1, stat1, label=ifo1, color=ifo_color[ifo1])
pylab.scatter(time2, stat2, label=ifo2, color=ifo_color[ifo2])
fmt = '.12g'
mpld3.plugins.connect(fig, mpld3.plugins.MousePosition(fmt=fmt))
pylab.legend()
pylab.xlabel('Time (s)')
pylab.ylabel('NewSNR')
pylab.grid()
return mpld3.fig_to_html(fig)