def update(attr, old, new): if old == new: return t0 = time.time() timer = Paragraph() timer.text = '(Executing query...)' test_name_para = Paragraph() test_name_para.text = 'Metrics for: {}'.format(test_select.value) curdoc().clear() base_rows = [row(test_name_para), row(test_select, metric_select, timer)] curdoc().add_root(column(children=base_rows, )) test_name = test_select.value if test_name not in test_names: timer.text = 'Invalid test_name: {}'.format(test_name) return metric_substr = metric_select.value cutoff_timestamp = ( datetime.datetime.now() - datetime.timedelta(days=30)).strftime('%Y-%m-%d %H:%M:%S UTC') data = metric_history.fetch_data(test_name, cutoff_timestamp) plots = metric_history.make_plots(test_name, metric_substr, data) plot_rows = [row(p) for p in plots] if plots else [] curdoc().clear() curdoc().add_root(column(children=base_rows + plot_rows, )) t1 = time.time() timer.text = '(Execution time: %s seconds)' % round(t1 - t0, 4)
def create_plots(): t0 = time.time() timer = Paragraph() test_names = [x for x in test_select.value.split(',') if x] logging.info('test_names: `{}`'.format(test_names)) metric_names = [x for x in metric_select.value.split(',') if x] logging.info('metric_names: `{}`'.format(metric_names)) if not test_names or not metric_names: timer.text = 'Neither test_names nor metric_names can be blank.' draw_base_ui(timer, test_select, metric_select) return data = metric_compare.fetch_data(test_names, metric_names) if data.empty: timer.text = 'No data found. Double check metric/test names.' draw_base_ui(timer, test_select, metric_select) return plots = metric_compare.make_plots(test_names, metric_names, data) plot_rows = [row(p) for p in plots] if plots else [] base_rows = [row(timer), row(test_select), row(metric_select)] curdoc().clear() curdoc().add_root( column( children=base_rows + plot_rows, ) ) t1 = time.time() timer.text = '(Execution time: %s seconds)' % round(t1 - t0, 4)
def update(attr, old, new): if old == new: return t0 = time.time() timer = Paragraph() timer.text = '(Executing query...)' test_name_para = Paragraph() test_name_para.text = 'Metrics for: {}'.format(test_select.value) curdoc().clear() base_rows = [row(test_name_para), row(test_select, metric_select, timer)] curdoc().add_root(column(children=base_rows, )) test_name = test_select.value metric_substr = metric_select.value data = metric_history.fetch_data(test_name) plots = metric_history.make_plots(test_name, metric_substr, data) plot_rows = [row(p) for p in plots] if plots else [] curdoc().clear() curdoc().add_root(column(children=base_rows + plot_rows, )) t1 = time.time() timer.text = '(Execution time: %s seconds)' % round(t1 - t0, 4)
def forecast_tab(data, ticker): pg_title = Paragraph() pg_title.text = '[ ' + ticker + ' ] CLOSE PRICE FORECAST' # Create a row layout layout = row(pg_title) # Make a tab with the layout tab = Panel(child=layout, title='Forecast') return tab
def update_reviews(attr, old, new): data_set = pd.read_csv('Outputs/data_set.csv') i = int(star_rating.value) #output_review_list = extract_ngrams(str(data_set[(data_set['Star_count'] == i)]['Review'].values),2,3) data_set_blob = data_set.copy() data_set_blob['Noun_sentences'] = data_set_blob['Review'].apply(lambda x:get_nouns(x)) n_gram_blob = TextBlob(str(data_set_blob[(data_set_blob['Star_count'] == i)]['Noun_sentences'].values)) #Styling the paragraph element text1 = Paragraph(style={'font-variant': 'small-caps','font-family': "Tahoma"}) text1.text="" #review1 = text_cleaner(str(n_gram_blob.ngrams(1)[0])) #review2 = text_cleaner(str(n_gram_blob.ngrams(1)[1])) review1 = text_cleaner(n_gram_blob.ngrams(1)[1][0]) review2 = text_cleaner(n_gram_blob.ngrams(1)[2][0]) text1.text = "Top "+str(i)+" star reviews feel: "+review1+", followed by "+review2 curdoc().add_root(Row(text1))
lattice=Select(title="Lattice:", value="Triangular", options=["Rectangular", "Triangular"]) dxin=TextInput(title='dx (cm)', value='5.74') dyin=TextInput(title='dy (cm)', value='7.13') tiltin=TextInput(title='Tilt (degrees)', value='22.5') scanazin=TextInput(title='Azimuth Scan (degrees)', value='-60 60') scanelin=TextInput(title='Elevation Scan (degrees)', value='0 45') kgxout=Paragraph(width=200, height=15) kgyout=Paragraph(width=200, height=15) wlout=Paragraph(width=200, height=15) p=Figure(match_aspect=True) tilt=float(tiltin.value)*np.pi/180 wl=2.997e4/float(freqin.value) wlout.text='Wavelength = '+str(wl)+' cm' kgy=wl/float(dyin.value) if lattice.value=='Triangular': kgx=2*wl/float(dxin.value) kmult=0.5 else: kgx=wl/float(dxin.value) kmult=1 kgxout.text='kgx = '+str(kgx) kgyout.text='kgy = '+str(kgy) newscanazstr = ''.join((ch if ch in '0123456789.-e' else ' ') for ch in scanazin.value) newscanelstr = ''.join((ch if ch in '0123456789.-e' else ' ') for ch in scanelin.value) scanaz = [float(i) for i in newscanazstr.split()] scanel = [float(i) for i in newscanelstr.split()]
] x_select = Select(options=option_list, value='length', title='Select the x-axis data') # Create a dropdown Select widget for the y data: y_select y_select = Select(options=option_list, value='price', title='Select the y-axis data') # create some widgets like adding text #button = Button(label="Get the Pearson correlation (Cor) and the P-value between the selected variables") output1 = Paragraph() output2 = Paragraph() pearson_coef, p_value = stats.pearsonr(df['length'], df['price']) output1.text = "Pearson Correlation = " + str(pearson_coef) output2.text = "P-value = " + str(p_value) #Define the callback: update_plot def callback(attr, old, new): # Read the current values 2 dropdowns: x, y new_data_dict = { 'x': df[x_select.value], 'y': df[y_select.value], 'drive_wheels': df['drive_wheels'] } source.data = new_data_dict pearson_coef, p_value = stats.pearsonr(df[x_select.value], df[y_select.value])
def update(attr, old, new): timer = Paragraph() timer.text = '(Executing query...)' draw_base_ui(timer, test_select, metric_select) curdoc().add_next_tick_callback(create_plots)
print(authors) print(abstract) print(paper) # SVM # kNN model.fit() model.predict() return (5, 10, 15) def get_paper_string(): data = str(b64decode(file_input.value)) return data y1.text = " - " def update_output(): title = title_input.value authors = author_number.value abstract = abstract_input.value paper = get_paper_string() if check_for_errors(): y1.text = "-" y5.text = "-" y10.text = "-" else: y1.text = str(calculate(title, authors, abstract, paper)[0]) y5.text = str(calculate(title, authors, abstract, paper)[1]) y10.text = str(calculate(title, authors, abstract, paper)[2])