修改了特征分析图表的显示和热力图说明

This commit is contained in:
tianjianyong 2024-12-01 21:22:11 +08:00
parent 04e43760ae
commit 1c91ba42ab
2 changed files with 36 additions and 5 deletions

View File

@ -67,12 +67,18 @@
<h3>特征重要性</h3>
<div class="chart-container">
<div ref="importanceChartRef" style="width: 100%; height: 600px"></div>
<div class="chart-note">
<p>说明F-特征分数是基于F统计量的特征重要性度量用于评估各个特征与预测目标之间的相关程度F分数越高表示该特征与预测目标之间的相关性越强但不一定是线性关系F分数没有固定的上限其值取决于数据的特征分布和样本量</p>
</div>
</div>
<!-- 相关性分析 -->
<h3>相关性分析</h3>
<div class="chart-container">
<div ref="correlationChartRef" style="width: 100%; height: 800px"></div>
<div class="chart-note">
<p>说明热力图展示了各特征之间的相关系数范围从-1到1正值蓝色表示正相关负值红色表示负相关0白色表示无相关性相关系数的绝对值越接近1表示相关性越强越接近0表示相关性越弱</p>
</div>
</div>
<!-- 火箭炮特有的图表 -->
@ -404,19 +410,27 @@ const renderCharts = () => {
//
const importanceOption = {
title: { text: '特征重要性排序' },
title: {
text: '特征重要性排序',
left: 'center'
},
tooltip: {
trigger: 'item',
axisPointer: {
type: 'shadow'
},
formatter: function(params) {
return `${params.name}: ${params.value.toFixed(1)}`
return `${params.name}: ${params.value.toFixed(2)}`
}
},
xAxis: {
type: 'value',
name: '重要性得分'
name: 'F-特征分数',
axisLabel: {
formatter: function(value) {
return value.toFixed(1)
}
}
},
yAxis: {
type: 'category',
@ -1106,4 +1120,12 @@ function debounce(fn, delay) {
}
}
}
.chart-note {
margin-top: 10px;
padding: 10px;
color: #666;
font-size: 14px;
line-height: 1.5;
}
</style>

View File

@ -212,11 +212,20 @@ class FeatureAnalysis:
# 创建特征重要性列表(使用中文名称)
important_features = []
# 过滤掉无效的分数
valid_scores = importance_scores[~np.isnan(importance_scores)]
# 记录一些统计信息
logger.info(f"F-score statistics:")
logger.info(f"min={np.min(valid_scores):.2f}, max={np.max(valid_scores):.2f}, "
f"mean={np.mean(valid_scores):.2f}, median={np.median(valid_scores):.2f}")
for idx, (name, score) in enumerate(zip(feature_names, importance_scores)):
if not np.isnan(score):
important_features.append({
'name': self.feature_name_map.get(name, name), # 使用中文名称
'importance': float(score)
'name': self.feature_name_map.get(name, name),
'importance': float(score) # 保持原始F-score
})
# 按重要性排序