# -*- coding: utf-8 -*- """Kalibrasi waktu training LSTM 2-lapis pd subset — ekstrapolasi utk gate/wf.""" import os import sys import time import numpy as np HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) import train_hybrid as TH def time_run(n_train, n_ep, tag): F, label, close, midx, split_pos, split_bar = TH.load_base() X = F mean = X[midx[:split_pos]].mean(0) std = X[midx[:split_pos]].std(0) std[std < 1e-9] = 1.0 Xs = (X - mean) / std n = min(n_train, split_pos) va2 = int(0.85 * n) Xtr = TH.build_sequences(Xs, midx[:va2]) Xva = TH.build_sequences(Xs, midx[va2:n]) yl = (label[midx] == 1).astype(float) ys = (label[midx] == -1).astype(float) Ytr = np.column_stack([yl[:va2], ys[:va2]]) Yva = np.column_stack([yl[va2:n], ys[va2:n]]) t0 = time.time() st, va, ep = TH.train_lstm2(Xtr, Ytr, Xva, Yva, seed=42, epoch_max=n_ep, verbose=False) dt_ = time.time() - t0 per_ep = dt_ / (ep + 1) print(f"[{tag}] n_train={len(Xtr)} epochs={ep + 1} total={dt_:.0f}s " f"({per_ep:.1f}s/ep) val_AUC={va:.4f}") return per_ep if __name__ == "__main__": per = time_run(6000, 3, "probe-6k") # ekstrapolasi gate: ~39k train, 5 seed, ~15 ep/seed est_gate = per * (39000 / 6000) * 15 * 5 print(f"Estimasi GATE penuh (39k train, 5 seed, ~15 ep): ~{est_gate / 60:.0f} menit")