Files
DeepLottery/valid.py
dsyoon 52e8495148 Add final BallFilter, train/valid scripts, train-derived sum filters
- final_BallFilter: CSV history loader, TRAIN_ALLOW for 6-sum and week diff,
  fix filterOneDigitPattern ball overwrite bug, drop socket call
- final_filter_params: build sum6 and abs_sum_diff from rounds 1-800
- filter_model re-exports BallFilter; train/valid evaluate pass-through counts
- final_filterTest aligned with 1_FilterTest_25 plus optional MC survivors
- README and scripts/run_with_ncue.sh for ncue workflow

Made-with: Cursor
2026-04-08 19:29:10 +09:00

50 lines
1.6 KiB
Python

"""
검증 구간(801~1000회): 필터만 검사(학습으로 튜닝하지 않음).
"""
import argparse
import os
import pandas as pd
from final_BallFilter import BallFilter
def load_history(resources_path: str) -> pd.DataFrame:
path = os.path.join(resources_path, "lotto_history.txt")
df = pd.read_csv(path, header=None)
df.columns = ["no", "b1", "b2", "b3", "b4", "b5", "b6", "bn"]
return df
def run_valid(resources_path: str, start_no: int, end_no: int) -> tuple[int, int, list[int]]:
df = load_history(resources_path)
hist_path = os.path.join(resources_path, "lotto_history.txt")
bf = BallFilter(hist_path)
wins = 0
total = 0
win_nos: list[int] = []
for no in range(start_no, end_no + 1):
sub = df[df["no"] == no]
if sub.empty:
continue
answer = sorted(int(x) for x in sub.iloc[0][1:7].tolist())
fts = bf.extract_final_candidates(answer, no=no, until_end=True, df=df)
total += 1
if len(fts) == 0:
wins += 1
win_nos.append(no)
return wins, total, win_nos
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("--resources", default=os.path.join(os.path.dirname(__file__), "resources"))
p.add_argument("--start-no", type=int, default=801)
p.add_argument("--end-no", type=int, default=1000)
args = p.parse_args()
w, t, nos = run_valid(args.resources, args.start_no, args.end_no)
rate = w / t if t else 0.0
print(f"검증 구간 당첨 통과: {w} / {t} ({rate:.4f})")
print(f"통과 회차: {nos}")