analyser_hj3415 2.9.9__tar.gz → 2.9.10__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- analyser_hj3415-2.9.10/.gitignore +6 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/PKG-INFO +1 -1
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/cli.py +4 -6
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/tsa.py +12 -15
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/pyproject.toml +1 -1
- analyser_hj3415-2.9.9/.gitignore +0 -1
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/README.md +0 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/__init__.py +0 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/eval.py +0 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/workroom/__init__.py +0 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/workroom/mysklearn.py +0 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/workroom/mysklearn2.py +0 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/workroom/score.py +0 -0
- {analyser_hj3415-2.9.9 → analyser_hj3415-2.9.10}/analyser_hj3415/workroom/trash.py +0 -0
@@ -209,23 +209,21 @@ def analyser_manager():
|
|
209
209
|
elif args.type == 'prophet':
|
210
210
|
if args.command == 'ranking':
|
211
211
|
myprophet = tsa.MyProphet
|
212
|
-
myprophet.expire_time_h
|
213
|
-
result = myprophet.ranking(refresh=args.refresh)
|
212
|
+
result = myprophet.ranking(refresh=args.refresh, expire_time_h=24)
|
214
213
|
print(result)
|
215
214
|
log_cli.save('INFO', 'run >> analyser prophet ranking')
|
216
215
|
|
217
216
|
elif args.type == 'lstm':
|
218
217
|
mylstm = tsa.MyLSTM
|
219
|
-
mylstm.expire_time_h = 72
|
220
218
|
if args.command == 'caching':
|
221
219
|
if args.top:
|
222
|
-
mylstm.caching_based_on_prophet_ranking(refresh=args.refresh, top=args.top)
|
220
|
+
mylstm.caching_based_on_prophet_ranking(refresh=args.refresh, expire_time_h=24, top=args.top)
|
223
221
|
else:
|
224
|
-
mylstm.caching_based_on_prophet_ranking(refresh=args.refresh)
|
222
|
+
mylstm.caching_based_on_prophet_ranking(refresh=args.refresh, expire_time_h=24)
|
225
223
|
log_cli.save('INFO', f'run >> analyser lstm caching / top={args.top if args.top else 20})')
|
226
224
|
elif args.command == 'get':
|
227
225
|
assert utils.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
|
228
|
-
result = mylstm(args.code).get_final_predictions(refresh=args.refresh)
|
226
|
+
result = mylstm(args.code).get_final_predictions(refresh=args.refresh, expire_time_h=24)
|
229
227
|
log_cli.save('INFO', f'run >> analyser lstm get {args.code}')
|
230
228
|
|
231
229
|
elif args.type == 'setting':
|
@@ -30,10 +30,8 @@ import logging
|
|
30
30
|
|
31
31
|
tsa_logger = helpers.setup_logger('tsa_logger', logging.WARNING)
|
32
32
|
|
33
|
-
expire_time = 3600 * 24
|
34
33
|
|
35
34
|
class MyProphet:
|
36
|
-
expire_time_h = 24
|
37
35
|
def __init__(self, code: str):
|
38
36
|
assert utils.is_6digit(code), f'Invalid value : {code}'
|
39
37
|
self.scaler = StandardScaler()
|
@@ -195,7 +193,7 @@ class MyProphet:
|
|
195
193
|
Exception("to 인자가 맞지 않습니다.")
|
196
194
|
|
197
195
|
@classmethod
|
198
|
-
def ranking(cls, refresh = False) -> OrderedDict:
|
196
|
+
def ranking(cls, refresh = False, expire_time_h = 24) -> OrderedDict:
|
199
197
|
"""
|
200
198
|
가장 최근 날짜의 랭킹 분석
|
201
199
|
:param refresh:
|
@@ -205,7 +203,7 @@ class MyProphet:
|
|
205
203
|
redis_name = 'myprophet_ranking'
|
206
204
|
|
207
205
|
print(
|
208
|
-
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {
|
206
|
+
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time_h}h")
|
209
207
|
|
210
208
|
def fetch_ranking() -> dict:
|
211
209
|
data = {}
|
@@ -224,7 +222,7 @@ class MyProphet:
|
|
224
222
|
print(f"{i}.{p.code}/{p.name} date: {recent_date} 가격:{recent_price} 기대하한값:{yhat_lower} 편차:{deviation}")
|
225
223
|
return data
|
226
224
|
|
227
|
-
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=
|
225
|
+
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=expire_time_h * 3600)
|
228
226
|
|
229
227
|
return OrderedDict(sorted(data_dict.items(), key=lambda item: item[1], reverse=True))
|
230
228
|
|
@@ -265,7 +263,6 @@ class MyLSTM:
|
|
265
263
|
"""
|
266
264
|
# 미래 몇일을 예측할 것인가?
|
267
265
|
future_days = 30
|
268
|
-
expire_time_h = 48
|
269
266
|
|
270
267
|
def __init__(self, code: str):
|
271
268
|
assert utils.is_6digit(code), f'Invalid value : {code}'
|
@@ -489,7 +486,7 @@ class MyLSTM:
|
|
489
486
|
test_r2=test_r2,
|
490
487
|
)
|
491
488
|
|
492
|
-
def get_final_predictions(self, refresh, num=5) -> tuple:
|
489
|
+
def get_final_predictions(self, refresh: bool, expire_time_h: int, num=5) -> tuple:
|
493
490
|
"""
|
494
491
|
미래 예측치를 레디스 캐시를 이용하여 반환함
|
495
492
|
:param refresh:
|
@@ -500,7 +497,7 @@ class MyLSTM:
|
|
500
497
|
redis_name = f'{self.code}_mylstm_predictions'
|
501
498
|
|
502
499
|
print(
|
503
|
-
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {
|
500
|
+
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time_h}h")
|
504
501
|
|
505
502
|
def fetch_final_predictions(num_in) -> tuple:
|
506
503
|
"""
|
@@ -531,7 +528,7 @@ class MyLSTM:
|
|
531
528
|
|
532
529
|
return future_dates_str, final_future_predictions.tolist()
|
533
530
|
|
534
|
-
future_dates_str, final_future_predictions = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_final_predictions, num, timer=
|
531
|
+
future_dates_str, final_future_predictions = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_final_predictions, num, timer=expire_time_h * 3600)
|
535
532
|
|
536
533
|
# 문자열을 날짜 형식으로 변환
|
537
534
|
future_dates = [datetime.strptime(date, '%Y-%m-%d') for date in future_dates_str]
|
@@ -541,14 +538,14 @@ class MyLSTM:
|
|
541
538
|
|
542
539
|
return future_dates, final_future_predictions
|
543
540
|
|
544
|
-
def export(self, refresh=False, to="str") -> Optional[str]:
|
541
|
+
def export(self, refresh=False, expire_time_h=24, to="str") -> Optional[str]:
|
545
542
|
"""
|
546
543
|
prophet과 plotly로 그래프를 그려서 html을 문자열로 반환
|
547
544
|
:param refresh:
|
548
545
|
:param to: str, htmlfile, png
|
549
546
|
:return:
|
550
547
|
"""
|
551
|
-
future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh)
|
548
|
+
future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh, expire_time_h=expire_time_h)
|
552
549
|
final_future_predictions = final_future_predictions.reshape(-1) # 차원을 하나 줄인다.
|
553
550
|
|
554
551
|
# 데이터 준비
|
@@ -636,7 +633,7 @@ class MyLSTM:
|
|
636
633
|
Exception("to 인자가 맞지 않습니다.")
|
637
634
|
|
638
635
|
def visualization(self, refresh=True):
|
639
|
-
future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh)
|
636
|
+
future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh, expire_time_h=1)
|
640
637
|
|
641
638
|
# 시각화1
|
642
639
|
plt.figure(figsize=(10, 6))
|
@@ -664,15 +661,15 @@ class MyLSTM:
|
|
664
661
|
plt.show()"""
|
665
662
|
|
666
663
|
@staticmethod
|
667
|
-
def caching_based_on_prophet_ranking(refresh: bool, top=20):
|
668
|
-
ranking_topn = OrderedDict(itertools.islice(MyProphet.ranking().items(), top))
|
664
|
+
def caching_based_on_prophet_ranking(refresh: bool, expire_time_h: int, top=20):
|
665
|
+
ranking_topn = OrderedDict(itertools.islice(MyProphet.ranking(refresh=False).items(), top))
|
669
666
|
tsa_logger.info(ranking_topn)
|
670
667
|
mylstm = MyLSTM('005930')
|
671
668
|
print(f"*** LSTM prediction redis cashing top{top} items ***")
|
672
669
|
for i, (code, _) in enumerate(ranking_topn.items()):
|
673
670
|
mylstm.code = code
|
674
671
|
print(f"{i+1}. {mylstm.code}/{mylstm.name}")
|
675
|
-
mylstm.get_final_predictions(refresh=refresh, num=5)
|
672
|
+
mylstm.get_final_predictions(refresh=refresh, expire_time_h=expire_time_h, num=5)
|
676
673
|
|
677
674
|
|
678
675
|
|
analyser_hj3415-2.9.9/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
/dist/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|