Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import seaborn as sns
|
|
| 7 |
from sklearn.metrics import confusion_matrix, classification_report
|
| 8 |
from utils.preprocess import load_and_preprocess_dataset
|
| 9 |
from model.cnn_model import CNNModel
|
| 10 |
-
from model.
|
| 11 |
|
| 12 |
# Configuration de la page
|
| 13 |
st.set_page_config(
|
|
@@ -190,17 +190,16 @@ with tab2:
|
|
| 190 |
|
| 191 |
if 'X_train' in st.session_state:
|
| 192 |
st.subheader("Optimisation des Hyperparamètres")
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
with st.spinner("Optimisation en cours (peut prendre plusieurs minutes)..."):
|
| 196 |
try:
|
| 197 |
-
|
| 198 |
obj_func=objective_function,
|
| 199 |
bounds=bounds,
|
| 200 |
-
population_size=
|
| 201 |
-
max_iter=15
|
| 202 |
)
|
| 203 |
-
result =
|
| 204 |
|
| 205 |
st.session_state['best_params'] = {
|
| 206 |
'filter1': int(result['best_solution'][0]),
|
|
@@ -210,18 +209,18 @@ with tab2:
|
|
| 210 |
'dropout': result['best_solution'][4]
|
| 211 |
}
|
| 212 |
|
| 213 |
-
st.success("Optimisation terminée!")
|
| 214 |
st.json(st.session_state['best_params'])
|
| 215 |
-
|
| 216 |
-
#
|
| 217 |
-
st.subheader("Courbe de Convergence")
|
| 218 |
st.line_chart({
|
| 219 |
'Erreur Validation': result['convergence_curve'],
|
| 220 |
'Précision': [1 - x for x in result['convergence_curve']]
|
| 221 |
})
|
| 222 |
|
| 223 |
except Exception as e:
|
| 224 |
-
st.error(f"Erreur lors de l'optimisation : {str(e)}")
|
| 225 |
|
| 226 |
# Onglet 3: Résultats et export
|
| 227 |
with tab3:
|
|
|
|
| 7 |
from sklearn.metrics import confusion_matrix, classification_report
|
| 8 |
from utils.preprocess import load_and_preprocess_dataset
|
| 9 |
from model.cnn_model import CNNModel
|
| 10 |
+
from model.gwo import GWO
|
| 11 |
|
| 12 |
# Configuration de la page
|
| 13 |
st.set_page_config(
|
|
|
|
| 190 |
|
| 191 |
if 'X_train' in st.session_state:
|
| 192 |
st.subheader("Optimisation des Hyperparamètres")
|
| 193 |
+
if st.button("⚡ Optimiser avec GWO", type="primary"): # Changer le texte du bouton
|
| 194 |
+
with st.spinner("Optimisation en cours (GWO)..."):
|
|
|
|
| 195 |
try:
|
| 196 |
+
optimizer = GWO(
|
| 197 |
obj_func=objective_function,
|
| 198 |
bounds=bounds,
|
| 199 |
+
population_size=10, # Nombre de loups
|
| 200 |
+
max_iter=15 # Itérations
|
| 201 |
)
|
| 202 |
+
result = optimizer.optimize()
|
| 203 |
|
| 204 |
st.session_state['best_params'] = {
|
| 205 |
'filter1': int(result['best_solution'][0]),
|
|
|
|
| 209 |
'dropout': result['best_solution'][4]
|
| 210 |
}
|
| 211 |
|
| 212 |
+
st.success("Optimisation GWO terminée !")
|
| 213 |
st.json(st.session_state['best_params'])
|
| 214 |
+
|
| 215 |
+
# Affichage de la courbe de convergence
|
| 216 |
+
st.subheader("Courbe de Convergence (GWO)")
|
| 217 |
st.line_chart({
|
| 218 |
'Erreur Validation': result['convergence_curve'],
|
| 219 |
'Précision': [1 - x for x in result['convergence_curve']]
|
| 220 |
})
|
| 221 |
|
| 222 |
except Exception as e:
|
| 223 |
+
st.error(f"Erreur lors de l'optimisation GWO : {str(e)}")
|
| 224 |
|
| 225 |
# Onglet 3: Résultats et export
|
| 226 |
with tab3:
|