This commit is contained in:
512song committed 2024-10-10 18:53:00 +08:00
1 parent 47bc01514d
commit 31482fb2f5
3 files changed
+248 -510

No files matched your search

+18 -165
View File
@@ -431,15 +431,15 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"id": "3e614f4a-a623-48e2-97f8-b31f62c9a983",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-08T11:25:00.162666Z",
"iopub.status.busy": "2024-10-08T11:25:00.161915Z",
"iopub.status.idle": "2024-10-08T11:25:00.180116Z",
"shell.execute_reply": "2024-10-08T11:25:00.179490Z",
"shell.execute_reply.started": "2024-10-08T11:25:00.162592Z"
"iopub.execute_input": "2024-10-10T04:19:31.792657Z",
"iopub.status.busy": "2024-10-10T04:19:31.791903Z",
"iopub.status.idle": "2024-10-10T04:19:31.845405Z",
"shell.execute_reply": "2024-10-10T04:19:31.844817Z",
"shell.execute_reply.started": "2024-10-10T04:19:31.792583Z"
},
"tags": []
},
@@ -544,15 +544,15 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"id": "141b30dc-5975-4dcb-9bc3-9b20d26a0917",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-08T11:25:10.348657Z",
"iopub.status.busy": "2024-10-08T11:25:10.348028Z",
"iopub.status.idle": "2024-10-08T11:25:10.367430Z",
"shell.execute_reply": "2024-10-08T11:25:10.366876Z",
"shell.execute_reply.started": "2024-10-08T11:25:10.348595Z"
"iopub.execute_input": "2024-10-10T04:19:34.936239Z",
"iopub.status.busy": "2024-10-10T04:19:34.935929Z",
"iopub.status.idle": "2024-10-10T04:19:34.954873Z",
"shell.execute_reply": "2024-10-10T04:19:34.954373Z",
"shell.execute_reply.started": "2024-10-10T04:19:34.936209Z"
},
"tags": []
},
@@ -689,153 +689,6 @@
"print('ok!') "
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "30c4c256-a75d-40dd-b9cf-e3102fd4ab5a",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-08T11:25:33.793524Z",
"iopub.status.busy": "2024-10-08T11:25:33.792822Z",
"iopub.status.idle": "2024-10-08T11:25:33.811389Z",
"shell.execute_reply": "2024-10-08T11:25:33.810061Z",
"shell.execute_reply.started": "2024-10-08T11:25:33.793457Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"\n",
"filename = '../item.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl) \n",
"for k,v in dict3.items():\n",
" item[k] = v\n",
"item['1']['en'] = 'lung'\n",
"item['2']['en'] = 'grip'\n",
"item['3']['en'] = 'flexion'\n",
"item['4']['en'] = 'jump'\n",
"item['5']['en'] = 'pushup'\n",
"item['6']['en'] = 'balance'\n",
"item['7']['en'] = 'reaction'\n",
"item['8']['en'] = 'step'\n",
"item['9']['en'] = 'situp'\n",
"item['10']['en'] = 'height'\n",
"item['11']['en'] = 'weight'\n",
"\n",
"filename = 'data/体质检测标准 (1).json' \n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"\n",
"\n",
"def cal_score(data1):\n",
" #data = {'name':'张三','sex':'M','age':37,'item':'StepExperiment','result':46} \n",
" person = dict1['person']\n",
" criteria = dict1['criteria']\n",
" if data1['age'] >59:\n",
" data1['age'] = 59\n",
" if data1['age'] <20:\n",
" data1['age'] = 20\n",
" info = data1['sex']+str(data1['age'])\n",
" bz = person[info]\n",
" mx = criteria[bz][data1['item']]\n",
" result = data1['result'] \n",
" if data1['item'] == 'reaction':\n",
" for bz1 in mx:\n",
" if result > bz1:\n",
" #print(bz1)\n",
" score = mx.index(bz1,0)\n",
" break\n",
" else:\n",
" score = 5\n",
" else:\n",
" for bz1 in mx:\n",
" if result < bz1:\n",
" #print(bz1)\n",
" score = mx.index(bz1,0)\n",
" break\n",
" else:\n",
" score = 5\n",
" return(score)\n",
"filename = 'data/体质检测标准_BMI.json'\n",
"with open(filename,'r') as fl:\n",
" dict4 = json.load(fl) \n",
" \n",
"def cal_bmi(data1):\n",
" # data = {'name':'张三','sex':'M','age':37,'item':'HeightWeight','result':'177.7,97.0'}\n",
" person = dict4['person']\n",
" criteria = dict4['criteria']\n",
" if data1['age'] > 59:\n",
" data1['age'] = 59\n",
" if data1['age'] <20:\n",
" data1['age'] = 20\n",
" info = data1['sex']+str(data1['age'])\n",
" bz = person[info]\n",
" #print(bz)\n",
" result = data1['result']\n",
" #print(data1['code'],result)\n",
" height = int(float(result.split(',')[0]))\n",
" weight = float(result.split(',')[1])\n",
" if str(height) not in criteria[bz]:\n",
" score = 1\n",
" else: \n",
" mx = criteria[bz][str(height)]\n",
" if weight < mx[0]:\n",
" score = 1\n",
" elif weight < mx[1]:\n",
" score = 3\n",
" elif weight < mx[2]:\n",
" score = 5 \n",
" elif weight <= mx[3]:\n",
" score = 3 \n",
" elif weight > mx[3]:\n",
" score = 1\n",
" return score\n",
" \n",
" \n",
"\n",
"#list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','height','weight']\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
"filename = 'data/result_样本.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for k, v in dict2.items():\n",
" #print(k)\n",
" if v['sex'] == '男':\n",
" sex = 'M'\n",
" else:\n",
" sex = 'F' \n",
" if 'height' in v.keys() and 'weight' in v.keys():\n",
" bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':'HeightWeight','result':bmi_data}\n",
" dict2[k]['bmi'] = {}\n",
" dict2[k]['bmi']['成绩'] = bmi_data\n",
" dict2[k]['bmi']['score'] = cal_bmi(data1)\n",
" for item_en in list_item:\n",
" if item_en in v.keys(): \n",
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':item_en,'result':float(v[item_en]['成绩'].split()[0])}\n",
" dict2[k][item_en]['score'] = cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"\n",
"filename = f'data/result_样本.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
]
},
{
"cell_type": "markdown",
"id": "ceef0742-f62a-4a7d-b0d5-be7ae7abb741",
@@ -846,15 +699,15 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"id": "b123ee6b-85d2-4660-b226-321832a6b796",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-08T11:25:43.507759Z",
"iopub.status.busy": "2024-10-08T11:25:43.506935Z",
"iopub.status.idle": "2024-10-08T11:26:24.811404Z",
"shell.execute_reply": "2024-10-08T11:26:24.810202Z",
"shell.execute_reply.started": "2024-10-08T11:25:43.507684Z"
"iopub.execute_input": "2024-10-10T04:22:38.050651Z",
"iopub.status.busy": "2024-10-10T04:22:38.049905Z",
"iopub.status.idle": "2024-10-10T04:23:20.183719Z",
"shell.execute_reply": "2024-10-10T04:23:20.182527Z",
"shell.execute_reply.started": "2024-10-10T04:22:38.050579Z"
},
"tags": []
},