This commit is contained in:
Executable
+226
@@ -0,0 +1,226 @@
|
||||
# V9 AI Engine Development - 17 Ocak 2026
|
||||
|
||||
Bu oturumda yapılan tüm değişikliklerin özeti.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Hedef
|
||||
|
||||
Mevcut V8 modelinden daha iyi tahmin yapan V9 AI modeli geliştirmek. Özellikle:
|
||||
- Maç sonucu, Alt/Üst, KG tahminleri
|
||||
- Günlük kupon önerileri
|
||||
- Value betting fırsatlarını tespit
|
||||
|
||||
---
|
||||
|
||||
## ✅ Tamamlanan İşler
|
||||
|
||||
### 1. V9 Feature Engine'leri (6 yeni modül)
|
||||
|
||||
| Dosya | Açıklama |
|
||||
|-------|----------|
|
||||
| `ai-engine/features/upset_engine.py` | Sürpriz maç tespiti (Galatasaray-Liverpool gibi) |
|
||||
| `ai-engine/features/momentum_engine.py` | Form trendi, seriler, psikolojik momentum |
|
||||
| `ai-engine/features/poisson_engine.py` | Matematiksel xG, exact score olasılıkları |
|
||||
| `ai-engine/features/context_engine.py` | Derbi tespiti, sezon dönemi, maç önemi |
|
||||
| `ai-engine/features/elo_system.py` | V2: Venue-adjusted ELO, lig kalitesi faktörü |
|
||||
| `ai-engine/features/referee_engine.py` | Hakem profilleri: kart, penaltı, ev sahibi eğilimi |
|
||||
|
||||
#### Upset Engine Özellikleri:
|
||||
- Atmosfer skoru (yüksek atmosferli stadyumlar)
|
||||
- Motivasyon asimetrisi (küme düşme vs şampiyon)
|
||||
- Yorgunluk faktörü (maç yoğunluğu, seyahat mesafesi)
|
||||
- Tarihsel upset oranı
|
||||
|
||||
#### Momentum Engine Özellikleri:
|
||||
- Gol atma/yeme trendi (artan/azalan)
|
||||
- Galibiyet/yenilmezlik/yenilgi serileri
|
||||
- Son maç psikolojik etkisi
|
||||
- Form yönü (improving/declining/stable)
|
||||
|
||||
#### Poisson Engine Özellikleri:
|
||||
- Expected Goals (xG) hesaplama
|
||||
- Exact score olasılıkları (0-0, 1-0, 1-1, vb.)
|
||||
- Over/Under olasılıkları (matematiksel)
|
||||
- BTTS (Karşılıklı Gol) olasılıkları
|
||||
|
||||
#### Context Engine Özellikleri:
|
||||
- Derbi tespiti (GS-FB, El Clasico, vb.)
|
||||
- Sezon dönemi (early/mid/late/final)
|
||||
- Şampiyonluk yarışı, küme düşme hattı
|
||||
- Motivasyon skoru
|
||||
|
||||
#### ELO V2 Özellikleri:
|
||||
- Venue-adjusted ELO (ev/deplasman ayrı)
|
||||
- Lig kalitesi faktörü (Premier League=1.15, Süper Lig=1.00)
|
||||
- Form ELO (son maçlara ağırlıklı)
|
||||
- Win probability hesaplama
|
||||
|
||||
---
|
||||
|
||||
### 2. V9 Training Script
|
||||
|
||||
**Dosya:** `ai-engine/scripts/train_ultimate_v9.py`
|
||||
|
||||
**Özellikler:**
|
||||
- XGBoost + LightGBM + CatBoost (3'lü ensemble)
|
||||
- Time-series cross validation
|
||||
- 6 hedef: MS, KG, AU25, AU15, AU35, DC
|
||||
- V9 feature engine entegrasyonu
|
||||
|
||||
---
|
||||
|
||||
### 3. Live Matches Odds Desteği
|
||||
|
||||
**Schema Değişikliği:** `prisma/schema.prisma`
|
||||
```prisma
|
||||
model LiveMatch {
|
||||
// ...
|
||||
odds Json? @map("odds")
|
||||
oddsUpdatedAt DateTime? @map("odds_updated_at")
|
||||
}
|
||||
```
|
||||
|
||||
**Yeni Cron Job:** `src/tasks/data-fetcher.task.ts`
|
||||
- `fetchOddsForLiveMatches()` - Her 15 dakikada çalışır
|
||||
- Mackolik'ten oranları çeker
|
||||
- JSON olarak `live_matches.odds` kolonuna kaydeder
|
||||
|
||||
**Odds Formatı:**
|
||||
```json
|
||||
{
|
||||
"MS": {"1": 2.10, "X": 3.40, "2": 3.20},
|
||||
"AU25": {"Alt": 2.05, "Üst": 1.75},
|
||||
"KG": {"Var": 1.85, "Yok": 1.95}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 4. Kod Temizliği
|
||||
|
||||
**Silinen Dosyalar (13 adet, ~134KB):**
|
||||
- `ai-engine/ultimate_predictor_v7.py`
|
||||
- `ai-engine/basketball_predictor_v1.py`
|
||||
- `ai-engine/match_analyzer.py` (89KB)
|
||||
- `ai-engine/scripts/train_ultimate_v7.py`
|
||||
- `ai-engine/scripts/backtest_v7.py`
|
||||
- `ai-engine/scripts/test_v3_prediction.py`
|
||||
- `ai-engine/scripts/predict_trabzon_v3.py`
|
||||
- `ai-engine/scripts/batch_predict_v3.py`
|
||||
- `ai-engine/scripts/analyze_single.py`
|
||||
- `ai-engine/scripts/check_match_id.py`
|
||||
- `ai-engine/scripts/dump_match_json.py`
|
||||
- `ai-engine/scripts/sample_stats.py`
|
||||
- `ai-engine/scripts/discovery_mackolik.py`
|
||||
|
||||
---
|
||||
|
||||
## 📊 V8 vs V9 Karşılaştırma (Hedef)
|
||||
|
||||
| Bahis Türü | V8 Accuracy | V9 Hedef |
|
||||
|------------|-------------|----------|
|
||||
| Maç Sonucu | %61.7 | %65+ |
|
||||
| 2.5 Alt/Üst | %67.8 | %72+ |
|
||||
| KG | %63.7 | %68+ |
|
||||
| Çifte Şans | %77.7 | %80+ |
|
||||
| İlk Yarı | %52.7 | %58+ |
|
||||
|
||||
---
|
||||
|
||||
## 🔜 Sonraki Adımlar
|
||||
|
||||
1. **4 gün sonra:** Veri toplama tamamlandığında `train_ultimate_v9.py` çalıştır
|
||||
2. **Backtest:** V8 vs V9 accuracy karşılaştırması
|
||||
3. **Kupon Generator:** Risk modları + kombine seçici ekle
|
||||
4. **Production Deploy:** V9 modelini aktif et
|
||||
|
||||
---
|
||||
|
||||
## 📁 Değişen Dosyalar
|
||||
|
||||
```
|
||||
ai-engine/
|
||||
├── features/
|
||||
│ ├── __init__.py (güncellendi)
|
||||
│ ├── upset_engine.py (yeni)
|
||||
│ ├── momentum_engine.py (yeni)
|
||||
│ ├── poisson_engine.py (yeni)
|
||||
│ ├── context_engine.py (yeni)
|
||||
│ └── elo_system.py (güncellendi - V2)
|
||||
└── scripts/
|
||||
└── train_ultimate_v9.py (yeni)
|
||||
|
||||
prisma/
|
||||
├── schema.prisma (güncellendi)
|
||||
└── migrations/
|
||||
└── manual_add_odds_to_live_matches.sql (yeni)
|
||||
|
||||
src/tasks/
|
||||
└── data-fetcher.task.ts (güncellendi)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🗄️ Veritabanı Değişiklikleri
|
||||
|
||||
```sql
|
||||
-- Çalıştırıldı: 17 Ocak 2026 00:14
|
||||
ALTER TABLE "live_matches"
|
||||
ADD COLUMN IF NOT EXISTS "odds" JSONB,
|
||||
ADD COLUMN IF NOT EXISTS "odds_updated_at" TIMESTAMP(3);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💡 Mimari Kararlar
|
||||
|
||||
1. **Tek Model Tüm Ligler:** Her lig için ayrı model yerine, lig feature'larıyla tek model
|
||||
2. **Hibrit Odds Saklama:** Ayrı tablo yerine `live_matches.odds` JSON kolonu
|
||||
3. **3'lü Ensemble:** XGBoost + LightGBM + CatBoost ortalaması
|
||||
4. **Feature Engine Paterni:** Singleton instance + `get_features()` metodu
|
||||
|
||||
---
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 📌 Güncellemeler - 17 Ocak 2026 (Part 2)
|
||||
|
||||
### 5. Yeni Feature Engine'ler
|
||||
İki yeni güçlü feature engine eklendi:
|
||||
|
||||
#### `ai-engine/features/referee_engine.py`
|
||||
Hakem verilerini analiz eder (`MatchOfficial` tablosundan).
|
||||
- **Özellikler:** Ortalama sarı/kırmızı kart, penaltı oranı, ev sahibi kayırma (home bias), lig ortalamasına göre agresiflik.
|
||||
- **Teknik:** `dataclasses` ile type-safe yapı.
|
||||
|
||||
#### `ai-engine/features/squad_analysis_engine.py`
|
||||
Detaylı kadro analizi yapar.
|
||||
- **Özellikler:**
|
||||
- İlk 11 / Yedek ayrımı
|
||||
- Oyuncu formu (son 5 maç: gol, asist, dakika)
|
||||
- Key Player analizi (takımın en çok gol atan oyuncuları oynuyor mu?)
|
||||
- Pozisyon dağılımı (Defans, Orta Saha, Forvet sayısı)
|
||||
- Kadro gücü farkı karşılaştırması
|
||||
|
||||
**Toplam Engine Sayısı:** 7 adet (Upset, Momentum, Poisson, Context, ELO V2, Referee, Squad Analysis)
|
||||
|
||||
---
|
||||
|
||||
### 6. Eğitim Altyapısı İyileştirmeleri
|
||||
|
||||
#### 🚀 Google Colab Entegrasyonu
|
||||
Eğitimin lokal CPU'da yavaş olması (30-60 dk) nedeniyle Google Colab (GPU) için altyapı hazırlandı.
|
||||
- **Notebook:** `ai-engine/notebooks/train_v9_colab.ipynb` (XGBoost GPU, LightGBM, CatBoost GPU)
|
||||
- **Veri Export:** `ai-engine/scripts/export_training_data.py`
|
||||
|
||||
#### export_training_data.py Optimizasyonu
|
||||
İlk versiyonda satır satır DB sorgusu yaptığı için 21 saat süreceği hesaplandı.
|
||||
- **Optimize:** Momentum ve Context gibi ağır engine'ler için bulk query yaklaşımı tartışıldı.
|
||||
- **Geçici Çözüm:** Şimdilik sadece hızlı engine'ler (ELO, Poisson) ile export alınıyor. İleride bulk query ile rewrite edilecek.
|
||||
|
||||
### 7. Veritabanı Bağlantısı
|
||||
- AWS SSM Tunneling ile `localhost:15432` portu üzerinden prod DB bağlantısı sağlandı.
|
||||
- `.env` dosyası güncellendi.
|
||||
|
||||
Reference in New Issue
Block a user