Skip to content

Commit

Permalink
core: extracted static folder from app base into configs
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel committed Sep 16, 2024
1 parent 1bfb250 commit 1652d53
Show file tree
Hide file tree
Showing 1,262 changed files with 58 additions and 2,715 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ virtual_env
.vscode/
.idea
.git
instance

# sphinx docs
_build
Expand Down
4 changes: 4 additions & 0 deletions .idea/TESIS.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Dashboard/Dash_fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ def serve_layout():
app.config.suppress_callback_exceptions = True
app.layout = serve_layout

print('App Layout: ', app.layout)
11 changes: 8 additions & 3 deletions Dashboard/dataset/datasetLayout.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import plotly
from dash import dcc, html, dash_table
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
Expand Down Expand Up @@ -33,8 +34,11 @@ def generateDataSetDistributions(df: pd.DataFrame, feature, legendTranslations):
line=dict(color="royalblue", width=1, dash="dot"),
))
graph['graph_data'].append(
go.Bar(name=setText(legendTranslations, 'bars', 'dashboard.data.common.distributions.legend'), x=x, y=y,
width=0.5))
go.Bar(
name=setText(legendTranslations, 'bars', 'dashboard.data.common.distributions.legend'),
x=x, y=y, width=0.5,
marker=dict(color=['#095e49' for _ in range(len(x))])
))
return graph


Expand Down Expand Up @@ -209,7 +213,7 @@ def datasetLayout(dataTranslations):
),
], className="container")
],
)
),
],
className="section-content",
style={"margin": "auto"},
Expand Down Expand Up @@ -463,6 +467,7 @@ def replace_empty_values(x):
y=corr_matrix.columns,
text=round(corr_matrix, 2),
texttemplate="%{text}",
colorscale=['#c6efce', '#8bc34a', '#2f4f4f']
),
)
)
Expand Down
4 changes: 3 additions & 1 deletion Dashboard/importances/importancesLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def importancesLayout(importanceTranslations):
'dashboard.importance.classifier'),
)
], id='selector-container', hidden=True)),
], className="container")
], className="container"),
],
),
style={"padding-left": "30px", "padding-right": "30px", "margin": "auto"},
Expand Down Expand Up @@ -154,6 +154,7 @@ def graph_explainers(cl, positive_class):
x=setText(translationsGini, 'label-x', 'dashboard.importance.common.gini'),
y=setText(translationsGini, 'label-y', 'dashboard.importance.common.gini'),
title=setText(translationsGini, 'title', 'dashboard.importance.common.gini'),
color_discrete_sequence=['#0a5b35']
)

if not isRegressor:
Expand Down Expand Up @@ -209,6 +210,7 @@ def graph_explainers(cl, positive_class):
"importances_mean":
setText(translationsPermutation, 'label-x', 'dashboard.importance.common.permutation')
},
color_discrete_sequence=['#0b787d']
)
classifier_hint = html.Strong(setText(translationsClassifier, 'hint', 'dashboard.importance.classifier'))
return (
Expand Down
49 changes: 29 additions & 20 deletions Dashboard/metrics/metricsLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def generateDependencePlots(X: pd.DataFrame, qualitative_dict,
graph['graph_data'].append(
go.Bar(
name=setText(legendTranslations, 'bars', 'dashboard.metrics.regressor.partial-dependence.legend'),
x=x, y=y, width=0.5
x=x, y=y, width=0.5,
marker=dict(color=['#095e49' for _ in range(len(x))])
)
)

Expand Down Expand Up @@ -487,7 +488,7 @@ def __create_matrix(cm, class_names, matrixTranslations):
x=class_names,
y=class_names,
text_auto=True,
color_continuous_scale="Blues",
color_continuous_scale=["white", "aqua", "#095e49"],
)
return fig

Expand Down Expand Up @@ -1019,15 +1020,19 @@ def graph_pred_vs_real(cl):
)
y = regressor_dataset[model_x.getElement('target_row')]
y_pred = regressor_model.predict(regressor_dataset.drop(columns=model_x.getElement('target_row')))
fig = px.scatter(x=y, y=y_pred, title=setText(regressorPredRealTranslations, 'title',
'dashboard.metrics.regressor.prediction-real'),
marginal_y='histogram',
labels={
'x': setText(regressorPredRealLabelsTranslations, 'x',
'dashboard.metrics.regressor.prediction-real.labels'),
'y': setText(regressorPredRealLabelsTranslations, 'y',
'dashboard.metrics.regressor.prediction-real.labels')
})
fig = px.scatter(
x=y, y=y_pred,
title=setText(regressorPredRealTranslations, 'title',
'dashboard.metrics.regressor.prediction-real'),
marginal_y='histogram',
labels={
'x': setText(regressorPredRealLabelsTranslations, 'x',
'dashboard.metrics.regressor.prediction-real.labels'),
'y': setText(regressorPredRealLabelsTranslations, 'y',
'dashboard.metrics.regressor.prediction-real.labels')
},
color_discrete_sequence=['#0a5b35']
)
fig.add_shape(
type="line", line=dict(dash='dash'),
x0=y.min(), y0=y.min(),
Expand All @@ -1036,15 +1041,19 @@ def graph_pred_vs_real(cl):

fig_1 = dcc.Graph(figure=fig)

fig = px.scatter(x=y_pred, y=y, title=setText(regressorRealPredTranslations, 'title',
'dashboard.metrics.regressor.real-prediction'),
marginal_y='histogram',
labels={
'x': setText(regressorRealPredLabelsTranslations, 'x',
'dashboard.metrics.regressor.real-prediction.labels'),
'y': setText(regressorRealPredLabelsTranslations, 'y',
'dashboard.metrics.regressor.real-prediction.labels')
})
fig = px.scatter(
x=y_pred, y=y,
title=setText(regressorRealPredTranslations, 'title',
'dashboard.metrics.regressor.real-prediction'),
marginal_y='histogram',
labels={
'x': setText(regressorRealPredLabelsTranslations, 'x',
'dashboard.metrics.regressor.real-prediction.labels'),
'y': setText(regressorRealPredLabelsTranslations, 'y',
'dashboard.metrics.regressor.real-prediction.labels')
},
color_discrete_sequence=['#0b787d']
)
fig.add_shape(
type="line", line=dict(dash='dash'),
x0=y_pred.min(), y0=y_pred.min(),
Expand Down
17 changes: 9 additions & 8 deletions Dashboard/predictions/predictionsLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def getTreeInterpreterParamethersRegressor(
f" ({round(point, 3)}) "
f"{round((point / (prediction[0][0] if prediction[0][0] > 0 else 1) * 100), 2)} %",
line=dict(dash="dash"),
marker_color=["blue", "blue"],
marker_color=["#095e49", "#095e49"],
)
)

Expand Down Expand Up @@ -240,7 +240,7 @@ def getTreeInterpreterParamethersClassifier(
mode="lines",
name=f"{actual} ({round(point, 3)}) {round((point / (prediction[0][index] if prediction[0][index] > 0 else 1) * 100), 2)} %",
line=dict(dash="dash"),
marker_color=["blue", "blue"],
marker_color=["#095e49", "#095e49"],
)
)

