-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_form.html
More file actions
213 lines (188 loc) · 7.83 KB
/
test_form.html
File metadata and controls
213 lines (188 loc) · 7.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>医疗欺诈预测测试页面</title>
<style>
body {
font-family: 'Microsoft YaHei', Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="number"] {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
padding: 15px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #f9f9f9;
}
.feature-importance {
margin-top: 15px;
}
.feature-bar {
height: 20px;
background-color: #4CAF50;
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>医疗欺诈预测测试</h1>
<form id="predictionForm">
<div class="form-group">
<label for="monthlyPoolAmount">月统筹金额</label>
<input type="number" id="monthlyPoolAmount" name="月统筹金额" step="0.01">
</div>
<div class="form-group">
<label for="monthlyDrugAmount">月药品金额</label>
<input type="number" id="monthlyDrugAmount" name="月药品金额" step="0.01">
</div>
<div class="form-group">
<label for="approvalAmount">本次审批金额</label>
<input type="number" id="approvalAmount" name="本次审批金额" step="0.01">
</div>
<div class="form-group">
<label for="monthlyVisitCount">月就诊次数</label>
<input type="number" id="monthlyVisitCount" name="月就诊次数">
</div>
<div class="form-group">
<label for="aboveStartRatio">起付标准以上自负比例金额</label>
<input type="number" id="aboveStartRatio" name="起付标准以上自负比例金额" step="0.01">
</div>
<div class="form-group">
<label for="nonAccountAmount">非账户支付金额</label>
<input type="number" id="nonAccountAmount" name="非账户支付金额" step="0.01">
</div>
<div class="form-group">
<label for="personalAccountAmount">个人账户金额</label>
<input type="number" id="personalAccountAmount" name="个人账户金额" step="0.01">
</div>
<div class="form-group">
<label for="accountReimbursementAmount">可用账户报销金额</label>
<input type="number" id="accountReimbursementAmount" name="可用账户报销金额" step="0.01">
</div>
<div class="form-group">
<label for="poolPayAmount">统筹支付金额</label>
<input type="number" id="poolPayAmount" name="统筹支付金额" step="0.01">
</div>
<div class="form-group">
<label for="sequenceNumber">顺序号</label>
<input type="number" id="sequenceNumber" name="顺序号">
</div>
<div class="form-group">
<label for="drugCostAmount">药品费发生金额</label>
<input type="number" id="drugCostAmount" name="药品费发生金额" step="0.01">
</div>
<div class="form-group">
<label for="modelSelect">选择模型</label>
<select id="modelSelect">
<option value="dnn">DNN</option>
<option value="cnn">CNN</option>
<option value="rnn">RNN</option>
<option value="rf">随机森林</option>
<option value="xgb">XGBoost</option>
</select>
</div>
<button type="button" id="predictBtn">预测</button>
</form>
<div id="resultContainer" class="result" style="display: none;">
<h2>预测结果</h2>
<p>模型: <span id="model"></span></p>
<p>预测: <span id="prediction"></span></p>
<p>概率: <span id="probability"></span></p>
<div class="feature-importance">
<h3>特征重要性</h3>
<div id="featureChart"></div>
</div>
</div>
<script>
document.getElementById('predictBtn').addEventListener('click', async function() {
const form = document.getElementById('predictionForm');
const model = document.getElementById('modelSelect').value;
const formData = {};
// 收集表单数据
const inputs = form.querySelectorAll('input[type="number"]');
inputs.forEach(input => {
if (input.value) {
formData[input.name] = parseFloat(input.value);
} else {
formData[input.name] = 0;
}
});
try {
// 发送预测请求
const response = await fetch(`http://localhost:5000/api/predict-single/${model}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formData)
});
if (!response.ok) {
throw new Error(`服务器返回错误: ${response.status}`);
}
const result = await response.json();
console.log('预测结果:', result);
// 显示结果
document.getElementById('model').textContent = result.model;
document.getElementById('prediction').textContent = result.prediction === 1 ? '欺诈风险' : '正常';
document.getElementById('probability').textContent = (result.probability * 100).toFixed(2) + '%';
// 显示特征重要性
const featureChart = document.getElementById('featureChart');
featureChart.innerHTML = '';
const importances = result.feature_importance;
for (const [feature, importance] of Object.entries(importances)) {
const featureDiv = document.createElement('div');
featureDiv.innerHTML = `
<p>${feature}: ${(importance * 100).toFixed(2)}%</p>
<div class="feature-bar" style="width: ${importance * 100}%;"></div>
`;
featureChart.appendChild(featureDiv);
}
document.getElementById('resultContainer').style.display = 'block';
} catch (error) {
console.error('预测失败:', error);
alert('预测失败: ' + error.message);
}
});
// 检查表单是否可以输入
document.addEventListener('DOMContentLoaded', function() {
const testInput = document.getElementById('monthlyPoolAmount');
testInput.value = 100;
if (testInput.value === '100') {
console.log('表单输入正常工作');
} else {
console.error('表单输入异常');
}
});
</script>
</body>
</html>