def apply_file_properties(n): file = db.get("file") format = db.get("format") sep = db.get("file_separator") header = db.get("file_header") div = None if format is None: div = None elif (format == 'csv' or format == 'txt') and header is None: div = common.error_msg('Please Select Header!!') elif format == 'csv' or format == 'txt': if sep is None: sep = ',' db.put("file_separator", sep) path = FileUtils.path('raw', file) df = DataUtils.read_csv(path, sep, header) db.put("data", df) msg = "Following Properties Applied. Separator=" + sep + " Header=" + str( header) table = dbc.Table.from_dataframe(df.head(10), striped=True, bordered=True, hover=True, style=common.table_style) div = [common.msg(msg), table] return div
def display_data(value): """Displaying the head for the selected file.""" db_value = db.get("file") if value is None and db_value is None: return "" elif value is None and not db_value is None: value = db_value elif not value == db_value: db.reset() format = FileUtils.file_format(value) if format == 'csv' or format == 'txt': path = FileUtils.path('raw', value) head = DataUtils.read_text_head(path) table_col = [html.Col(style = {'width':"10%"}), html.Col(style = {'width':"90%"})] table_header = [html.Thead(html.Tr([html.Th("Row No"), html.Th("Data")]))] rows = [] for i in range(len(head)): row = html.Tr([html.Td(i+1), html.Td(head[i])]) rows.append(row) table_body = [html.Tbody(rows)] table = dbc.Table(table_col+ table_header + table_body, bordered=True, style = common.table_style) div = [common.msg("Selected File: " + value), common.msg("Selected Format: " + format), table, html.Br(), csv_properties_div] elif format == 'jpeg' or format == 'jpg' or format == 'gif': div = [common.msg("Selected File: " + value), common.msg("Selected Format: " + format)] else: div = "Format Not Supported!!" db.put("file", value) db.put("format", format) return div
def dtn_display_selected_file_scatter_plot(value): value = "banknote" db.put("dtn.file", value) file = value path = FileUtils.path('clean', file) df = DataUtils.read_csv(path) save_path = FileUtils.path('extra', 'banknote.csv') df.to_csv(save_path, index=False, header = False) db.put("dtn.data", df) db.put('dtn.model_class', 'class') db.put('dtn.model_variables', ['variance','skewness','curtosis','entropy']) call_path = FileUtils.path('nets', 'dt_banknote_call1.csv') cdf = DataUtils.read_csv(call_path) trace_1 = go.Scatter(x = cdf['max_depth'], y = cdf['avg_train_score'], name = 'Average Train Score') trace_2 = go.Scatter(x = cdf['max_depth'], y = cdf['avg_test_score'], name = 'Average Test Score') title = go.Layout(title = 'Depth of Tree Vs Performance Plot', hovermode = 'closest', xaxis={'title': 'Depth of Tree'}, yaxis={'title': 'Performance'}) fig = go.Figure(data = [trace_1, trace_2], layout = title) div = html.Div([ common.msg("Selected cleaned file: "+ file), dbc.Table.from_dataframe(df.head(10).round(5).astype(str), striped=True, bordered=True, hover=True, style = common.table_style), html.Br(), html.H2('Using Default parameters for both max_depth and min_size.'), html.H2('Max Depth = 2 to 15'), html.H2('Min Size = 10'), dbc.Table.from_dataframe(cdf.round(4), striped=True, bordered=True, hover=True, style = common.table_style), html.Br(), dcc.Graph(id='dtn-plot', figure=fig), html.Br(), get_dtn_model_properties_div(df), dcc.Loading(id="dtn-model-training", children=[html.Div([], id = "dtn-trained-model", style = {'margin': '10px'})], type="default"), ]) return div
def dt_display_selected_file_scatter_plot(value): db_value = db.get("dt.file") if value is None and db_value is None: return common.msg("Please select a cleaned file to proceed!!") elif value is None and not db_value is None: value = db_value db.put("dt.file", value) file = value path = FileUtils.path('clean', file) df = DataUtils.read_csv(path) db.put("dt.data", df) div = html.Div([ common.msg("Selected cleaned file: "+ file), dbc.Table.from_dataframe(df.head(10).astype(str), striped=True, bordered=True, hover=True, style = common.table_style), #html.Div([html.H3("Data Statistics")], style={'width': '100%', 'display': 'flex', 'align-items': 'center', 'justify-content': 'center'}), #dbc.Table.from_dataframe(stats, striped=True, bordered=True, hover=True, style = common.table_style), html.Br(), get_dt_model_properties_div(df), html.Div([], id = "dt-trained-model", style = {'margin': '10px'}), ]) return div
def nlcl_display_selected_file_scatter_plot(value): db_value = db.get("nlcl.file") if value is None and db_value is None: return common.msg("Please select a cleaned file to proceed!!") elif value is None and not db_value is None: value = db_value db.put("nlcl.file", value) file = value path = FileUtils.path('clean', file) df = DataUtils.read_csv(path) db.put("nlcl.data", df) stats = df.describe(include = 'all').head(6).round(5) stats.insert(loc=0, column='Statistics', value=['Count','unique','top','freq','Mean','Standard Deviation']) stats = stats.drop(stats.index[[1,2,3]]) div = html.Div([ common.msg("Selected cleaned file: "+ file), dbc.Table.from_dataframe(df.head(10), striped=True, bordered=True, hover=True, style = common.table_style), html.Div([html.H3("Data Statistics")], style={'width': '100%', 'display': 'flex', 'align-items': 'center', 'justify-content': 'center'}), dbc.Table.from_dataframe(stats, striped=True, bordered=True, hover=True, style = common.table_style), html.Br(), html.Div([html.H2("Scatter Plot")], style={'width': '100%', 'display': 'flex', 'align-items': 'center', 'justify-content': 'center'}), dbc.Row([ dbc.Col([ dbc.Label("Select Class"), dcc.Dropdown( id = 'nlcl-class', options=[{'label':col, 'value':col} for col in [*df]], value=None, multi=False ), html.Br(), dbc.Label("Select X Axis"), dcc.Dropdown( id = 'nlcl-x-axis', options=[{'label':col, 'value':col} for col in [*df]], value=None, multi=False ), html.Br(), dbc.Label("Select Y Axis"), dcc.Dropdown( id = 'nlcl-y-axis', options=[{'label':col, 'value':col} for col in [*df]], value=None, multi=False ), html.Br(), dbc.Button("Plot", color="primary", id = 'nlcl-scatter-plot-button'), html.Div([], id = "nlcl-class-do-nothing"), html.Div([], id = "nlcl-x-axis-do-nothing"), html.Div([], id = "nlcl-y-axis-do-nothing") ], md=2, style = {'margin': '10px', 'font-size': '16px'}), dbc.Col([], md=9, id="nlcl-scatter-plot") ]), html.Br(), get_nlcl_model_properties_div(df), html.Div([], id = "nlcl-trained-model", style = {'margin': '10px'}), ]) return div