94 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
	
| # -*- coding: utf-8 -*-
 | |
| 
 | |
| '''
 | |
| 
 | |
| 脚本说明:基于赔案查询获取的赔案数据进行规则测试
 | |
| 
 | |
| '''
 | |
| 
 | |
| #导入模块
 | |
| 
 | |
| import json
 | |
| 
 | |
| import pandas
 | |
| 
 | |
| import os
 | |
| 
 | |
| import sys
 | |
| 
 | |
| sys.path.append(os.path.dirname(os.path.dirname(__file__)))
 | |
| 
 | |
| #导入普康自动化审核决策模型
 | |
| from cognition import Cognition
 | |
| 
 | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
 | |
| 
 | |
| from utils.pandas_extension import SaveAsExcel
 | |
| 
 | |
| print('正在打开文件并抽取数据...', end = '')
 | |
| 
 | |
| file_paths = []
 | |
| 
 | |
| #遍历存放赔案数据的文件夹,获取文件路径并添加至文件路径列表
 | |
| for directory_path, directory_name, file_names in os.walk('../dataset'):
 | |
| 
 | |
| 	for file_name in file_names:
 | |
| 
 | |
| 		if file_name != '.DS_Store':
 | |
| 
 | |
| 			#构建文件路径
 | |
| 			file_path = os.path.join(directory_path, file_name)
 | |
| 
 | |
| 			file_paths.append(file_path)
 | |
| 
 | |
| #获取最新修改的文件路径
 | |
| file_path = max(file_paths, key = os.path.getmtime)
 | |
| 
 | |
| #读取文件数据
 | |
| with open(file_path, 'r', encoding = 'utf-8') as file:
 | |
| 
 | |
| 	file_data = json.load(file)
 | |
| 
 | |
| print('已完成')
 | |
| print()
 | |
| 
 | |
| print('正转化数据...', end = '')
 | |
| 
 | |
| #用于保存数据
 | |
| data = []
 | |
| 
 | |
| #遍历数据
 | |
| for extractions in file_data:
 | |
| 
 | |
| 	#实例化普康自动化审核决策模型
 | |
| 	decision = Cognition(extractions = extractions).after_adjustment(insurance = '瑞泰人寿保险有限公司')
 | |
| 
 | |
| 	#定义规则结果
 | |
| 	decision_data = {'赔案号': decision.get('赔案号'), '审核结论': decision.get('审核结论'), '自动化:审核结论': decision.get('自动化:审核结论')}
 | |
| 
 | |
| 	#平铺规则结果
 | |
| 	for key, value in list(decision.get('规则结果').items()):
 | |
| 
 | |
| 		decision_data.update({key: value})
 | |
| 
 | |
| 	data.append(decision_data)
 | |
| 
 | |
| dataset = pandas.DataFrame(data = data)
 | |
| 
 | |
| dataset['是否正确'] = (dataset['审核结论'] == dataset['自动化:审核结论']).astype(int)
 | |
| 
 | |
| print('已完成')
 | |
| print()
 | |
| 
 | |
| print('正在将数据保存为EXCEL', end = '')
 | |
| 
 | |
| SaveAsExcel(worksheets = [['Sheet1', dataset]], file_path = 'evaluation_report.xlsx')	
 | |
| 
 | |
| print('已完成')
 | |
| print()
 | |
| 
 | |
| '''
 | |
| 
 | |
| 修改记录
 | |
| 
 | |
| ''' |