Skip to content

Commit 3a75a68

Browse files
Copilotedumgt
andauthored
GS피앤엘 티커 기반 모델링/결과 파일명 반영
Agent-Logs-Url: https://github.com/edumgt/python-ml-class/sessions/3f8f3954-0ac2-433b-a03a-d73499640a07 Co-authored-by: edumgt <41275565+edumgt@users.noreply.github.com>
1 parent 2d8ed4f commit 3a75a68

11 files changed

Lines changed: 36 additions & 22 deletions

CnnCandleChart.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ def forward(self, x):
294294

295295
plt.subplots_adjust(top=0.93)
296296
plt.tight_layout()
297-
plt.savefig("result/CnnCandleChart_078935_KS.png", dpi=150, bbox_inches="tight")
298-
print(" → 그래프 저장: result/CnnCandleChart_078935_KS.png")
297+
ticker_tag = TICKER.replace(".", "_")
298+
out_name = f"result/CnnCandleChart_{ticker_tag}.png"
299+
plt.savefig(out_name, dpi=150, bbox_inches="tight")
300+
print(f" → 그래프 저장: {out_name}")
299301

300302
print("\n✓ 2D CNN 캔들차트 이미지 분류 실습 완료!\n")

CnnLstmHybrid.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
np.random.seed(42)
2828

2929
# ── 1. 데이터 생성 ─────────────────────────────────────────
30-
print("\n[1/8] 주가 시계열 로드 중 (078935.KS - GS P&N)...")
30+
print("\n[1/8] 주가 시계열 로드 중 (078935.KS - GS피앤엘)...")
3131
time.sleep(0.5)
3232

3333
TICKER = '078935.KS'
@@ -289,7 +289,9 @@ def forward(self, x):
289289

290290
plt.subplots_adjust(top=0.93)
291291
plt.tight_layout()
292-
plt.savefig("result/CnnLstmHybrid_078935_KS.png", dpi=150, bbox_inches="tight")
293-
print(" → 그래프 저장: result/CnnLstmHybrid_078935_KS.png")
292+
ticker_tag = TICKER.replace(".", "_")
293+
out_name = f"result/CnnLstmHybrid_{ticker_tag}.png"
294+
plt.savefig(out_name, dpi=150, bbox_inches="tight")
295+
print(f" → 그래프 저장: {out_name}")
294296

295297
print("\n✓ CNN+LSTM 하이브리드 주가 방향 분류 실습 완료!\n")

CnnTimeSeriesFeature.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
np.random.seed(42)
2828

2929
# ── 1. 데이터 생성 ─────────────────────────────────────────
30-
print("\n[1/8] 주가 시계열 로드 중 (078935.KS - GS P&N)...")
30+
print("\n[1/8] 주가 시계열 로드 중 (078935.KS - GS피앤엘)...")
3131
time.sleep(0.5)
3232

3333
TICKER = '078935.KS'
@@ -286,7 +286,9 @@ def hook_fn(module, inp, out):
286286

287287
plt.subplots_adjust(top=0.93)
288288
plt.tight_layout()
289-
plt.savefig("result/CnnTimeSeriesFeature_078935_KS.png", dpi=150, bbox_inches="tight")
290-
print(" → 그래프 저장: result/CnnTimeSeriesFeature_078935_KS.png")
289+
ticker_tag = TICKER.replace(".", "_")
290+
out_name = f"result/CnnTimeSeriesFeature_{ticker_tag}.png"
291+
plt.savefig(out_name, dpi=150, bbox_inches="tight")
292+
print(f" → 그래프 저장: {out_name}")
291293

292294
print("\n✓ 1D CNN 시계열 특징 추출 실습 완료!\n")

LinearRegressionReturn.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def compute_volume_change(n):
6161
X = np.column_stack([feat_vol, feat_ret]) # [거래량변화율, 전일수익률]
6262
y = label
6363
print(f" → 실제 데이터 샘플: {len(X)}개 | 특성: [거래량변화율, 전일수익률(%)]")
64-
data_source = f"GS P&N({TICKER}) 실제 데이터"
64+
data_source = f"GS피앤엘({TICKER}) 실제 데이터"
6565
x_label_str = "거래량 변화율"
6666
else:
6767
# ── fallback: 가상 데이터 ───────────────────────────────────────────────
@@ -154,7 +154,9 @@ def compute_volume_change(n):
154154
# ────────────────────────────────────────────────────────────────────────────
155155

156156
plt.tight_layout()
157-
plt.savefig("result/LinearRegressionReturn_078935_KS.png", dpi=150, bbox_inches="tight")
158-
print(" → 그래프 저장: result/LinearRegressionReturn_078935_KS.png")
157+
ticker_tag = TICKER.replace(".", "_")
158+
out_name = f"result/LinearRegressionReturn_{ticker_tag}.png"
159+
plt.savefig(out_name, dpi=150, bbox_inches="tight")
160+
print(f" → 그래프 저장: {out_name}")
159161

