feat: 주말 나들이 점수를 평균 60 정규분포로 보정, 지금 날씨·나들이 점수 100점은 완벽한 날만
- 나들이 점수(주말 전국 순위·당일치기)에 지금 날씨 점수와 같은 방식의 바꾸기 표를 적용: 원래 점수를 1년 치 분포의 순위로 보고 평균 60·표준편차 15 정규분포 점수로 바꿈 (weekend_rank.py, outing_score_table.json, scripts/gen_outing_score_table.py) - 나들이 점수 만점 조건을 엄격하게: 체감온도 최적 21°±0.5°, 바람 초속 1m 이하일 때만 100점 (같은 예보를 받는 여러 지역이 한꺼번에 100점이 되던 것을 줄임) - 표 맨 위가 100으로 잘려 비슷한 원래 점수(96·97·99)가 모두 100점이 되던 것을 막기 위해 straighten_top 추가: 표시 점수 83 이하인 마지막 원래 점수에서 100점까지 직선으로 이어, 100점은 구간에서 나올 수 있는 가장 높은 원래 점수(밤은 85)일 때만 나옴. 지금 날씨 점수 표도 다시 만듦 (90점 이상 약 2.4% → 1.5%) - 당일치기 최소 점수는 원래 50점과 같은 날씨 수준(표시 62점)으로 옮김 - 주말 순위 캐시 키를 weekend_rank:v2:<날짜>로 올려 옛 점수 캐시를 쓰지 않게 함 - 테스트 추가: test_outing_score_table, test_weather_score_table(straighten_top·100점 조건) - docs/점수_계산식.md의 지금 날씨 점수·나들이 점수 항목을 새 기준과 숫자로 갱신
This commit is contained in:
1 parent
b2470d80ed
commit
0edb7059c8
9 files changed
+337
-39
No files matched your search
@@ -423,7 +423,8 @@ def estimate(definition, fc: DayForecast, windows: list[list[int]], ctx: Context
|
||||
# 나들이 날씨 점수: 낮 10~17시에 바깥에서 놀기 좋은 정도. 주말 전국 순위·당일치기 추천에 쓴다.
|
||||
OUTING_HOURS = (10, 18)
|
||||
_OUTING_WEIGHTS = {"temp": 35, "rain": 40, "sky": 15, "wind": 10}
|
||||
_OUTING_RULES = {"temp": {"type": "range", "lo": 17, "hi": 24, "best": 21}, "rain": {"dir": "dry"}, "wind": {"type": "calm", "ok": 4, "limit": 12}}
|
||||
# 만점 조건을 엄격하게: 기온은 최적 21° ±0.5°, 바람은 초속 1m 이하(ok/2)여야 100점 — 같은 예보를 받는 여러 지역이 한꺼번에 100점이 되던 것을 줄인다
|
||||
_OUTING_RULES = {"temp": {"type": "range", "lo": 17, "hi": 24, "best": 21, "plateau": 0.5}, "rain": {"dir": "dry"}, "wind": {"type": "calm", "ok": 2, "limit": 12}}
|
||||
_OUTING_SKY = {Sky.CLEAR: 100, Sky.PARTLY: 80, Sky.CLOUDY: 50}
|
||||
_OUTING_RAIN_PROB, _OUTING_RAIN_CAP = 60, 30
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"about": "나들이 점수 바꾸기 표: 원래 점수 0~100 → 표시 점수. 평균 60·표준편차 15. scripts/gen_outing_score_table.py 가 만든다",
|
||||
"period": [
|
||||
"2025-10-22",
|
||||
"2026-10-21"
|
||||
],
|
||||
"regions": 32,
|
||||
"samples": 11680,
|
||||
"table": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
8,
|
||||
13,
|
||||
17,
|
||||
22,
|
||||
25,
|
||||
28,
|
||||
30,
|
||||
32,
|
||||
34,
|
||||
36,
|
||||
37,
|
||||
37,
|
||||
38,
|
||||
38,
|
||||
39,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
41,
|
||||
42,
|
||||
42,
|
||||
47,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
51,
|
||||
51,
|
||||
51,
|
||||
51,
|
||||
52,
|
||||
54,
|
||||
57,
|
||||
61,
|
||||
62,
|
||||
62,
|
||||
62,
|
||||
63,
|
||||
63,
|
||||
63,
|
||||
63,
|
||||
63,
|
||||
64,
|
||||
64,
|
||||
64,
|
||||
64,
|
||||
64,
|
||||
64,
|
||||
65,
|
||||
65,
|
||||
65,
|
||||
65,
|
||||
66,
|
||||
66,
|
||||
66,
|
||||
66,
|
||||
67,
|
||||
67,
|
||||
67,
|
||||
68,
|
||||
68,
|
||||
68,
|
||||
69,
|
||||
69,
|
||||
70,
|
||||
70,
|
||||
71,
|
||||
72,
|
||||
73,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
78,
|
||||
79,
|
||||
81,
|
||||
83,
|
||||
85,
|
||||
86,
|
||||
88,
|
||||
90,
|
||||
92,
|
||||
93,
|
||||
95,
|
||||
97,
|
||||
98,
|
||||
100
|
||||
]
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"about": "지금 날씨 점수 바꾸기 표: 원래 점수 0~100 → 표시 점수. 평균 60·표준편차 15. scripts/gen_weather_score_table.py 가 만든다",
|
||||
"period": [
|
||||
"2025-10-21",
|
||||
"2026-10-20"
|
||||
"2025-10-22",
|
||||
"2026-10-21"
|
||||
],
|
||||
"regions": 32,
|
||||
"samples": {
|
||||
@@ -59,12 +59,12 @@
|
||||
44,
|
||||
45,
|
||||
46,
|
||||
46,
|
||||
47,
|
||||
47,
|
||||
48,
|
||||
49,
|
||||
50,
|
||||
51,
|
||||
52,
|
||||
53,
|
||||
54,
|
||||
55,
|
||||
@@ -101,18 +101,18 @@
|
||||
80,
|
||||
82,
|
||||
83,
|
||||
85,
|
||||
84,
|
||||
86,
|
||||
87,
|
||||
88,
|
||||
90,
|
||||
91,
|
||||
92,
|
||||
93,
|
||||
95,
|
||||
96,
|
||||
97,
|
||||
99,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"day": [
|
||||
@@ -211,11 +211,11 @@
|
||||
79,
|
||||
81,
|
||||
83,
|
||||
85,
|
||||
87,
|
||||
91,
|
||||
86,
|
||||
89,
|
||||
92,
|
||||
94,
|
||||
97,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"evening": [
|
||||
@@ -303,7 +303,7 @@
|
||||
69,
|
||||
70,
|
||||
71,
|
||||
72,
|
||||
71,
|
||||
72,
|
||||
74,
|
||||
75,
|
||||
@@ -311,14 +311,14 @@
|
||||
78,
|
||||
79,
|
||||
81,
|
||||
84,
|
||||
86,
|
||||
83,
|
||||
85,
|
||||
87,
|
||||
89,
|
||||
92,
|
||||
94,
|
||||
96,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
98,
|
||||
100
|
||||
],
|
||||
"night": [
|
||||
@@ -365,7 +365,7 @@
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
47,
|
||||
46,
|
||||
48,
|
||||
49,
|
||||
50,
|
||||
@@ -373,7 +373,7 @@
|
||||
53,
|
||||
55,
|
||||
57,
|
||||
59,
|
||||
60,
|
||||
62,
|
||||
63,
|
||||
65,
|
||||
@@ -399,14 +399,14 @@
|
||||
78,
|
||||
80,
|
||||
82,
|
||||
85,
|
||||
84,
|
||||
86,
|
||||
88,
|
||||
90,
|
||||
92,
|
||||
94,
|
||||
96,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
98,
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
|
||||
@@ -22,7 +22,7 @@ from crud.region_crud import RegionCRUD
|
||||
from crud.sky_crud import SkyCRUD
|
||||
from crud.weather_crud import WeatherCRUD
|
||||
from crud.week_crud import WeekCRUD
|
||||
from services.calc.index_calc import OUTING_HOURS, outing, outing_estimate
|
||||
from services.calc.index_calc import OUTING_HOURS, Outing, outing, outing_estimate
|
||||
from services.index_service import day_forecast, windows_for
|
||||
from services.weather_service import WeatherService
|
||||
from services.week_service import _icon
|
||||
@@ -30,14 +30,29 @@ from services.week_service import _icon
|
||||
# 주말 전국 날씨 순위·당일치기 추천. 대표 지역(노을 순위 30곳)과 당일치기 후보 도시의 토·일 나들이 점수를
|
||||
# 워커가 하루 두 번(06:40·18:40) 미리 계산해 Redis 에 둔다. 없으면 순위 API 가 그 자리에서 계산한다.
|
||||
_SEED = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "seed", "trip_city.csv")
|
||||
_KEY = "weekend_rank:{:%Y%m%d}"
|
||||
_KEY = "weekend_rank:v2:{:%Y%m%d}" # v2: 점수를 바꾸기 표로 보정한 값 (옛 점수 캐시를 쓰지 않게 키를 바꿨다)
|
||||
_TTL = 13 * 3600
|
||||
_PARALLEL = 4 # 기상청 동시 호출 수
|
||||
_WAIT_STEPS, _WAIT_SEC = 60, 0.5
|
||||
_WINDOW = SimpleNamespace(windows=[{"from": OUTING_HOURS[0], "to": OUTING_HOURS[1]}])
|
||||
# 나들이 점수 바꾸기 표: 원래 점수 0~100 → 표시 점수(평균 60, 90점 이상은 드물게). scripts/gen_outing_score_table.py 가 만든다
|
||||
OUTING_SCORE_TABLE: list[int] = json.loads(
|
||||
open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "calc", "outing_score_table.json"), encoding="utf-8").read()
|
||||
)["table"]
|
||||
|
||||
|
||||
def calibrated_outing(score: int) -> int:
|
||||
return OUTING_SCORE_TABLE[score]
|
||||
|
||||
|
||||
def outing_day_score(result: Outing) -> int:
|
||||
"""순위·당일치기에 쓰는 하루 나들이 점수. 시간별 예보로 낸 점수와 중기예보 예상 점수 모두 같은 표를 거친다."""
|
||||
return calibrated_outing(result.score)
|
||||
|
||||
|
||||
# 당일치기: 내 지역에서 직선 이 거리 안의 후보 도시만 (1~2시간 거리), 너무 가까운 곳(같은 동네)은 뺀다.
|
||||
TRIP_MIN_KM, TRIP_MAX_KM = 20, 200
|
||||
TRIP_MIN_SCORE = 50
|
||||
TRIP_MIN_SCORE = calibrated_outing(50) # 원래 점수 50점과 같은 날씨 수준
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -205,7 +220,7 @@ class WeekendRank:
|
||||
if result is None or row is None:
|
||||
continue
|
||||
out.append(DayScore(
|
||||
region_code=region.code, day=d, score=result.score, reason=result.reason, icon=_icon(Sky(row.sky), RainType(row.rain_type)),
|
||||
region_code=region.code, day=d, score=outing_day_score(result), reason=result.reason, icon=_icon(Sky(row.sky), RainType(row.rain_type)),
|
||||
temp_min_c=float(row.temp_min_c) if row.temp_min_c is not None else None,
|
||||
temp_max_c=float(row.temp_max_c) if row.temp_max_c is not None else None,
|
||||
rain_prob=row.rain_prob, estimated=result.estimated,
|
||||
|
||||
Reference in new issue
Block a user