Skip to content

Commit

Permalink
modified for server usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nischa564 committed Oct 25, 2023
1 parent fb3e793 commit 8e2dc71
Show file tree
Hide file tree
Showing 38 changed files with 2,459 additions and 1,318 deletions.
6 changes: 3 additions & 3 deletions app.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
"from callbacks import sidebar_callbacks\n",
"\n",
"# import pages\n",
"from view import page_data_loading, page_overview, page_categorical_feature, page_na_value, page_outlier_detection, page_transformation_table_data, page_transformation_time_series, page_supervised_classification, page_supervised_regression\n",
"from view import page_data_loading, page_overview, page_categorical_feature, page_na_value, page_outlier_detection, page_transformation_time_series, page_supervised_classification, page_supervised_regression\n",
"\n",
"# the styles for the main content position it to the right of the sidebar and\n",
"# add some padding.\n",
Expand Down Expand Up @@ -669,7 +669,7 @@
" id=\"page_content\", style=CONTENT_STYLE\n",
")\n",
"\n",
"app.layout = html.Div([dcc.Location(id=\"url\"), sidebar_, content])\n",
"app.layout = html.Div([dcc.Location(id=\"url\", refresh=False), sidebar_, content])\n",
"\n",
"\n",
"\n",
Expand Down Expand Up @@ -703,7 +703,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.8.15"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from callbacks import sidebar_callbacks

# import pages
from view import page_data_loading, page_overview, page_categorical_feature, page_na_value, page_outlier_detection, page_transformation_table_data, page_transformation_time_series, page_supervised_classification, page_supervised_regression
from view import page_data_loading, page_overview, page_categorical_feature, page_na_value, page_outlier_detection, page_transformation_time_series, page_supervised_classification, page_supervised_regression

# the styles for the main content position it to the right of the sidebar and
# add some padding.
Expand Down Expand Up @@ -41,7 +41,7 @@
id="page_content", style=CONTENT_STYLE
)

app.layout = html.Div([dcc.Location(id="url"), sidebar_, content])
app.layout = html.Div([dcc.Location(id="url", refresh=False), sidebar_, content])



Expand Down
Binary file added assets/img/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 71 additions & 4 deletions assets/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
.sidebar_link {
background-color: blue;
color: white;
text-transform: none;
margin-top: 0.5rem;
font-size: 16pt;
text-decoration: none;
padding: 1rem;
}

.sidebar_logo {
width: 30rem;
}

.sidebar_hr {
border-width: 0.3vh;
width: 100%;
border-color: black;
border-style: solid;
}

.sidebar_nav {
padding: 50px 50px 50px 50px
}

.sidebar_kit {
width: 10rem;
display: flex;
justify-content: center
}

.sidebar_report_bugs {
display: flex;
justify-content: center
}

.no-gutters .col {
padding-right: 0;
padding-left: 0;
Expand Down Expand Up @@ -224,13 +260,13 @@
margin-left: 1rem;
margin-top: 3rem;
margin-bottom: 2rem;
background-color: seagreen;
background-color: royalblue;
color: white;
}

.btn_apply, .btn_apply:hover, .btn_apply:active, .btn_apply:focus {
width: 10rem;
background-color: seagreen;
background-color: royalblue;
color: white;
margin-right: 1rem;
}
Expand All @@ -241,7 +277,7 @@
margin-left: 1rem;
margin-top: 1rem;
margin-bottom: 2rem;
background-color: seagreen;
background-color: royalblue;
color: white;
}

Expand Down Expand Up @@ -289,10 +325,41 @@
}

.dropdown_overview_single_feature {
width: 20rem;
width: 26.5rem;
margin-right: 1rem;
}

.dropdown_overview_target {
width: 21rem;
margin-left 1rem;
margin-right: 1rem;
display: inline-block;
margin-bottom: 1rem;
align-items: center;
}

.dropdown_overview_target_large {
width: 50rem;
margin-left 1rem;
margin-right: 1rem;
display: inline-block;
margin-bottom: 1rem;
align-items: center;
}