Expand All @@ -262,6 +262,7 @@ def getIndividualPredictionsRegressor(model: RandomForestRegressor, instance, tr
name=setText(treesTranslations, 'bar-title', 'dashboard.predictions.regressor.trees'),
y=np.round(sorted(individual_predictions), 2),
x=x[1:],
marker=dict(color=['#095e49' for _ in range(len(x[1:]))])
),
go.Scatter(
name=setText(treesTranslations, 'line-title', 'dashboard.predictions.regressor.trees'),
Expand Down Expand Up @@ -295,19 +296,19 @@ def getIndividualPredictionsClassifier(model, class_names, instance, cut_point,
markers = []
for val in np.array(individual_predictions)[:, index]:
if val * 100 >= cut_point:
markers.append("blue")
markers.append("#095e49")
else:
markers.append("red")
markers.append("#ba3333")

sorted_predictions = sorted(
zip(np.array(individual_predictions)[:, index], markers),
key=lambda x: (-x[0] if markers.count("blue") > markers.count("red") else x[0]),
key=lambda x: (-x[0] if markers.count("#095e49") > markers.count("#ba3333") else x[0]),
)
predictions_for_actual_clase = np.array(sorted_predictions)[:, 0]
prev_x = list(range(len(predictions_for_actual_clase) + 1))
x = (
prev_x[1:]
if markers.count("blue") > markers.count("red")
if markers.count("#095e49") > markers.count("#ba3333")
else prev_x[::-1][:-1]
)
y = np.round(predictions_for_actual_clase.astype(np.float64) * 100, 2)
Expand All @@ -320,7 +321,7 @@ def getIndividualPredictionsClassifier(model, class_names, instance, cut_point,
marker_color=np.array(sorted_predictions)[:, 1],
), go.Scatter(
name=setText(treesTranslations, 'line-title', 'dashboard.predictions.classifier.trees'),
x=[1, x[0]] if markers.count("blue") < markers.count("red") else [x[-1], 1],
x=[1, x[0]] if markers.count("#095e49") < markers.count("#ba3333") else [x[-1], 1],
y=[cut_point, cut_point],
mode="lines",
line=dict(dash="dash"),
Expand All @@ -335,7 +336,7 @@ def getIndividualPredictionsClassifier(model, class_names, instance, cut_point,
bargap=0.1,
xaxis=dict(
autorange=(
"reversed" if markers.count("blue") > markers.count("red") else True
"reversed" if markers.count("#095e49 ") > markers.count("#ba3333") else True
)
),
)
Expand Down
19 changes: 1 addition & 18 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
MIT License

Copyright (c) 2017 Antoine Fourmy
Copyright (c) 2024 Manuel Alfonso Rodríguez CUJAE

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ This project integrates Gentelella with Flask using:
- [flask_migrate](https://flask-migrate.readthedocs.io/en/latest/).
- [dash](https://dash.plot.ly/).

Here is an example of a real project implemented using Flask-Gentelella:
- [Online demo](http://afourmy.pythonanywhere.com/)
- [Source code](https://github.com/afourmy/eNMS)

## Install requirements
pipenv sync
or
Expand Down
135 changes: 0 additions & 135 deletions Tree

This file was deleted.

Loading

0 comments on commit 1652d53

Please sign in to comment.