Skip to content
Snippets Groups Projects
Commit 4ffc38d7 authored by Caroline DE POURTALES's avatar Caroline DE POURTALES
Browse files

adding callbacks none

parent 38025bc8
No related branches found
No related tags found
No related merge requests found
Showing
with 68 additions and 203 deletions
.idea
__pycache__
pages/application/DecisionTree/utils/__pycache__
pages/application/DecisionTree/__pycache__
pages/application/__pycache__
tests/push_command
\ No newline at end of file
tests
venv
*.pyc
.DS_Store
.env
\ No newline at end of file
......@@ -7,39 +7,38 @@ from utils import parse_contents_graph, parse_contents_instance, parse_contents_
from pages.application.RandomForest.utils import xrf
from pages.application.RandomForest.utils.xrf import *
sys.modules['xrf'] = xrf
####### Creates alerts when callback fails #########
warning_selection_model = html.Div([dbc.Alert("You didn't choose a king of Machine Learning model first.",
is_open=True,
color='warning',
duration=10000, ), ])
def register_callbacks(page_home, page_course, page_application, app):
page_list = ['home', 'course', 'application']
warning_selection_pretrained_model = html.Div([dbc.Alert("You uploaded the data, now upload the pretrained model.",
is_open=True,
color='warning',
duration=10000, ), ])
####### Creates alerts when callback fails #########
alert_network = html.Div([dbc.Alert("There was a problem while computing the graph, read the documentation. \
You might have forgotten to upload the data for Random Forest or you tried to upload an unknown format.",
is_open=True,
color='danger',
duration=10000, ), ])
alert_explanation = html.Div([dbc.Alert(
"There was a problem while computing the explanation. Read the documentation to understand which king of format are accepted.",
is_open=True,
color='danger',
duration=10000, ), ])
alert_version_model = []
warning_selection_model = html.Div([dbc.Alert("You didn't choose a king of Machine Learning model first.",
is_open=True,
color='warning',
duration=10000, ), ])
warning_selection_pretrained_model = html.Div([dbc.Alert("You uploaded the data, now upload the pretrained model.",
is_open=True,
color='warning',
duration=10000, ), ])
######################################################
alert_network = html.Div([dbc.Alert("There was a problem while computing the graph, read the documentation. \
You might have forgotten to upload the data for Random Forest or you tried to upload an unknown format.",
is_open=True,
color='danger',
duration=10000, ), ])
alert_explanation = html.Div([dbc.Alert(
"There was a problem while computing the explanation. Read the documentation to understand which king of format are accepted.",
is_open=True,
color='danger',
duration=10000, ), ])
alert_version_model = []
def register_callbacks(page_home, page_course, page_application, app):
page_list = ['home', 'course', 'application']
######################################################
@app.callback(
Output('page-content', 'children'),
......@@ -74,25 +73,49 @@ def register_callbacks(page_home, page_course, page_application, app):
list(model_application.xtypes.keys())[0]]
@app.callback(Output('pretrained_model_filename', 'children'),
Input('ml_model_choice', 'value'),
Input('ml_pretrained_model_choice', 'filename'),
prevent_initial_call=True
)
def update_model_prertrained_name(pretrained_model_filename):
return pretrained_model_filename
def update_model_prertrained_name(value_ml_model, pretrained_model_filename):
ctx = dash.callback_context
if ctx.triggered:
ihm_id = ctx.triggered[0]['prop_id'].split('.')[0]
if ihm_id == 'ml_model_choice':
return None
else :
return pretrained_model_filename
@app.callback(Output('info_filename', 'children'),
Input('ml_model_choice', 'value'),
Input('model_info_choice', 'filename'),
prevent_initial_call=True
)
def update_model_info_filename(model_info_filename):
return model_info_filename
def update_model_info_filename(value_ml_model, model_info_filename):
ctx = dash.callback_context
if ctx.triggered:
ihm_id = ctx.triggered[0]['prop_id'].split('.')[0]
if ihm_id == 'ml_model_choice':
return None
else :
return model_info_filename
@app.callback(Output('instance_filename', 'children'),
Input('ml_model_choice', 'value'),
Input('ml_pretrained_model_choice', 'contents'),
Input('ml_instance_choice', 'filename'),
prevent_initial_call=True
)
def update_instance_filename(instance_filename):
return instance_filename
def update_instance_filename(value_ml_model, model_info_filename, instance_filename):
ctx = dash.callback_context
if ctx.triggered:
ihm_id = ctx.triggered[0]['prop_id'].split('.')[0]
if ihm_id == 'ml_model_choice':
return None
elif ihm_id == 'ml_pretrained_model_choice':
return None
else :
return instance_filename
@app.callback(
Output('graph', 'children'),
......
......@@ -53,6 +53,9 @@ class RandomForestComponent:
self.explanation.append(html.P(explanation_result[k]))
self.explanation.append(html.Hr())
del self.random_forest.enc
del self.random_forest.x
return [], []
def update_plotted_tree(self, tree_to_plot):
......
......@@ -7,6 +7,7 @@ from pages.application.NaiveBayes.NaiveBayesComponent import NaiveBayesComponent
from pages.application.RandomForest.RandomForestComponent import RandomForestComponent
class Application:
def __init__(self, view):
self.view = view
......@@ -56,8 +57,14 @@ class Model:
self.xtypes = self.dic_xtypes[self.ml_model]
self.xtype = [list(self.xtypes.keys())[0]]
#init all params
self.pretrained_model = None
self.model_info = None
self.instance = None
def update_pretrained_model(self, pretrained_model_update):
self.pretrained_model = pretrained_model_update
self.instance = None
def update_info_needed(self, add_info):
self.add_info = add_info
......
......@@ -2,7 +2,6 @@ colorlover>=0.2.1
scipy>=1.2.1
python-sat[pblib,aiger]
matplotlib==3.5.1
xgboost==1.6.0
lime==0.2.0.1
shap==0.40.0
anchor-exp==0.0.2.0
......@@ -18,8 +17,6 @@ json2html==1.3.0
numpy==1.21
pandas==1.4.1
pysat==3.0.1
pytest==7.0.1
python_sat==0.1.7.dev15
scikit_learn==1.0.2
six==1.16.0
gunicorn==20.1.0
......
File deleted
File deleted
File deleted
f0=1,f1=9,f2=9,f3=7,f4=9,f5=5,f6=7,f7=0,f8=5,f9=3,f10=0,f11=15
\ No newline at end of file
File deleted
"sepal.length","sepal.width","petal.length","petal.width","variety"
5.1,3.5,1.4,.2,"Setosa"
4.9,3,1.4,.2,"Setosa"
4.7,3.2,1.3,.2,"Setosa"
4.6,3.1,1.5,.2,"Setosa"
5,3.6,1.4,.2,"Setosa"
5.4,3.9,1.7,.4,"Setosa"
4.6,3.4,1.4,.3,"Setosa"
5,3.4,1.5,.2,"Setosa"
4.4,2.9,1.4,.2,"Setosa"
4.9,3.1,1.5,.1,"Setosa"
5.4,3.7,1.5,.2,"Setosa"
4.8,3.4,1.6,.2,"Setosa"
4.8,3,1.4,.1,"Setosa"
4.3,3,1.1,.1,"Setosa"
5.8,4,1.2,.2,"Setosa"
5.7,4.4,1.5,.4,"Setosa"
5.4,3.9,1.3,.4,"Setosa"
5.1,3.5,1.4,.3,"Setosa"
5.7,3.8,1.7,.3,"Setosa"
5.1,3.8,1.5,.3,"Setosa"
5.4,3.4,1.7,.2,"Setosa"
5.1,3.7,1.5,.4,"Setosa"
4.6,3.6,1,.2,"Setosa"
5.1,3.3,1.7,.5,"Setosa"
4.8,3.4,1.9,.2,"Setosa"
5,3,1.6,.2,"Setosa"
5,3.4,1.6,.4,"Setosa"
5.2,3.5,1.5,.2,"Setosa"
5.2,3.4,1.4,.2,"Setosa"
4.7,3.2,1.6,.2,"Setosa"
4.8,3.1,1.6,.2,"Setosa"
5.4,3.4,1.5,.4,"Setosa"
5.2,4.1,1.5,.1,"Setosa"
5.5,4.2,1.4,.2,"Setosa"
4.9,3.1,1.5,.2,"Setosa"
5,3.2,1.2,.2,"Setosa"
5.5,3.5,1.3,.2,"Setosa"
4.9,3.6,1.4,.1,"Setosa"
4.4,3,1.3,.2,"Setosa"
5.1,3.4,1.5,.2,"Setosa"
5,3.5,1.3,.3,"Setosa"
4.5,2.3,1.3,.3,"Setosa"
4.4,3.2,1.3,.2,"Setosa"
5,3.5,1.6,.6,"Setosa"
5.1,3.8,1.9,.4,"Setosa"
4.8,3,1.4,.3,"Setosa"
5.1,3.8,1.6,.2,"Setosa"
4.6,3.2,1.4,.2,"Setosa"
5.3,3.7,1.5,.2,"Setosa"
5,3.3,1.4,.2,"Setosa"
7,3.2,4.7,1.4,"Versicolor"
6.4,3.2,4.5,1.5,"Versicolor"
6.9,3.1,4.9,1.5,"Versicolor"
5.5,2.3,4,1.3,"Versicolor"
6.5,2.8,4.6,1.5,"Versicolor"
5.7,2.8,4.5,1.3,"Versicolor"
6.3,3.3,4.7,1.6,"Versicolor"
4.9,2.4,3.3,1,"Versicolor"
6.6,2.9,4.6,1.3,"Versicolor"
5.2,2.7,3.9,1.4,"Versicolor"
5,2,3.5,1,"Versicolor"
5.9,3,4.2,1.5,"Versicolor"
6,2.2,4,1,"Versicolor"
6.1,2.9,4.7,1.4,"Versicolor"
5.6,2.9,3.6,1.3,"Versicolor"
6.7,3.1,4.4,1.4,"Versicolor"
5.6,3,4.5,1.5,"Versicolor"
5.8,2.7,4.1,1,"Versicolor"
6.2,2.2,4.5,1.5,"Versicolor"
5.6,2.5,3.9,1.1,"Versicolor"
5.9,3.2,4.8,1.8,"Versicolor"
6.1,2.8,4,1.3,"Versicolor"
6.3,2.5,4.9,1.5,"Versicolor"
6.1,2.8,4.7,1.2,"Versicolor"
6.4,2.9,4.3,1.3,"Versicolor"
6.6,3,4.4,1.4,"Versicolor"
6.8,2.8,4.8,1.4,"Versicolor"
6.7,3,5,1.7,"Versicolor"
6,2.9,4.5,1.5,"Versicolor"
5.7,2.6,3.5,1,"Versicolor"
5.5,2.4,3.8,1.1,"Versicolor"
5.5,2.4,3.7,1,"Versicolor"
5.8,2.7,3.9,1.2,"Versicolor"
6,2.7,5.1,1.6,"Versicolor"
5.4,3,4.5,1.5,"Versicolor"
6,3.4,4.5,1.6,"Versicolor"
6.7,3.1,4.7,1.5,"Versicolor"
6.3,2.3,4.4,1.3,"Versicolor"
5.6,3,4.1,1.3,"Versicolor"
5.5,2.5,4,1.3,"Versicolor"
5.5,2.6,4.4,1.2,"Versicolor"
6.1,3,4.6,1.4,"Versicolor"
5.8,2.6,4,1.2,"Versicolor"
5,2.3,3.3,1,"Versicolor"
5.6,2.7,4.2,1.3,"Versicolor"
5.7,3,4.2,1.2,"Versicolor"
5.7,2.9,4.2,1.3,"Versicolor"
6.2,2.9,4.3,1.3,"Versicolor"
5.1,2.5,3,1.1,"Versicolor"
5.7,2.8,4.1,1.3,"Versicolor"
6.3,3.3,6,2.5,"Virginica"
5.8,2.7,5.1,1.9,"Virginica"
7.1,3,5.9,2.1,"Virginica"
6.3,2.9,5.6,1.8,"Virginica"
6.5,3,5.8,2.2,"Virginica"
7.6,3,6.6,2.1,"Virginica"
4.9,2.5,4.5,1.7,"Virginica"
7.3,2.9,6.3,1.8,"Virginica"
6.7,2.5,5.8,1.8,"Virginica"
7.2,3.6,6.1,2.5,"Virginica"
6.5,3.2,5.1,2,"Virginica"
6.4,2.7,5.3,1.9,"Virginica"
6.8,3,5.5,2.1,"Virginica"
5.7,2.5,5,2,"Virginica"
5.8,2.8,5.1,2.4,"Virginica"
6.4,3.2,5.3,2.3,"Virginica"
6.5,3,5.5,1.8,"Virginica"
7.7,3.8,6.7,2.2,"Virginica"
7.7,2.6,6.9,2.3,"Virginica"
6,2.2,5,1.5,"Virginica"
6.9,3.2,5.7,2.3,"Virginica"
5.6,2.8,4.9,2,"Virginica"
7.7,2.8,6.7,2,"Virginica"
6.3,2.7,4.9,1.8,"Virginica"
6.7,3.3,5.7,2.1,"Virginica"
7.2,3.2,6,1.8,"Virginica"
6.2,2.8,4.8,1.8,"Virginica"
6.1,3,4.9,1.8,"Virginica"
6.4,2.8,5.6,2.1,"Virginica"
7.2,3,5.8,1.6,"Virginica"
7.4,2.8,6.1,1.9,"Virginica"
7.9,3.8,6.4,2,"Virginica"
6.4,2.8,5.6,2.2,"Virginica"
6.3,2.8,5.1,1.5,"Virginica"
6.1,2.6,5.6,1.4,"Virginica"
7.7,3,6.1,2.3,"Virginica"
6.3,3.4,5.6,2.4,"Virginica"
6.4,3.1,5.5,1.8,"Virginica"
6,3,4.8,1.8,"Virginica"
6.9,3.1,5.4,2.1,"Virginica"
6.7,3.1,5.6,2.4,"Virginica"
6.9,3.1,5.1,2.3,"Virginica"
5.8,2.7,5.1,1.9,"Virginica"
6.8,3.2,5.9,2.3,"Virginica"
6.7,3.3,5.7,2.5,"Virginica"
6.7,3,5.2,2.3,"Virginica"
6.3,2.5,5,1.9,"Virginica"
6.5,3,5.2,2,"Virginica"
6.2,3.4,5.4,2.3,"Virginica"
5.9,3,5.1,1.8,"Virginica"
\ No newline at end of file
File deleted
sepal.length,Categorical,7.6,6.8,7.1,4.9,4.4,6.2,6,7.3,5.9,7.4,5.2,5.6,4.8,6.5,5.5,4.6,6.6,6.4,7,4.5,7.2,5.1,5.8,5.3,6.9,6.1,6.7,4.7,7.7,6.3,5.7,7.9,5.4,4.3,5
sepal.width,Categorical,4.2,4.4,3.1,2.4,2.9,2,3.8,4.1,4,3.2,2.7,3.3,2.2,2.5,2.3,3.6,3.5,3.9,2.8,2.6,3.7,3,3.4
petal.length,Categorical,4.2,4.9,4.4,6,5.9,5.2,5.6,4.8,1,5.5,4.6,6.6,1.1,3.8,1.5,6.4,4.1,4,4.5,1.6,3.3,1.4,5.1,1.7,5.8,3.5,3.6,5.3,1.9,6.9,6.1,6.7,4.7,3.9,1.2,1.3,6.3,5.7,3.7,5.4,3,4.3,5
petal.width,Categorical,2.4,.2,1,2,1.1,1.5,.6,.5,2.2,.3,1.6,1.4,2.5,1.7,2.3,1.8,2.1,1.9,1.2,1.3,.1,.4
\ No newline at end of file
{"sepal.length":4.9,
"sepal.width":3,
"petal.length":1.4,
"petal.width":0.2}
File deleted
sepal.length=4.3,sepal.width=2.0,petal.length=1.0,petal.width=0.1
\ No newline at end of file
f0=1,f1=0,f1=0,f1=1,f1=0,f1=0,f1=1,f1=1,f1=1,f1=1,f1=0,f1=0,f1=4,f1=0,f1=0,f1=1
\ No newline at end of file
1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,1
\ No newline at end of file
0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0
\ No newline at end of file
0,1,1,0,1,0,0,0,1,1,0,0,2,1,1,0
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment