-
Notifications
You must be signed in to change notification settings - Fork 2
[AI][FIX] 피쳐 계산 코드 변경 #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "20260308_#287_\uD53C\uCCD0-\uACC4\uC0B0-\uCF54\uB4DC(processor.py)-\uC218\uC815\uD544\uC694"
Changes from all commits
eb36629
a54390e
3c9a407
de10a79
ae5ee10
26953d1
79b3f16
b3a519d
dd50ea4
68e663e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| # AI/modules/features/processor.py | ||
| import pandas as pd | ||
| from .market_derived import add_standard_technical_features, add_multi_timeframe_features | ||
| from .event_features import add_event_features | ||
| from .technical import compute_correlation_spike, compute_recent_loss_ema | ||
| from AI.modules.features.market_derived import add_standard_technical_features, add_multi_timeframe_features | ||
| from AI.modules.features.event_features import add_date_distance, add_event_window_flags | ||
| from AI.modules.features.technical import compute_correlation_spike, compute_recent_loss_ema | ||
|
|
||
| class FeatureProcessor: | ||
| """ | ||
|
|
@@ -15,22 +15,31 @@ def __init__(self, df: pd.DataFrame): | |
| if 'date' in self.df.columns: | ||
| self.df['date'] = pd.to_datetime(self.df['date']) | ||
| self.df = self.df.sort_values('date') | ||
| self.df.set_index('date', inplace=True) | ||
|
|
||
| def execute_pipeline(self, event_info=None, sector_df=None): | ||
| """전체 파생 피처 생성 파이프라인 실행""" | ||
|
|
||
| # 1. 일봉 기준 표준 기술적 지표 및 수익률 계산 (Standard Key 생성) | ||
| # 1. 일봉 기준 표준 기술적 지표 및 수익률 계산 | ||
| self.df = add_standard_technical_features(self.df) | ||
|
|
||
| # 2. 주봉/월봉 멀티 타임프레임 피처 결합 (Legacy 로직 완벽 대체) | ||
| # 2. 주봉/월봉 멀티 타임프레임 피처 결합 | ||
| self.df = add_multi_timeframe_features(self.df) | ||
|
|
||
| # 3. 이벤트 기반 피처 (IPO 경과일, 실적발표 등) | ||
| # 3. 이벤트 기반 피처 | ||
| if event_info: | ||
| self.df = add_event_features(self.df, event_info) | ||
| self.df = add_date_distance(self.df, event_info.get('ipo_dates', pd.Series()), 'ipo') | ||
| self.df = add_event_window_flags(self.df, event_info.get('fomc_dates', []), 'fomc') | ||
|
Comment on lines
+29
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
제안 수정안- self.df = add_date_distance(self.df, event_info.get('ipo_dates', pd.Series()), 'ipo')
+ ipo_dates = event_info.get('ipo_dates')
+ if ipo_dates is None:
+ ipo_dates = pd.Series(pd.NaT, index=self.df.index, dtype='datetime64[ns]')
+ self.df = add_date_distance(self.df, ipo_dates, 'ipo')🤖 Prompt for AI Agents |
||
|
|
||
| # 사용자님이 완벽하게 고치신 부분! 👍 | ||
| if 'vix_close' in self.df.columns: | ||
| self.df['correlation_spike'] = compute_correlation_spike(self.df['close'], self.df['vix_close']) | ||
|
|
||
| self.df['recent_loss_ema'] = compute_recent_loss_ema(self.df['close'], self.df['close'].shift(1)) | ||
|
|
||
| # 4. 데이터 정제 (Legacy 안정성 로직) | ||
| # 4. 데이터 정제 | ||
| self.df = self.finalize_data() | ||
| self.df.reset_index(inplace=True) | ||
|
|
||
| return self.df | ||
|
|
||
|
|
@@ -39,4 +48,4 @@ def finalize_data(self): | |
| import numpy as np | ||
| self.df.replace([np.inf, -np.inf], np.nan, inplace=True) | ||
| self.df = self.df.fillna(0) | ||
| return self.df | ||
| return self.df | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: SISC-IT/sisc-web
Length of output: 944
__init__.py파일이 누락되어 상대 임포트가 작동하지 않습니다.상대 임포트(
.technical)를 사용하려면AI/modules/와AI/modules/features/디렉토리에__init__.py파일이 필요합니다. 현재 두 파일 모두 존재하지 않으므로ImportError가 발생합니다.또한
AI/modules/signal/core/dataset_builder.py의 절대 임포트(from AI.modules.features.market_derived import ...)도 패키지 구조가 완성되지 않으면 실패합니다.다음 파일들을 생성하세요:
AI/modules/__init__.py(빈 파일)AI/modules/features/__init__.py(빈 파일)🤖 Prompt for AI Agents