Spaces:
Sleeping
Sleeping
Pareil
Browse files
src/config/GPT2_Fine_Tuning_model_report_gpt_2_simple.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"created_at": "2025-12-07T16:23:15.572017Z",
|
| 3 |
+
"task": "language_modeling",
|
| 4 |
+
"target": "next_token_prediction",
|
| 5 |
+
"framework": "gpt_2_simple",
|
| 6 |
+
"dataset": {
|
| 7 |
+
"file": "\\fine_tuning\\description.txt",
|
| 8 |
+
"size_bytes": 769167,
|
| 9 |
+
"tokens": 208095
|
| 10 |
+
},
|
| 11 |
+
"model": {
|
| 12 |
+
"base_model_name": "124M",
|
| 13 |
+
"run_name": "run3",
|
| 14 |
+
"checkpoint_dir": "\\checkpoint\\run3",
|
| 15 |
+
"total_params": 0,
|
| 16 |
+
"size_mb": 0.0
|
| 17 |
+
},
|
| 18 |
+
"training": {
|
| 19 |
+
"steps": 200,
|
| 20 |
+
"restore_from": "fresh",
|
| 21 |
+
"batch_size": 1,
|
| 22 |
+
"learning_rate": 0.0001,
|
| 23 |
+
"optimizer": "Adam"
|
| 24 |
+
},
|
| 25 |
+
"metrics": {
|
| 26 |
+
"loss": 2.04,
|
| 27 |
+
"avg": 2.29,
|
| 28 |
+
"notes": "No explicit loss tracking from gpt_2_simple; metrics left to None."
|
| 29 |
+
}
|
| 30 |
+
}
|
src/config/execution_generator_model_report.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"created_at": "2025-12-07T17:13:48.852853Z",
|
| 3 |
+
"task": "language_modeling",
|
| 4 |
+
"target": "next_token_prediction (execution_generation)",
|
| 5 |
+
"n_train_samples": 1347,
|
| 6 |
+
"n_val_samples": 150,
|
| 7 |
+
"sequence_length": 128,
|
| 8 |
+
"device": "cpu",
|
| 9 |
+
"model": {
|
| 10 |
+
"name": "transformer_execution_generator_v3",
|
| 11 |
+
"type": "CausalLM_FineTuned",
|
| 12 |
+
"class": "GPT2LMHeadModel",
|
| 13 |
+
"checkpoint_base": "gpt2",
|
| 14 |
+
"total_params": 124439808,
|
| 15 |
+
"trainable_params": 124439808,
|
| 16 |
+
"size_mb": 474.7
|
| 17 |
+
},
|
| 18 |
+
"training": {
|
| 19 |
+
"epochs": 8,
|
| 20 |
+
"learning_rate": 3e-05,
|
| 21 |
+
"batch_size": 32,
|
| 22 |
+
"seed_global": 42,
|
| 23 |
+
"optimizer": "AdamW"
|
| 24 |
+
},
|
| 25 |
+
"metrics": {
|
| 26 |
+
"final_train_loss": 1.2690867379654285,
|
| 27 |
+
"final_val_loss": 1.293086338043213,
|
| 28 |
+
"best_val_loss": 1.293086338043213,
|
| 29 |
+
"best_loss": 1.293086338043213
|
| 30 |
+
}
|
| 31 |
+
}
|
src/config/model_report.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"created_at": "2025-12-03T09:04:03.083507Z",
|
| 3 |
+
"target": "Experience_Level",
|
| 4 |
+
"n_features": 8,
|
| 5 |
+
"n_test_samples": 2999,
|
| 6 |
+
"metrics_by_model": {
|
| 7 |
+
"Linear Regression": {
|
| 8 |
+
"MAE": 1.0702313301015012,
|
| 9 |
+
"RMSE": 1.3044658413432206,
|
| 10 |
+
"R2": -0.7023841026300084
|
| 11 |
+
},
|
| 12 |
+
"Random Forest": {
|
| 13 |
+
"MAE": 0.037401182031597605,
|
| 14 |
+
"RMSE": 0.09026074714124309,
|
| 15 |
+
"R2": 0.9918493924787138
|
| 16 |
+
},
|
| 17 |
+
"Bagging Regressor": {
|
| 18 |
+
"MAE": 0.03729884069670664,
|
| 19 |
+
"RMSE": 0.09030304487293238,
|
| 20 |
+
"R2": 0.9918417516603214
|
| 21 |
+
},
|
| 22 |
+
"Gradient Boosting": {
|
| 23 |
+
"MAE": 0.330239336587384,
|
| 24 |
+
"RMSE": 0.42489344861201594,
|
| 25 |
+
"R2": 0.8193856708756857
|
| 26 |
+
},
|
| 27 |
+
"KNN Regressor": {
|
| 28 |
+
"MAE": 0.15201366322234064,
|
| 29 |
+
"RMSE": 0.31524115755224025,
|
| 30 |
+
"R2": 0.9005790382902003
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"selected_model": {
|
| 34 |
+
"model_type": "Random Forest",
|
| 35 |
+
"model_class": "RandomForestRegressor",
|
| 36 |
+
"model_path": "C:\\Users\\fback\\Desktop\\Projets\\Dev\\GitHub\\train.me\\src\\models\\v1\\life_style_data\\model.joblib",
|
| 37 |
+
"params": {
|
| 38 |
+
"bootstrap": true,
|
| 39 |
+
"ccp_alpha": 0.0,
|
| 40 |
+
"criterion": "squared_error",
|
| 41 |
+
"max_depth": null,
|
| 42 |
+
"max_features": 1.0,
|
| 43 |
+
"max_leaf_nodes": null,
|
| 44 |
+
"max_samples": null,
|
| 45 |
+
"min_impurity_decrease": 0.0,
|
| 46 |
+
"min_samples_leaf": 1,
|
| 47 |
+
"min_samples_split": 2,
|
| 48 |
+
"min_weight_fraction_leaf": 0.0,
|
| 49 |
+
"monotonic_cst": null,
|
| 50 |
+
"n_estimators": 200,
|
| 51 |
+
"n_jobs": null,
|
| 52 |
+
"oob_score": false,
|
| 53 |
+
"random_state": 42,
|
| 54 |
+
"verbose": 0,
|
| 55 |
+
"warm_start": false
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
}
|
src/gradio/config.py
CHANGED
|
@@ -5,7 +5,7 @@ from huggingface_hub import hf_hub_download
|
|
| 5 |
|
| 6 |
# ---- Chaînes centralisées (sans logique) ----
|
| 7 |
# Dossiers / fichiers "métier"
|
| 8 |
-
MODEL_SUBDIR = ("
|
| 9 |
# MODEL_FILENAME = "model.joblib"
|
| 10 |
# SCHEMA_FILENAME = "feature_schema.json"
|
| 11 |
REPORT_FILENAME = "model_report.json"
|
|
|
|
| 5 |
|
| 6 |
# ---- Chaînes centralisées (sans logique) ----
|
| 7 |
# Dossiers / fichiers "métier"
|
| 8 |
+
MODEL_SUBDIR = ("config")
|
| 9 |
# MODEL_FILENAME = "model.joblib"
|
| 10 |
# SCHEMA_FILENAME = "feature_schema.json"
|
| 11 |
REPORT_FILENAME = "model_report.json"
|
src/gradio/generators/execution_generator.py
CHANGED
|
@@ -13,7 +13,7 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
| 13 |
# ---------------------------------------------------------------------
|
| 14 |
|
| 15 |
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
| 16 |
-
MODEL_DIR = PROJECT_ROOT / "
|
| 17 |
|
| 18 |
# Dossier de ton modèle finetuné d'exécution
|
| 19 |
# EXEC_MODEL_DIR = MODEL_DIR / "transformer_execution_generator_v3"
|
|
|
|
| 13 |
# ---------------------------------------------------------------------
|
| 14 |
|
| 15 |
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
| 16 |
+
MODEL_DIR = PROJECT_ROOT / "config"
|
| 17 |
|
| 18 |
# Dossier de ton modèle finetuné d'exécution
|
| 19 |
# EXEC_MODEL_DIR = MODEL_DIR / "transformer_execution_generator_v3"
|
src/gradio/pages/ml_tab.py
CHANGED
|
@@ -111,14 +111,24 @@ def render_ml_tab(
|
|
| 111 |
precision=2,
|
| 112 |
)
|
| 113 |
|
| 114 |
-
# Nouveau champ texte interprétation du niveau
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
level_out = gr.Textbox(
|
| 116 |
label="Physical level (text)",
|
| 117 |
-
|
|
|
|
|
|
|
| 118 |
lines=1,
|
| 119 |
max_lines=1,
|
| 120 |
)
|
| 121 |
|
|
|
|
| 122 |
meta_out = gr.Textbox(
|
| 123 |
label="Informations",
|
| 124 |
interactive=False,
|
|
@@ -153,6 +163,22 @@ def render_ml_tab(
|
|
| 153 |
gr.Markdown("---")
|
| 154 |
|
| 155 |
# ====== Prédiction ======
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
def _interpret_level(y_val) -> str:
|
| 158 |
"""Map numeric prediction to textual level."""
|
|
@@ -203,7 +229,7 @@ def render_ml_tab(
|
|
| 203 |
payload["Workout_Frequency (days/week)"]
|
| 204 |
)
|
| 205 |
|
| 206 |
-
|
| 207 |
payload=payload,
|
| 208 |
internal_expected=internal_expected,
|
| 209 |
model=model,
|
|
@@ -216,16 +242,23 @@ def render_ml_tab(
|
|
| 216 |
encoder=encoder,
|
| 217 |
)
|
| 218 |
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
print("[DEBUG] meta =", meta)
|
| 221 |
|
| 222 |
-
level_text = xp_to_label_safe(
|
| 223 |
info_text = str(meta)
|
| 224 |
|
| 225 |
print("[DEBUG] level_text =", level_text)
|
| 226 |
print("[DEBUG] info_text =", info_text)
|
| 227 |
|
| 228 |
-
|
| 229 |
# 2) Calcul BMI & Body Fat %
|
| 230 |
bmi = None
|
| 231 |
fat_pct = None
|
|
@@ -240,9 +273,7 @@ def render_ml_tab(
|
|
| 240 |
|
| 241 |
if bmi is not None and age_val not in (None, ""):
|
| 242 |
age_f = float(age_val)
|
| 243 |
-
# 1 = homme, 0 = femme (IMG formule classique)
|
| 244 |
sex_flag = 1.0 if gender_raw.startswith("m") else 0.0
|
| 245 |
-
|
| 246 |
fat_pct = 1.20 * bmi + 0.23 * age_f - 10.8 * sex_flag - 5.4
|
| 247 |
fat_pct = round(fat_pct, 2)
|
| 248 |
except Exception:
|
|
@@ -250,7 +281,7 @@ def render_ml_tab(
|
|
| 250 |
fat_pct = None
|
| 251 |
|
| 252 |
# 4) Retourner les 5 sorties Gradio
|
| 253 |
-
return
|
| 254 |
|
| 255 |
btn.click(_fn, comps, [y_out, level_out, bmi_out, fat_out, meta_out])
|
| 256 |
|
|
|
|
| 111 |
precision=2,
|
| 112 |
)
|
| 113 |
|
| 114 |
+
# # Nouveau champ texte interprétation du niveau
|
| 115 |
+
# level_out = gr.Textbox(
|
| 116 |
+
# label="Physical level (text)",
|
| 117 |
+
# interactive=False,
|
| 118 |
+
# lines=1,
|
| 119 |
+
# max_lines=1,
|
| 120 |
+
# )
|
| 121 |
+
|
| 122 |
level_out = gr.Textbox(
|
| 123 |
label="Physical level (text)",
|
| 124 |
+
value="", # ou "—" si tu veux un placeholder visuel
|
| 125 |
+
placeholder="Prediction will appear here",
|
| 126 |
+
interactive=True,
|
| 127 |
lines=1,
|
| 128 |
max_lines=1,
|
| 129 |
)
|
| 130 |
|
| 131 |
+
|
| 132 |
meta_out = gr.Textbox(
|
| 133 |
label="Informations",
|
| 134 |
interactive=False,
|
|
|
|
| 163 |
gr.Markdown("---")
|
| 164 |
|
| 165 |
# ====== Prédiction ======
|
| 166 |
+
def _to_scalar(x):
|
| 167 |
+
"""
|
| 168 |
+
Transforme n'importe quoi (np.array, liste, scalaire) en float Python.
|
| 169 |
+
Retourne None si on ne peut vraiment rien faire.
|
| 170 |
+
"""
|
| 171 |
+
try:
|
| 172 |
+
if isinstance(x, np.ndarray):
|
| 173 |
+
if x.shape == ():
|
| 174 |
+
return float(x)
|
| 175 |
+
if x.size == 1:
|
| 176 |
+
return float(x.ravel()[0])
|
| 177 |
+
if isinstance(x, (list, tuple)) and len(x) == 1:
|
| 178 |
+
return float(x[0])
|
| 179 |
+
return float(x)
|
| 180 |
+
except Exception:
|
| 181 |
+
return None
|
| 182 |
|
| 183 |
def _interpret_level(y_val) -> str:
|
| 184 |
"""Map numeric prediction to textual level."""
|
|
|
|
| 229 |
payload["Workout_Frequency (days/week)"]
|
| 230 |
)
|
| 231 |
|
| 232 |
+
y_xp_raw, meta = predict_single(
|
| 233 |
payload=payload,
|
| 234 |
internal_expected=internal_expected,
|
| 235 |
model=model,
|
|
|
|
| 242 |
encoder=encoder,
|
| 243 |
)
|
| 244 |
|
| 245 |
+
# --- sécuriser la valeur numérique pour Gradio ---
|
| 246 |
+
y_xp = _to_scalar(y_xp_raw)
|
| 247 |
+
if y_xp is None:
|
| 248 |
+
y_xp_display = 0.0
|
| 249 |
+
else:
|
| 250 |
+
y_xp_display = round(float(y_xp), 2)
|
| 251 |
+
|
| 252 |
+
print("[DEBUG] y_xp_raw =", y_xp_raw)
|
| 253 |
+
print("[DEBUG] y_xp_scalar =", y_xp_display)
|
| 254 |
print("[DEBUG] meta =", meta)
|
| 255 |
|
| 256 |
+
level_text = xp_to_label_safe(y_xp_display)
|
| 257 |
info_text = str(meta)
|
| 258 |
|
| 259 |
print("[DEBUG] level_text =", level_text)
|
| 260 |
print("[DEBUG] info_text =", info_text)
|
| 261 |
|
|
|
|
| 262 |
# 2) Calcul BMI & Body Fat %
|
| 263 |
bmi = None
|
| 264 |
fat_pct = None
|
|
|
|
| 273 |
|
| 274 |
if bmi is not None and age_val not in (None, ""):
|
| 275 |
age_f = float(age_val)
|
|
|
|
| 276 |
sex_flag = 1.0 if gender_raw.startswith("m") else 0.0
|
|
|
|
| 277 |
fat_pct = 1.20 * bmi + 0.23 * age_f - 10.8 * sex_flag - 5.4
|
| 278 |
fat_pct = round(fat_pct, 2)
|
| 279 |
except Exception:
|
|
|
|
| 281 |
fat_pct = None
|
| 282 |
|
| 283 |
# 4) Retourner les 5 sorties Gradio
|
| 284 |
+
return y_xp_display, level_text, bmi, fat_pct, info_text
|
| 285 |
|
| 286 |
btn.click(_fn, comps, [y_out, level_out, bmi_out, fat_out, meta_out])
|
| 287 |
|