def get_layout(UPDATE_INT, config=None): app_layout = html.Div([ html.Div([ dcc.Interval(id='interval_component', interval=UPDATE_INT * 1000, n_intervals=0), dcc.Interval( id='psutil_component', interval=2 * 1000, n_intervals=0) ], style=dict(textAlign='center')), html.Div([ daq.Gauge(id='virtual_memory', min=0, value=0, size=150, className="leftbox", style=dict(textAlign="center")), daq.Gauge(id='swap_memory', min=0, value=0, size=150, className="rightbox", style=dict(textAlign="center")), ]), daq.LEDDisplay(id='train-id', value=1000, color="#FF5E5E", style=dict(textAlign="center")), html.Br(), html.Div(children=[ dcc.Tabs( parent_className='custom-tabs', className='custom-tabs-container', id='view-tabs', value='plot', children=[ dcc.Tab(className="custom-tab", selected_className='custom-tab--selected', label='Stream/Load data', value='stream-data', children=get_stream_tab(config)), # dcc.Tab( # className="custom-tab", # selected_className='custom-tab--selected', # label='Experimental parameters', # value='exp-param', # children=get_exp_tab() # ), dcc.Tab(className="custom-tab", selected_className='custom-tab--selected', label='Plots', value='plot', children=get_plot_tab(config)) ]) ]) ]) return app_layout
def get_my_carbon_food_print(country, age_group, *args): newDict = {} i = 0 for category in food_categories: newDict[category] = {} for item in all_keys[category]: newDict[category][item] = args[i] i += 1 my_carbon_food_print = helper_data.calculate_my_carbon_food_print(newDict) country_food_print = helper_data.get_carbon_food_print_for_country( country, age_group) return html.Div([ html.Div([ daq.Gauge(id='my-gauge', label='Your weekly CO2 food print', max=100000, value=my_carbon_food_print, min=0) ], className="six columns"), html.Div([ daq.Gauge(id='country-gauge', label=country + ' ' + age_group.lower() + ' weekly CO2 food print', max=100000, value=country_food_print, min=0) ], className="six columns") ], className="row")
def percentfig(pipe_df, ref_df): # Number of Evaluated Algorithms #evalgo = len(pipe_df['ALGO_NAME'].unique()) evalgo = len(pipe_df['ALGO_NAME'][pipe_df['ALGO_NAME'].str.contains( '_stack') == False][pipe_df['PP_FLAG'] == 'N'].unique()) # Hyperparameters evalhyper = len(pipe_df['HYPER_NAME'].unique()) # Total Algo Space total_algo = len(ref_df['ALGO_NAME'].unique()) print(total_algo) # Total Hyper Space total_hyper = ref_df['TOTAL_HYPER_COUNT'].groupby( ref_df['ALGO_NAME']).count().sum() pct_algos = (evalgo / total_algo) * 100 pct_hypers = (evalhyper / total_hyper) * 100 pfig1 = html.Div([ daq.Gauge(id='my-gauge', color={ "gradient": True, "ranges": { "green": [60, 100], "yellow": [40, 59], "red": [0, 39] } }, label="% Algorithms", size=150, value=round(pct_algos, 0), min=0, max=100) ]) pfig2 = html.Div([ daq.Gauge(id='my-gauge-1', color={ "gradient": True, "ranges": { "green": [0, 6], "yellow": [6, 8], "red": [8, 10] } }, label="% Hyperparameters", size=150, value=round(pct_hypers, 0), min=0, max=100) ]) return pfig1, pfig2
def model_perf(value): datasets = json.loads(value) df = pd.read_json(datasets['df_model_performance'], orient='split') df['Value'] = round(df['Value'], 3) return html.Div([ html.H1('Model Performance'), dbc.Row([ dbc.Col(daq.LEDDisplay( label='AUC', color="#FF5E5E", value=str(df['Value'][0])), md=2), dbc.Col(daq.LEDDisplay( label='GINI', color="#FF5E5E", value=str(df['Value'][1])), md=2), dbc.Col(daq.LEDDisplay(label='Kolmogorov-Smirnov', color="#FF5E5E", value=str(df['Value'][2])), md=2), dbc.Col(daq.Gauge(color={ "gradient": True, "ranges": { "red": [0, 40], "yellow": [40, 70], "green": [70, 100] } }, value=df['Value'][0] * 100, label='Overall Model Quality', max=100, min=0), md=4), ], align="center"), ]),
def predict(Platform, Genre): row = pd.DataFrame( columns=['Platform', 'Genre'], data=[[Platform, Genre]] ) y_pred = round(model.predict(row)[0] * 100, 2) label = f'Sales prediction chances are likely {y_pred}%' output = daq.Gauge( id='Prediction-Sales', label=label, color="3346FF", showCurrentValue=True, value=y_pred, min=0, max=200, units="%") print(f'{label}') return output
def make_card(name, avg): link = '/' + name return dbc.Card( [ dbc.CardBody([ html.Div([ html.H4(name, className="card-title"), daq.Gauge(id=name + '_gauge', label="Mood in past week", value=avg, max=10, min=0, showCurrentValue=True, color={ "gradient": True, "ranges": { "red": [0, 4], "yellow": [4, 7], "green": [7, 10] } }), dbc.Button("Details", href=link, color="primary"), ], className="container text-center") ]), ], style={"width": "18rem"}, )
def progress_gauge(current,total): logging.debug("progress gauge: {} of {}".format(current,total)) try: per_cent = round(100*(current/total)) except ZeroDivisionError: per_cent = 0 # some "total" numbers are estimates, so could go over 100% if per_cent > 100: per_cent = 100 elements = [ daq.Gauge( value = per_cent, max = 100, min = 0, size = 130, color = {"gradient" : True, "ranges" : {"red" : [0, 25], "yellow" : [25, 75], "green" : [75, 100], }, }, label = {'label' : '%', 'style' : {'font-size': 'larger'} }, labelPosition = 'bottom', ), ] return elements
def create_quick_overview_tab(id_gauges, id_graphs, n_clicks, data): if n_clicks % 2 == 1: button = 'The live graphs are currently being updated.' graphs = [] for id_graph in id_graphs: sensor_graph = find_sensor_given_id(id_graph) graph = create_graph(sensor_graph, data) if sensor_graph: graphs.append(graph) else: button = 'The live graphs are currently paused.' graphs = no_update gauges = [] for id_gauge in id_gauges: sensor_gauge = find_sensor_given_id(id_gauge) if sensor_gauge: maxVal = sensor_gauge['max_value'] minVal = sensor_gauge['min_value'] gauge_unit = sensor_gauge['units'] gauge_label = sensor_gauge['label'] if sensor_gauge['id'] == 'AVG_VSS': gauge_value = (data['FL_VSS'][len(data) - 1] + data['FR_VSS'][len(data) - 1] + data['BL_VSS'][len(data) - 1] + data['BR_VSS'][len(data) - 1]) / 4 else: gauge_value = data[sensor_gauge['id']][len(data) - 1] gauges.append(daq.Gauge(id=sensor_gauge['id'] + "_qo_gauge", max=maxVal, min=minVal, units=gauge_unit, label=gauge_label, value=gauge_value, showCurrentValue=True, style={'display': 'inline-block', 'width': '20%'})) return gauges, graphs, button, no_update, no_update, no_update, no_update, no_update, no_update
def predict(walk_distance, time_survived, duration, game_mode, platform, ride_distance, map_name, weapons_acquired, boosts): # Create row row = pd.DataFrame( columns=['walkDistance', 'timeSurvived', 'duration', 'gameMode', 'platform', 'rideDistance', 'mapName', 'weaponsAcquired', 'boosts'], data=[[walk_distance, time_survived, duration, game_mode, platform, ride_distance, map_name, weapons_acquired, boosts]] ) y_pred = round(model.predict(row)[0] * 100, 2) label = f'Your chances of winning are {y_pred}%' output = daq.Gauge( id='win-place-pred-gauge', label=label, color="#F2A900", showCurrentValue=True, value=y_pred, max=100, min=0, units="%") print(f'[DEBUG] {label}') return output
def make_sentiment_gauge(label, value): return daq.Gauge( label=label, min=0, max=1, value=value, color={"gradient": True, "ranges": { "green": [0, 0.6], "yellow": [0.6, 0.8], "red": [0.8, 1]}}, size=120)
def explore_model_make_gauges(*values): if values[-5] == None: raise PreventUpdate feature_values = json.loads(values[-5]) data_target = values[-4] model_length = json.loads(values[-3]) model_weights = json.loads(values[-2]) model_weights = [np.array(i) for i in model_weights] N_values = json.loads(values[-1]) N = NormalizationTensor.from_stored_value( np.array(N_values['feature_mean']), np.array(N_values['feature_std']), np.array(N_values['target_mean']), np.array(N_values['target_std'])) model1 = model1_prep(model_length, add_dropout=False) model1.set_weights(model_weights) prediction = N.n2t(model1.predict(N.f2n(feature_values))) df_target = pd.read_json(data_target) column_names = list(df_target.columns) min_targets = df_target.min(axis=0).values max_targets = df_target.max(axis=0).values gauges = [] for i, (name, min_value, max_value) in enumerate(zip(column_names, min_targets, max_targets)): gap = (max_value - min_value) / 3 green = [min_value, min_value + gap] yellow = [min_value + gap, min_value + 2 * gap] red = [min_value + 2 * gap, min_value + 3 * gap] gauge = daq.Gauge(id={ 'type': 'gaugeModelExploration', 'index': name }, label=name, min=min_value, max=max_value, value=prediction[0, i], showCurrentValue=True, color={ "gradient": True, "ranges": { "green": green, "yellow": yellow, "red": red } }, size=100, scale={ 'start': min_value, 'interval': (max_value - min_value) / 8 }) gauges.append(html.Div(gauge, className='col s1')) return [html.Div(gauges, className='row')]
def build_quick_stats_panel(self): """Quick stats on the left of the view :return: html.Div object """ current_giesszellenbedarf = \ self.dm.giesszellenbedarf_over_time().iloc[0, :] return html.Div( id="quick-stats", className="row", children=[ html.Div( id="card-1", children=[ html.P("Operator ID"), daq.LEDDisplay( id="operator-led", value="042", color="#92e0d3", backgroundColor="#1e2130", size=20, ), ], ), html.Div( id="card-2", children=[ html.P("Durchschnittl. Formverschleiß"), daq.GraduatedBar(id="form-life-bar", value=self.dm.avg_attrition), ], ), html.Div( id="card-3", children=[ html.P( "Prozentuale Gießzellenauslastung diesen Monat"), daq.Gauge(id="attrition-gauge", min=0, max=100, showCurrentValue=True, value=100 * current_giesszellenbedarf.mean() / current_giesszellenbedarf.max()) ], ), html.Div( # todo: Implement this feature id="card-4", children=daq.BooleanSwitch(id="AI-powerbutton", on=False, label='AI', color="#92e0d3"), ), ], )
def realTimeStatusFigs(): algo_status_fig = html.Div([ daq.Gauge(id='algo-status-fig', label="% Algorithms", size=130, min=0, max=100) ], className='col-4') hyper_status_fig = html.Div([ daq.Gauge(id='hyper-status-fig', label="% Hyperparameters", size=130, min=0, max=100) ], className='col-4') return algo_status_fig, hyper_status_fig
def second_layer(self): return html.Div([create_paragraph(PVCONNECTION_TEXTS['second_layer']['heading'], \ PVCONNECTION_TEXTS['second_layer']['detail']), html.Div([ html.Div([daq.Gauge(id='nvri', color="#9B51E0", value=0, label='Increase in NVRI', max=100, min=-100, showCurrentValue=True) ],className="col"), html.Div([daq.Gauge(id='cri', color="#9B51E0", value=0, label='Increase in CRI', max=100, min=-100, showCurrentValue=True ) ], className="col"), ],className="row textwhite") ])
def generate_gauge(div_id, label_name, max_value=10): return daq.Gauge( id=div_id, value=0, label={ 'label': label_name, 'style': { 'color': '#C4CDD5' } }, max=max_value, min=0, )
def update_output(w): l_items = t.get() cpu_usage = l_items[0] total_ram = l_items[1] used_ram = l_items[2] disk_usage = l_items[3] return daq.Gauge(showCurrentValue=True, id='my-gauge', label="CPU", units="%", max=100, min=0, value=cpu_usage), daq.Gauge( showCurrentValue=True, id='my-gauge2', label="Disk", units="%", max=100, min=0, value=disk_usage), html.P( 'Total RAM :{}'.format(total_ram)), html.P( 'Used RAM :{}'.format(used_ram))
def build_quick_stats_panel(): return html.Div( id="quick-stats", className='row', children= [ html.Div( id="card-1", className='four columns', children=[ html.H5("Operator ID"), daq.LEDDisplay( value='1704', color=theme['secondary'], size=50, theme=theme ) ] ), html.Div( id='card-2', className='four columns', children=[ html.H5("Time to completion"), daq.Gauge( id='progress-gauge', value=0, size=150, max=max_length * 2, min=0, color=theme['secondary'] ) ] ), html.Div( id='utility-card', className='four columns', children=[ daq.StopButton(id='stop-button', size=160, buttonText='start') ] ) ] )
def sentiment(df): value = df.sentiment[df.sentiment != 0].mean() value = round(value, 1) value = float("%.1f" % value) return daq.Gauge(min=-1, max=1, value=value, showCurrentValue=True, scale={ 'start': -1, 'interval': 0.5, 'labelInterval': 0.5 }, color='#00a0d6', label=' ', size=200, id='sentiment')
def Main(): return html.Div([ dcc.Location(id='url', refresh=False), html.Div([ html.Div( html.Img(src="/assets/jolt.png"), className= "w3-container w3-cell w3-margin w3-padding w3-center jolt-box" ), MetricCard("In Queue", "metric_tasks_queued"), MetricCard("In Progress", "metric_tasks_running"), MetricCard("Completed (1h)", "metric_tasks_completed"), MetricCard("Failed (1h)", "metric_tasks_failed"), ], className="w3-padding w3-border-bottom"), html.Div(Tabs([("Overview", [ html.Div([ daq.Gauge(id='metric_cluster_load', label="Cluster Load", value=0, max=0, scale={ 'start': 0, 'interval': 1, 'labelInterval': '5' }), ], className="w3-container w3-padding"), ]), ("Tasks", SmallTabs([ ("Live", TaskList(id="tasklist_live", columns=[ "worker", "name", "identity", "queued", "started", "status" ])), ("Last Hour", TaskList(id="tasklist")), ], id="tabs-tasks")), ("Workers", WorkerContent(id="workercontent"))]), className="w3-cell-row w3-white"), ], className="w3-light-gray")
def update_graph_interactive_images(buttons,text): if text=="": return '' numericValue=mod.runs(str(text))*10 print(numericValue) gauge=daq.Gauge( showCurrentValue=True, color='#FFC107', value=numericValue, label='True-Meter', max=10, min=0, ) return gauge
def predict(clicked, text): if clicked: text = [text] text = wrangle2(text) y_pred = model.predict(text) if y_pred == 0: y_pred = 'hateful' if y_pred == 1: y_pred = 'offensive' if y_pred == 2: y_pred = 'normal' df = pd.DataFrame(model.predict_proba(text), columns=["Hateful", "Offensive", "Normal"]) df_percent = df.mul(100).round(2).astype(str) + '%' output1 = f'This tweet is labeled as {y_pred}.' output2 = dash_table.DataTable(data=df_percent.to_dict('records'), style_cell={ 'textAlign': 'left', 'padding': '15px' }, columns=[{ "name": i, "id": i } for i in df_percent.columns], style_header={ 'backgroundColor': 'rgb(230, 230, 230)', 'fontSize': '15px', 'fontWeight': 'bold' }) output3 = daq.Gauge( showCurrentValue=True, units="percentage points", value=(((df[["Hateful", "Offensive", "Normal"]].max()).max()) * 100).round(2), label=f'Percent probability this tweet is {y_pred}', size=380, labelPosition='bottom', max=100, min=0, ) return output1, output2, output3
def build_quick_stats_panel(): return html.Div( id="quick-stats", className="row", children=[ html.Div( id="card-1", className="w3-text-white", children=[ html.P("Operator ID"), daq.LEDDisplay( id="operator-led", value="1704", color="#92e0d3", backgroundColor="#1e2130", size=50, ), ], ), html.Div( id="card-2", className="w3-text-white", children=[ html.P("Time to completion"), daq.Gauge( id="progress-gauge", max=max_length * 2, min=0, showCurrentValue=True, # default size 200 pixel ), ], ), html.Div( id="utility-card", children=[ daq.StopButton(id="stop-button", size=160, n_clicks=0) ], ), ], )
def get_layout(UPDATE_INT, config=None): app_layout = html.Div( [ html.Div( [ dcc.Interval( id="interval_component", interval=UPDATE_INT * 1000, n_intervals=0, ), dcc.Interval( id="psutil_component", interval=2 * 1000, n_intervals=0 ), ], style=dict(textAlign="center"), ), html.Div( [ daq.Gauge( id="virtual_memory", min=0, value=0, size=150, className="leftbox", style=dict(textAlign="center"), ), daq.Gauge( id="swap_memory", min=0, value=0, size=150, className="rightbox", style=dict(textAlign="center"), ), ] ), daq.LEDDisplay( id="timestamp", value="1000", color="#FF5E5E", style=dict(textAlign="center"), ), html.Br(), html.Div( children=[ html.Div( [ html.Div( [ html.Label("Proposal"), dcc.Input( id="proposal", placeholder="Enter the proposal", type="text", value=config["proposal"], ), html.Br(), html.Label("Run Type:", className="leftbox"), dcc.Dropdown( id="run-type", options=[ {"label": i, "value": i} for i in _run_types ], value=_run_types[0], className="rightbox", ), html.Hr(), daq.BooleanSwitch(id="start", on=False), html.Br(), html.Div(id="stream-info"), html.Hr(), html.Div( [ dcc.Dropdown( id="problem-runs", placeholder="Problematic runs", options=[], className="leftbox", ), dcc.Textarea( id="problems-info", placeholder="Validation Message", draggable="false", readOnly=True, disabled=True, style={"width": "100%", "height": 200}, ), ] ), ], className="pretty_container one-third column", ), html.Div( [ dcc.Dropdown( id="format-type", options=[ {"label": i, "value": i} for i in _units ], value=_units[0], className="leftbox", ), dcc.Graph(id="histogram"), ], className="two-thirds column", ), ], className="row", ) ] ), html.Br(), ] ) return app_layout
html.Label(['Fatigue levels']) ], style = { 'font-size' : '24px', 'text-align' : 'center', 'marginTop':10, 'marginBottom':5, } ), html.Div([ daq.Gauge( id = 'output-b', color={"gradient":True,"ranges":{"red":[0,40],"white":[40,60],"blue":[60,100]}}, value= 50, max=100, min=0, ) ], style = { 'text-align' : 'center', } ), html.Div([ html.Label(['0 = no fatigue, 100 = maximum fatigue']) ], style = { 'font-size' : '14px',
"height": "10%", "marginLeft": "34%", "marginBottom": "6%", }, ), html.Div( [ daq.Gauge( id="speed-gauge", showCurrentValue=True, units="Revolutions/Second", min=0, max=3, value=0, size=150, color="#FF5E5E", label="Revolutions Per Second (Max 3 RPS)", className="twelve columns", style={ "marginTop": "5%", "marginBottom": "-10%", "color": "#222", }, ) ], className="row", style={ "border-radius": "1px", "border-width": "5px", "border-top": "1px solid rgb(216, 216, 216)", },
color='red', label='Off/Do Not Run =') ]) ]), html.Br(), html.Div(className='indicator-box', id='pgpress-container', children=[ html.H4('Blue Pressure Gauge'), daq.Gauge( id='pgpress-status', min=0, max=1, showCurrentValue=True, color={ "gradient": True, "ranges": { "green": [0, 0.3], "yellow": [0.3, 0.7], "red": [0.7, 1] } }, ), html.P('Order of 1000') ]), html.Div(className='indicator-box', id='time-container', children=[ html.H4('Time to completion (hours)'), daq.Gauge(id='time-to-completion', min=0, max=10,
id='darktheme-daq-booleanswitch', className='dark-theme-control' ), html.Br(), daq.ToggleSwitch( id='darktheme-daq-toggleswitch', className='dark-theme-control' ), html.Br(), daq.ColorPicker( value=17, id='darktheme-daq-colorpicker', className='dark-theme-control' ), html.Br(), daq.Gauge( min=0, max=10, value=6, color=theme['primary'], id='darktheme-daq-gauge', className='dark-theme-control' ), html.Br(), daq.GraduatedBar( value=4, color=theme['primary'], id='darktheme-daq-graduatedbar', className='dark-theme-control' ), html.Br(), daq.Indicator( value=True, color=theme['primary'], id='darktheme-daq-indicator', className='dark-theme-control' ), html.Br(),
25: {'label': '25'}, 50: {'label': '50'}, 75: {'label': '75'}, 100: {'label': '100'}, }), ],className="pretty_container four columns"), html.Div([ daq.Gauge( id='my-gauge', showCurrentValue=True, color={"gradient":True,"ranges":{"red":[0,30],"yellow":[30,60],"green":[60,100]}}, label="Test Score", max=100, min=0, value=1 ), ]) ]) @app.callback( Output('my-gauge', 'value'), [Input('Paper1-slider', 'value'), Input('Paper2-slider', 'value'), Input('Paper3-slider', 'value'), Input('Paper4-slider', 'value'), Input('Paper5-slider', 'value'),
40: {'label': '40'}, 60: {'label': '60'}, 80: {'label': '80'}, 100: {'label': '100'}, }), ],className="pretty_container four columns"), html.Div([ daq.Gauge( id='my-gauge', showCurrentValue=True, color={"gradient":True,"ranges":{"red":[0,40],"yellow":[40,70],"green":[70,100]}}, label="Probability", max=100, min=0, value=50 ), ]) ]) @app.callback( Output('my-gauge', 'value'), [Input('gre-slider', 'value'), Input('toefl-slider', 'value'), Input('rating-slider', 'value'), Input('sop-slider', 'value'), Input('lor-slider', 'value'),
html.Div([ daq.Gauge( id='FinalGrade-gauge', showCurrentValue=True, color={"gradient":True,"ranges":{"red":[0,5],"yellow":[5,15],"green":[15,20]}}, label="Final Grade", max=20, min=0, value=10 ), ]) ])