Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,7 +58,7 @@ def train_and_predict(file_obj):
|
|
| 58 |
scored = all_features.groupby("number")["prob"].mean().reset_index()
|
| 59 |
scored.columns = ["number", "score"]
|
| 60 |
|
| 61 |
-
#
|
| 62 |
top15 = scored.sort_values("score", ascending=False).head(15)["number"].tolist()
|
| 63 |
top6 = scored.sort_values("score", ascending=False).head(6)["number"].tolist()
|
| 64 |
|
|
@@ -83,16 +83,23 @@ def train_and_predict(file_obj):
|
|
| 83 |
debug_log.append(f"👉 Fallback Top 15: {top15}")
|
| 84 |
debug_log.append(f"👉 Fallback Top 6: {top6}")
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# --- Record history ---
|
| 87 |
today = datetime.now().strftime("%Y-%m-%d")
|
| 88 |
-
prediction_history.append({"date": today, "top15": top15, "top6": top6})
|
| 89 |
if len(prediction_history) > 12:
|
| 90 |
prediction_history.pop(0)
|
| 91 |
|
| 92 |
# Format history
|
| 93 |
history_lines = []
|
| 94 |
for row in prediction_history:
|
| 95 |
-
history_lines.append(
|
|
|
|
|
|
|
| 96 |
|
| 97 |
log_output = "\n".join(debug_log) + "\n\n📊 Prediction History (last 12 runs):\n" + "\n".join(history_lines)
|
| 98 |
|
|
@@ -104,7 +111,7 @@ demo = gr.Interface(
|
|
| 104 |
inputs=gr.File(file_types=[".txt", ".csv"], label="Upload Toto650.txt"),
|
| 105 |
outputs=gr.Textbox(label="Training, Predictions & History", lines=25),
|
| 106 |
title="Sure Win Club - Star Toto 6/50 Predictor (System 15 + System 6)",
|
| 107 |
-
description="Upload Toto650.txt after each draw.
|
| 108 |
)
|
| 109 |
|
| 110 |
if __name__ == "__main__":
|
|
@@ -117,3 +124,4 @@ if __name__ == "__main__":
|
|
| 117 |
|
| 118 |
|
| 119 |
|
|
|
|
|
|
| 58 |
scored = all_features.groupby("number")["prob"].mean().reset_index()
|
| 59 |
scored.columns = ["number", "score"]
|
| 60 |
|
| 61 |
+
# Predictions
|
| 62 |
top15 = scored.sort_values("score", ascending=False).head(15)["number"].tolist()
|
| 63 |
top6 = scored.sort_values("score", ascending=False).head(6)["number"].tolist()
|
| 64 |
|
|
|
|
| 83 |
debug_log.append(f"👉 Fallback Top 15: {top15}")
|
| 84 |
debug_log.append(f"👉 Fallback Top 6: {top6}")
|
| 85 |
|
| 86 |
+
# --- Evaluation: compare Top 6 with last draw ---
|
| 87 |
+
last_draw = set(df.iloc[-1][["n1", "n2", "n3", "n4", "n5", "n6"]].tolist())
|
| 88 |
+
hits = len(last_draw.intersection(top6))
|
| 89 |
+
debug_log.append(f"✅ Evaluation: Top 6 matched {hits}/6 with last draw {sorted(last_draw)}")
|
| 90 |
+
|
| 91 |
# --- Record history ---
|
| 92 |
today = datetime.now().strftime("%Y-%m-%d")
|
| 93 |
+
prediction_history.append({"date": today, "top15": top15, "top6": top6, "hits": hits})
|
| 94 |
if len(prediction_history) > 12:
|
| 95 |
prediction_history.pop(0)
|
| 96 |
|
| 97 |
# Format history
|
| 98 |
history_lines = []
|
| 99 |
for row in prediction_history:
|
| 100 |
+
history_lines.append(
|
| 101 |
+
f"{row['date']} | Top 15: {row['top15']} | Top 6: {row['top6']} | Hits: {row['hits']}/6"
|
| 102 |
+
)
|
| 103 |
|
| 104 |
log_output = "\n".join(debug_log) + "\n\n📊 Prediction History (last 12 runs):\n" + "\n".join(history_lines)
|
| 105 |
|
|
|
|
| 111 |
inputs=gr.File(file_types=[".txt", ".csv"], label="Upload Toto650.txt"),
|
| 112 |
outputs=gr.Textbox(label="Training, Predictions & History", lines=25),
|
| 113 |
title="Sure Win Club - Star Toto 6/50 Predictor (System 15 + System 6)",
|
| 114 |
+
description="Upload Toto650.txt after each draw. Predicts both Top 15 (System 15) and Top 6 (single ticket). Auto-evaluates Top 6 against latest draw. Keeps history of last 12 runs."
|
| 115 |
)
|
| 116 |
|
| 117 |
if __name__ == "__main__":
|
|
|
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
+
|