- 新增中国企业员工缺勤模拟数据集生成脚本(generate_dataset.py),覆盖7个行业、180家企业、2600名员工 - 重构 config.py,更新特征字段为中文名称,调整目标列、员工ID、行业类型等配置 - 重构 clustering.py,简化聚类逻辑,更新聚类特征和群体命名(高压通勤型、健康波动型等) - 重构 feature_mining.py,更新相关性分析和群体比较维度(按行业、班次、婚姻状态等) - 新增 model_features.py 定义模型训练特征 - 更新 preprocessing.py 和 train_model.py 适配新数据结构 - 更新各 API 路由默认参数(model: random_forest, dimension: industry) - 前端更新主题样式和各视图组件适配中文字段 - 更新系统名称为 China Enterprise Absence Analysis System
69 lines
1.8 KiB
Python
69 lines
1.8 KiB
Python
from flask import Flask
|
|
from flask_cors import CORS
|
|
|
|
from api import register_blueprints
|
|
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
|
|
CORS(app)
|
|
|
|
register_blueprints(app)
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return {
|
|
'code': 200,
|
|
'message': 'China Enterprise Absence Analysis System API',
|
|
'data': {
|
|
'version': '1.0.0',
|
|
'endpoints': {
|
|
'overview': [
|
|
'/api/overview/stats',
|
|
'/api/overview/trend',
|
|
'/api/overview/weekday',
|
|
'/api/overview/reasons',
|
|
'/api/overview/seasons'
|
|
],
|
|
'analysis': [
|
|
'/api/analysis/importance',
|
|
'/api/analysis/correlation',
|
|
'/api/analysis/compare'
|
|
],
|
|
'predict': [
|
|
'/api/predict/single',
|
|
'/api/predict/model-info'
|
|
],
|
|
'cluster': [
|
|
'/api/cluster/result',
|
|
'/api/cluster/profile',
|
|
'/api/cluster/scatter'
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
@app.errorhandler(404)
|
|
def not_found(e):
|
|
return {
|
|
'code': 404,
|
|
'message': 'Resource not found',
|
|
'data': None
|
|
}, 404
|
|
|
|
@app.errorhandler(500)
|
|
def server_error(e):
|
|
return {
|
|
'code': 500,
|
|
'message': 'Internal server error',
|
|
'data': None
|
|
}, 500
|
|
|
|
return app
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app = create_app()
|
|
app.run(host='0.0.0.0', port=5000, debug=True)
|