.dropdown_overview_index {
display: inline-block;
width: 20rem;
margin-bottom: 1rem;
align-items: center;
}

.text_overview_index {
display: inline-block;
margin-right: 0.5rem;
align-items: center;
}


.dropdown_overview_single_feature_full_width {
margin-right: 1rem;
Expand Down
Binary file not shown.
17 changes: 17 additions & 0 deletions callbacks/helper_callbacks/disable_component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def disable_link(style):
if style is None:
style = {}

style['pointer-events'] = 'none'
style['color'] = 'gray'

return style

def enable_link(style):
if style is None:
style = {}

style['pointer-events'] = 'auto'
style['color'] = 'royalblue'

return style
112 changes: 79 additions & 33 deletions callbacks/page_categorical_feature_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
from methods.cleaning import delete_columns

# import figures
from view.page_helper_components.plots import get_numeric_categorical_ratio_plot, get_categorical_feature_pie_plot
from view.page_helper_components.plots import get_numeric_categorical_ratio_plot, get_categorical_feature_pie_plot, get_overview_histogram_plot

# import utility
from methods.util import count_unique_values

@app.callback(
Output("figure_categorical_feature_pie", "figure"),
Output("container_feature_encoding", "style"),
Output("figure_categorical_feature_pie", "figure", allow_duplicate=True),
Input("dropdown_categorical_feature", "value"),
State("container_feature_encoding", "style"),
prevent_initial_call=True
)
def update_categorical_plot(col, style):
def update_categorical_plot(col):
if table_data.DF_RAW is None:
return dash.no_update

Expand All @@ -39,39 +38,51 @@ def update_categorical_plot(col, style):
if col is None or col == "" or triggered_id is None:
return dash.no_update

if col not in list(df_cat.columns):
if style is None:
style = {'display': 'none'}
else:
style['display'] = 'none'
return dash.no_update, style
df = compute_plot(table_data.DF_RAW, None, col, reset_index=True)
# draw Figure
figure = get_overview_histogram_plot(df, col)

counts = count_unique_values(df_cat, col)
return figure

@app.callback(
Output("container_feature_encoding", "style", allow_duplicate=True),
Input("dropdown_categorical_feature", "options"),
State("container_feature_encoding", "style"),
prevent_initial_call=True
)
def update_categorical_plot(options, style):
if table_data.DF_RAW is None:
return dash.no_update

figure = get_categorical_feature_pie_plot(counts)
if style is None:
style = {}

if options == []:
style['display'] = 'none'

return figure, style
return style


@app.callback(
# update categorical page
Output("alert_categorical_unconvertable_string", "is_open"),
Output("figure_categorical_feature_pie", "figure"),
Output("dropdown_categorical_feature", "options"),
Output("dropdown_categorical_feature", "value"),
Output("dropdown_replace_value1", "options"),
Output("dropdown_replace_value1", "value"),
Output("dropdown_replace_value2", "options"),
Output("dropdown_replace_value2", "value"),
Output("alert_categorical_unconvertable_string", "is_open", allow_duplicate=True),
Output("figure_categorical_feature_pie", "figure", allow_duplicate=True),
Output("dropdown_categorical_feature", "options", allow_duplicate=True),
Output("dropdown_categorical_feature", "value", allow_duplicate=True),
Output("dropdown_replace_value1", "options", allow_duplicate=True),
Output("dropdown_replace_value1", "value", allow_duplicate=True),
Output("dropdown_replace_value2", "options", allow_duplicate=True),
Output("dropdown_replace_value2", "value", allow_duplicate=True),
# update overview page
Output("datatable_overview", "data"),
Output("datatable_overview", "columns"),
Output("datatable_overview", "data", allow_duplicate=True),
Output("datatable_overview", "columns", allow_duplicate=True),
# inputs
Input("button_categorical_apply", "n_clicks"),
State("dropdown_categorical_feature", "value"),
State("dropdown_categorical_strategy", "value"),
State("dropdown_replace_value1", "value"),
State("dropdown_replace_value2", "value"),
prevent_initial_call=True
)
def update_df_after_encoding(n_clicks, col, strategy, in_str, out_str):
if table_data.DF_RAW is None:
Expand Down Expand Up @@ -103,7 +114,7 @@ def update_df_after_encoding(n_clicks, col, strategy, in_str, out_str):
# hide feature encoding when no more categorical features otherwise update parameter
if len(options_cat) > 0:
# if replacement selected update dropdowns
if strategy == ENCODING_STRATEGIES[3]:
if strategy == ENCODING_STRATEGIES[4]:
unique_values = table_data.DF_RAW[col].unique().tolist()

options_replacement = unique_values
Expand Down Expand Up @@ -147,8 +158,9 @@ def update_df_after_encoding(n_clicks, col, strategy, in_str, out_str):
return False, figure, options_cat, value, options_replacement, in_str, options_replacement, out_str, data_datatable_overview, columns_datatable_overview

@app.callback(
Output("exploration_categorical_feature_ratio_bar_plot", "figure"),
Output("exploration_categorical_feature_ratio_bar_plot", "figure", allow_duplicate=True),
Input("button_categorical_apply", "n_clicks"),
prevent_initial_call=True
)
def update_ratio(n_clicks):
if table_data.DF_RAW is None:
Expand All @@ -161,11 +173,12 @@ def update_ratio(n_clicks):
return figure

@app.callback(
Output("dropdown_replace_value1", "options"),
Output("dropdown_replace_value1", "value"),
Output("dropdown_replace_value2", "options"),
Output("dropdown_replace_value2", "value"),
Output("dropdown_replace_value1", "options", allow_duplicate=True),
Output("dropdown_replace_value1", "value", allow_duplicate=True),
Output("dropdown_replace_value2", "options", allow_duplicate=True),
Output("dropdown_replace_value2", "value", allow_duplicate=True),
Input("dropdown_categorical_feature", "value"),
prevent_initial_call=True
)
def update_replacement(col):
triggered_id = ctx.triggered_id
Expand All @@ -184,17 +197,50 @@ def update_replacement(col):
return options, value1, options, value2

@app.callback(
Output("card_categorical_replacement", "style"),
Output("card_categorical_replacement", "style", allow_duplicate=True),
Input("dropdown_categorical_strategy", "value"),
State("card_categorical_replacement", "style"),
prevent_initial_call=True
)
def update_parameter(strategy, style):
if strategy != ENCODING_STRATEGIES[3]:
if strategy != ENCODING_STRATEGIES[4]:
style['display'] = 'none'
else:
style['display'] = 'inline-block'
style['display'] = 'block'

return style

@app.callback(
Output("img_categorical_strategy", "src", allow_duplicate=True),
Output("link_categorical_strategy", "href", allow_duplicate=True),
Output("tooltip_categorical_strategy", "children", allow_duplicate=True),
Input("dropdown_categorical_strategy", "value"),
prevent_initial_call=True
)
def update_info(strategy):
if strategy == ENCODING_STRATEGIES[0]:
src = '/assets/img/link.png'
href = ENCODING_LINKS[0]
children = ENCODING_DESCRIPTIONS[0]
elif strategy == ENCODING_STRATEGIES[1]:
src = '/assets/img/link.png'
href = ENCODING_LINKS[1]
children = ENCODING_DESCRIPTIONS[1]
elif strategy == ENCODING_STRATEGIES[2]:
src = '/assets/img/link.png'
href = ENCODING_LINKS[2]
children = ENCODING_DESCRIPTIONS[2]
elif strategy == ENCODING_STRATEGIES[3]:
src = '/assets/img/tooltip.png'
href = ENCODING_LINKS[3]
children = ENCODING_DESCRIPTIONS[3]
elif strategy == ENCODING_STRATEGIES[4]:
src = '/assets/img/tooltip.png'
href = ENCODING_LINKS[4]
children = ENCODING_DESCRIPTIONS[4]
else:
return dash.no_update

return src, href, children


Loading

0 comments on commit 8e2dc71

Please sign in to comment.