新岗位发现:增长率改双年窗口口径(修复成熟岗位被误杀),测试对齐四指标阈值

This commit is contained in:
RoyirinRosmontis
2026-08-03 13:30:42 +08:00
parent a10442d78c
commit 441d555caf
2 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -143,9 +143,12 @@ def discover_new_jobs(
continue continue
years = Counter(r.publish_date.year for r in group) years = Counter(r.publish_date.year for r in group)
latest_year = max(years) latest_year = max(years)
prev_year_n = years.get(latest_year - 1, 0) # 增长率:最近两年合计 / 之前两年合计(从无到有视为达标)。
# 前一年没有基数视为“从无到有”,增长率视为达标 # 按年同比会在岗位成熟后回落(如 2026/2025=1.43),
growth = years[latest_year] / prev_year_n if prev_year_n else float("inf") # 双年窗口更能刻画"正在兴起"的全周期趋势(与方案"增长率≥50%"一致)。
recent2 = years[latest_year] + years.get(latest_year - 1, 0)
before2 = years.get(latest_year - 2, 0) + years.get(latest_year - 3, 0)
growth = recent2 / before2 if before2 else float("inf")
if growth < min_growth: if growth < min_growth:
continue continue
# 差异度:与最近既有岗位质心的距离,过近说明只是既有岗位的变体 # 差异度:与最近既有岗位质心的距离,过近说明只是既有岗位的变体
+2 -2
View File
@@ -172,7 +172,7 @@ def test_discover_candidate_carries_support_evidence():
from app.models import ExtractionResult from app.models import ExtractionResult
records, extractions = [], {} records, extractions = [], {}
for i in range(9): for i in range(15): # ≥ MIN_CLUSTER_SIZE(15),5 家企业 ≥ MIN_COMPANIES(5)
r = JDRecord(jid=f"c{i}", job_title="提示词工程师", company=f"公司{i % 5}", r = JDRecord(jid=f"c{i}", job_title="提示词工程师", company=f"公司{i % 5}",
industry="人工智能", publish_date=date(2025, i % 6 + 1, 1), industry="人工智能", publish_date=date(2025, i % 6 + 1, 1),
text="负责大模型提示词设计与优化", source_id=f"t.jsonl#{i + 1}") text="负责大模型提示词设计与优化", source_id=f"t.jsonl#{i + 1}")
@@ -183,7 +183,7 @@ def test_discover_candidate_carries_support_evidence():
cands = cluster.discover_new_jobs(records, extractions, known_titles=set()) cands = cluster.discover_new_jobs(records, extractions, known_titles=set())
assert len(cands) == 1 assert len(cands) == 1
c = cands[0] c = cands[0]
assert len(c.support_source_ids) == 9 assert len(c.support_source_ids) == 15
assert min(c.support_windows) == "2025Q1" assert min(c.support_windows) == "2025Q1"
assert c.industries == ["人工智能"] assert c.industries == ["人工智能"]