{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# HÜCRE 1 — Paketler\n",
    "!pip install xgboost lightgbm optuna scikit-learn pandas numpy -q\n",
    "print('Hazır')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# HÜCRE 2 — Drive bağla + CSV çek\n",
    "from google.colab import drive\n",
    "import os, shutil\n",
    "drive.mount('/content/drive')\n",
    "\n",
    "# training_data.csv'yi Drive'ın iddaai klasöründen kopyala\n",
    "shutil.copy('/content/drive/MyDrive/iddaai/training_data.csv', '/content/training_data.csv')\n",
    "print('CSV hazır:', os.path.getsize('/content/training_data.csv') // 1024 // 1024, 'MB')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# HÜCRE 3 — iddaai_colab3.zip upload et (ai-engine kodları)\n",
    "from google.colab import files\n",
    "import zipfile\n",
    "print('iddaai_colab3.zip dosyasını seç:')\n",
    "uploaded = files.upload()\n",
    "with zipfile.ZipFile('iddaai_colab3.zip') as z:\n",
    "    z.extractall('/content')\n",
    "print('Kod hazır')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# HÜCRE 4 — training_data.csv'yi script'in beklediği yere koy\n",
    "import os, shutil\n",
    "os.makedirs('/content/ai-engine/data', exist_ok=True)\n",
    "shutil.copy('/content/training_data.csv', '/content/ai-engine/data/training_data.csv')\n",
    "print('Yerleştirildi')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# HÜCRE 5 — Eğitimi başlat (her 5 trial'da bir ilerleme gösterir)\n",
    "import subprocess, os\n",
    "\n",
    "proc = subprocess.Popen(\n",
    "    ['python', 'scripts/train_v25_pro.py'],\n",
    "    stdout=subprocess.PIPE,\n",
    "    stderr=subprocess.STDOUT,\n",
    "    text=True,\n",
    "    cwd='/content/ai-engine',\n",
    "    env={**os.environ, 'PYTHONPATH': '/content/ai-engine'}\n",
    ")\n",
    "\n",
    "for line in proc.stdout:\n",
    "    print(line, end='', flush=True)\n",
    "\n",
    "proc.wait()\n",
    "print('\\nEĞİTİM BİTTİ!')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# HÜCRE 6 — Modelleri Drive'a kaydet\n",
    "import shutil, os\n",
    "os.makedirs('/content/drive/MyDrive/iddaai/models_v25', exist_ok=True)\n",
    "shutil.copytree(\n",
    "    '/content/ai-engine/models/v25',\n",
    "    '/content/drive/MyDrive/iddaai/models_v25',\n",
    "    dirs_exist_ok=True\n",
    ")\n",
    "print('Modeller Drive a kaydedildi: MyDrive/iddaai/models_v25/')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"},
  "language_info": {"name": "python", "version": "3.10.0"}
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
