Riy777 commited on
Commit
7744728
·
1 Parent(s): 165d676

Update ml_engine/sniper_engine.py

Browse files
Files changed (1) hide show
  1. ml_engine/sniper_engine.py +14 -8
ml_engine/sniper_engine.py CHANGED
@@ -1,6 +1,6 @@
1
  # ============================================================
2
- # 🎯 ml_engine/sniper_engine.py (V1.0 - L2 Entry Sniper)
3
- # هذا هو "الحارس V3" الذي بنيناه ناد الدخول)
4
  # ============================================================
5
 
6
  import os
@@ -15,7 +15,7 @@ import traceback
15
  from typing import List, Dict, Any
16
 
17
  # --- [ 💡 💡 💡 ] ---
18
- # [ 🚀 🚀 🚀 ] العتبة الافتراضية (بناءً على طلبك بعد الاختبار المنفصل)
19
  DEFAULT_SNIPER_THRESHOLD = 0.60
20
  # [ 🚀 🚀 🚀 ]
21
  # --- [ 💡 💡 💡 ] ---
@@ -113,14 +113,18 @@ def _add_standard_features(df):
113
  # ============================================================
114
 
115
  class SniperEngine:
116
- def __init__(self, base_project_dir: str):
 
 
 
117
  """
118
  تهيئة محرك قناص الدخول V1 (L2 Sniper).
119
  Args:
120
- base_project_dir: المسار الرئيسي للمشروع (Guard_Project)
121
  """
122
- # (نحمل النماذج من 'Models_V3' الذي أنشأناه)
123
- self.models_dir = os.path.join(base_project_dir, "Models_V3")
 
124
  self.models: List[lgb.Booster] = []
125
  self.feature_names: List[str] = []
126
 
@@ -138,9 +142,11 @@ class SniperEngine:
138
  """
139
  print(f"🎯 [SniperEngine V1] جاري التهيئة من {self.models_dir}...")
140
  try:
 
141
  model_files = [f for f in os.listdir(self.models_dir) if f.startswith('lgbm_guard_v3_fold_')]
142
  if len(model_files) < N_SPLITS:
143
  print(f"❌ [SniperEngine V1] خطأ فادح: تم العثور على {len(model_files)} نماذج فقط، مطلوب {N_SPLITS}.")
 
144
  return
145
 
146
  for f in sorted(model_files):
@@ -162,7 +168,7 @@ class SniperEngine:
162
  """
163
  السماح بتغيير العتبة أثناء التشغيل.
164
  """
165
- if 0.30 <= new_threshold <= 0.70:
166
  print(f"🎯 [SniperEngine V1] تم تحديث العتبة من {self.threshold} إلى {new_threshold}")
167
  self.threshold = new_threshold
168
  else:
 
1
  # ============================================================
2
+ # 🎯 ml_engine/sniper_engine.py (V1.1 - L2 Entry Sniper)
3
+ # (معدل ليقرأ النماذج من نفس مجلد Guard V2)
4
  # ============================================================
5
 
6
  import os
 
15
  from typing import List, Dict, Any
16
 
17
  # --- [ 💡 💡 💡 ] ---
18
+ # [ 🚀 🚀 🚀 ] العتبة الافتراضية (بناءً على طلبك 0.60)
19
  DEFAULT_SNIPER_THRESHOLD = 0.60
20
  # [ 🚀 🚀 🚀 ]
21
  # --- [ 💡 💡 💡 ] ---
 
113
  # ============================================================
114
 
115
  class SniperEngine:
116
+
117
+ # [ 🚀 🚀 🚀 ]
118
+ # [ 💡 💡 💡 ] التعديل: تغيير __init__ ليطابق GuardEngine
119
+ def __init__(self, models_dir: str):
120
  """
121
  تهيئة محرك قناص الدخول V1 (L2 Sniper).
122
  Args:
123
+ models_dir: المسار المباشر للمجلد (e.g., "ml_models/guard_v2")
124
  """
125
+ self.models_dir = models_dir
126
+ # [ 🚀 🚀 🚀 ]
127
+
128
  self.models: List[lgb.Booster] = []
129
  self.feature_names: List[str] = []
130
 
 
142
  """
143
  print(f"🎯 [SniperEngine V1] جاري التهيئة من {self.models_dir}...")
144
  try:
145
+ # (سيبحث الآن داخل 'ml_models/guard_v2/' عن هذه الملفات)
146
  model_files = [f for f in os.listdir(self.models_dir) if f.startswith('lgbm_guard_v3_fold_')]
147
  if len(model_files) < N_SPLITS:
148
  print(f"❌ [SniperEngine V1] خطأ فادح: تم العثور على {len(model_files)} نماذج فقط، مطلوب {N_SPLITS}.")
149
+ print(f" -> (تأكد من وجود ملفات 'lgbm_guard_v3...' داخل {self.models_dir})")
150
  return
151
 
152
  for f in sorted(model_files):
 
168
  """
169
  السماح بتغيير العتبة أثناء التشغيل.
170
  """
171
+ if 0.30 <= new_threshold <= 0.90: # (توسيع النطاق)
172
  print(f"🎯 [SniperEngine V1] تم تحديث العتبة من {self.threshold} إلى {new_threshold}")
173
  self.threshold = new_threshold
174
  else: