docs(11-02): complete plan 11-02 - 置信度评估实现

- 新增三维度加权置信度计算方法
- 加权公式: 0.4*历史命中率 + 0.3*得分分布 + 0.3*集中度
- 数据量检查: 不足50期返回警告
- getPredictionV3返回结构扩展confidence字段
This commit is contained in:
2026-05-01 15:14:37 +08:00
parent 663d83c25c
commit 0221c596b1
3 changed files with 113 additions and 6 deletions
+3 -3
View File
@@ -155,8 +155,8 @@ Plans:
**Plans**: 5 plans **Plans**: 5 plans
Plans: Plans:
- [ ] 11-01-PLAN.md — 回测指标扩展(新增 NDCG@5、MRR、命中分布计算方法,扩展 _runBacktestV3 返回结构) - [x] 11-01-PLAN.md — 回测指标扩展(新增 NDCG@5、MRR、命中分布计算方法,扩展 _runBacktestV3 返回结构)
- [ ] 11-02-PLAN.md — 置信度评估实现(新增 _calculateConfidence 及辅助方法,扩展 getPredictionV3 返回结构) - [x] 11-02-PLAN.md — 置信度评估实现(新增 _calculateConfidence 及辅助方法,扩展 getPredictionV3 返回结构)
- [ ] 11-03-PLAN.md — 前端展示优化(更新 renderPredict 方法,展示置信度、NDCG、MRR、命中分布柱状图) - [ ] 11-03-PLAN.md — 前端展示优化(更新 renderPredict 方法,展示置信度、NDCG、MRR、命中分布柱状图)
- [ ] 11-04-PLAN.md — 权重网格搜索优化(新增 _optimizeWeightsGridSearch 方法,新增 optimizeWeights 接口入口) - [ ] 11-04-PLAN.md — 权重网格搜索优化(新增 _optimizeWeightsGridSearch 方法,新增 optimizeWeights 接口入口)
- [ ] 11-05-PLAN.md — 二阶马尔可夫转移概率增强(新增 _getTransitionMatrix2ndOrder、_calcTransitionScore2ndOrder 方法,根据数据量自动选择阶数) - [ ] 11-05-PLAN.md — 二阶马尔可夫转移概率增强(新增 _getTransitionMatrix2ndOrder、_calcTransitionScore2ndOrder 方法,根据数据量自动选择阶数)
@@ -180,4 +180,4 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 →
| 8. 和值分析 | 0/0 | Not planned | - | | 8. 和值分析 | 0/0 | Not planned | - |
| 9. 连号分析 | 0/0 | Not planned | - | | 9. 连号分析 | 0/0 | Not planned | - |
| 10. 尾数分析 | 0/0 | Not planned | - | | 10. 尾数分析 | 0/0 | Not planned | - |
| 11. predictV3算法优化 | 0/5 | Planned | - | | 11. predictV3算法优化 | 2/5 | Executing | - |
+4 -3
View File
@@ -4,14 +4,14 @@ milestone: v1.0
milestone_name: milestone milestone_name: milestone
status: verifying status: verifying
stopped_at: context exhaustion at 95% (2026-04-30) stopped_at: context exhaustion at 95% (2026-04-30)
last_updated: "2026-05-01T07:10:32.046Z" last_updated: "2026-05-01T07:13:49.247Z"
last_activity: 2026-05-01 last_activity: 2026-05-01
progress: progress:
total_phases: 11 total_phases: 11
completed_phases: 1 completed_phases: 1
total_plans: 8 total_plans: 8
completed_plans: 4 completed_plans: 5
percent: 50 percent: 63
--- ---
# Project State # Project State
@@ -51,6 +51,7 @@ Progress: [█████░░░░░] 50%
- N/A (no completed plans yet) - N/A (no completed plans yet)
| Phase 11-predictv3 P01 | 5min | 3 tasks | 1 files | | Phase 11-predictv3 P01 | 5min | 3 tasks | 1 files |
| Phase 11-predictv3 P02 | 2min | 2 tasks | 1 files |
## Accumulated Context ## Accumulated Context
@@ -0,0 +1,106 @@
---
phase: 11-predictv3
plan: 02
subsystem: prediction
tags: [confidence, prediction, evaluation, metrics]
dependencies:
requires: [11-01]
provides: [confidence_evaluation]
affects: [getPredictionV3]
tech_stack:
added: [confidence_calculation, weighted_scoring]
patterns: [multi_dimension_weighted_average, data_threshold_check]
key_files:
created: []
modified:
- path: application/admin/model/History.php
changes:
- 新增 _calculateConfidence 方法
- 新增 _getHistoricalHitRateByRank 方法
- 新增 _getScoreDistributionConfidence 方法
- 新增 _getScoreConcentration 方法
- getPredictionV3 新增 confidence 字段返回
key_decisions:
- 三维度加权公式: 0.4*历史命中率 + 0.3*得分分布 + 0.3*集中度
- 数据量阈值设为50期,不足时返回警告并使用估算
- 置信度阈值: >=70%高、50-70%中、<50%低
- 无回测数据时使用排名估算公式: 1 - (rank-1)*0.15
metrics:
duration: 5min
tasks_completed: 2
files_modified: 1
lines_added: 180
completed_at: "2026-05-01T07:15:00Z"
---
# Phase 11 - Plan 02: 置信度评估实现 Summary
## 一句话总结
为预测结果添加三维度加权置信度评估,帮助用户判断预测可靠性。
## 实现内容
### Task 1: 置信度核心计算方法
`History.php` 中新增 4 个方法:
| 方法 | 功能 |
|------|------|
| `_calculateConfidence` | 主计算方法,返回置信度分数和整体置信度 |
| `_getHistoricalHitRateByRank` | 基于历史排名统计命中率 |
| `_getScoreDistributionConfidence` | 计算得分在 Top5 中的分布比例 |
| `_getScoreConcentration` | 计算得分集中度(与平均值的差距) |
**加权公式:**
```
confidence = 0.4 * 历史命中率 + 0.3 * 得分分布 + 0.3 * 得分集中度
```
**数据量检查:**
- 回测数据不足 50 期时返回 `data_warning` 警告
- 无回测数据时使用估算公式: `1 - (rank-1) * 0.15`
### Task 2: getPredictionV3 集成
`getPredictionV3` 返回结构中新增 `confidence` 字段:
```php
return [
'predictions' => $predictions,
// ... 其他字段 ...
'confidence' => $confidence // 新增
];
```
`confidence` 结构:
```php
[
'confidence_scores' => [...], // 各号码置信度详情
'overall_confidence' => 65.5, // Top5 平均置信度
'data_warning' => null // 数据不足警告
]
```
## Deviations from Plan
None - plan executed exactly as written.
## Verification Results
所有验收标准满足:
- `_calculateConfidence` 方法已实现
- `_getHistoricalHitRateByRank` 方法已实现
- `_getScoreDistributionConfidence` 方法已实现
- `_getScoreConcentration` 方法已实现
- `minDataThreshold` 参数存在(50期阈值)
- `score_concentration` 在返回结构中存在
- `getPredictionV3` 返回结构包含 `confidence` 字段
- 所有方法包含函数级注释
## Self-Check: PASSED
- 文件已修改: application/admin/model/History.php
- 提交已创建: 663d83c
- 所有方法已实现并包含注释