160162
print("\n✓ 선형 회귀 실습 완료!\n")

LogisticTradeSignal.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def compute_returns(prices):
7474

7575
n = len(rsi)
7676
print(f" → 실제 데이터 {n}개 샘플 | 매수(1): {y.sum()}개 | 매도/관망(0): {(y == 0).sum()}개")
77-
data_source = f"GS P&N({TICKER}) 실제 데이터"
77+
data_source = f"GS피앤엘({TICKER}) 실제 데이터"
7878
else:
7979
# ── fallback: 가상 데이터 ───────────────────────────────────────────────
8080
n = 300
@@ -180,7 +180,9 @@ def compute_returns(prices):
180180
# ────────────────────────────────────────────────────────────────────────────
181181

182182
plt.tight_layout()
183-
plt.savefig("result/LogisticTradeSignal_078935_KS.png", dpi=150, bbox_inches="tight")
184-
print(" → 그래프 저장: result/LogisticTradeSignal_078935_KS.png")
183+
ticker_tag = TICKER.replace(".", "_")
184+
out_name = f"result/LogisticTradeSignal_{ticker_tag}.png"
185+
plt.savefig(out_name, dpi=150, bbox_inches="tight")
186+
print(f" → 그래프 저장: {out_name}")
185187

186188
print("\n✓ 로지스틱 회귀 실습 완료!\n")

SvmTradeSignal.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def compute_volume_change(n):
6363

6464
X = np.column_stack([momentum, vol_feat])
6565
buy_count = y.sum()
66-
print(f" → 실제 데이터 {len(X)}개 샘플 (GS P&N {TICKER})")
66+
print(f" → 실제 데이터 {len(X)}개 샘플 (GS피앤엘 {TICKER})")
6767
print(f" 매수 신호(1): {buy_count}개 | 매도/보류(0): {len(y) - buy_count}개")
68-
data_source = f"GS P&N({TICKER}) 실제 데이터"
68+
data_source = f"GS피앤엘({TICKER}) 실제 데이터"
6969
else:
7070
# ── fallback: 가상 데이터 ───────────────────────────────────────────────
7171
X = np.random.randn(240, 2)
@@ -172,8 +172,10 @@ def plot_signal_boundary(features, labels, clf):
172172
# ────────────────────────────────────────────────────────────────────────────
173173

174174
plt.tight_layout()
175-
plt.savefig("result/SvmTradeSignal_078935_KS.png", dpi=150, bbox_inches="tight")
176-
print(" → 그래프 저장: result/SvmTradeSignal_078935_KS.png")
175+
ticker_tag = TICKER.replace(".", "_")
176+
out_name = f"result/SvmTradeSignal_{ticker_tag}.png"
177+
plt.savefig(out_name, dpi=150, bbox_inches="tight")
178+
print(f" → 그래프 저장: {out_name}")
177179

178180

179181
plot_signal_boundary(X, y, model)

TimeSeriesWindow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def ask_str(prompt, default):
6363
return default
6464

6565
print()
66-
# 기본값: GS P&N (078935.KS), 윈도우 20일, 예측 5일, 스텝 1
66+
# 기본값: GS피앤엘 (078935.KS), 윈도우 20일, 예측 5일, 스텝 1
6767
TICKER = args.ticker if args.ticker is not None else ask_str(" 종목 티커", "078935.KS")
6868
WINDOW = args.window if args.window is not None else ask_int(" 윈도우 크기 (일)", 20, 5, 120)
6969
HORIZON = args.horizon if args.horizon is not None else ask_int(" 예측 기간 (일)", 5, 1, 30)

TransformerAttention.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
np.random.seed(42)
3333

3434
# ── 1. 데이터 생성 ─────────────────────────────────────────
35-
print("\n[1/8] 주가 시계열 로드 중 (078935.KS - GS P&N)...")
35+
print("\n[1/8] 주가 시계열 로드 중 (078935.KS - GS피앤엘)...")
3636
time.sleep(0.5)
3737

3838
TICKER = '078935.KS'
@@ -297,7 +297,9 @@ def forward(self, x):
297297

298298
plt.subplots_adjust(top=0.93)
299299
plt.tight_layout()
300-
plt.savefig("result/TransformerAttention_078935_KS.png", dpi=150, bbox_inches="tight")
301-
print(" → 그래프 저장: result/TransformerAttention_078935_KS.png")
300+
ticker_tag = TICKER.replace(".", "_")
301+
out_name = f"result/TransformerAttention_{ticker_tag}.png"
302+
plt.savefig(out_name, dpi=150, bbox_inches="tight")
303+
print(f" → 그래프 저장: {out_name}")
302304

303305
print("\n✓ Transformer Self-Attention 주가 방향 분류 실습 완료!\n")
41.8 KB
Loading
154 KB
Loading

0 commit comments

Comments
 (0)