Files
my_git_project/CardioAI/README.md
zhenchuan199 b5b299a682 Add CardioAI project with usage instructions
- Add comprehensive README.md with setup and usage instructions
- Add .env.example template (sanitized, no real API keys)
- Add root-level .gitignore to exclude .env and generated files
- Add all project modules (dashboard, predictor)
- Add data file and requirements.txt
2026-04-02 20:11:24 +08:00

103 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CardioAI - 心血管疾病智能辅助系统
多模块应用集成了数据可视化、机器学习预测和AI问答功能。
## 项目结构
```
CardioAI/
├── data/ # 数据文件目录
│ └── 心血管疾病.xlsx # 心血管疾病数据集
├── module1_dashboard/ # 模块1: Streamlit 交互式仪表盘
│ └── cardio_dashboard.py
├── module2_predictor/ # 模块2: XGBoost 风险预测模型
│ ├── train_and_save.py # 模型训练脚本
│ ├── cardio_predictor_model.pkl # 训练好的模型
│ ├── app.py # Flask API 服务
│ └── templates/
│ └── index.html # 预测前端页面
├── requirements.txt # 项目依赖
├── .env.example # 环境变量模板
└── .gitignore # Git 忽略文件
```
## 环境配置
### 1. 创建 conda 环境
```bash
conda create -n cardioenv python=3.10
conda activate cardioenv
```
### 2. 安装依赖
```bash
cd F:\My_Git_Project\CardioAI
pip install -r requirements.txt
```
### 3. 配置环境变量
复制 `.env.example``.env`,并填入您的 API Key
```bash
copy .env.example .env
```
编辑 `.env` 文件,填入您的 DeepSeek API Key。
## 模块说明
### 模块1: 交互式仪表盘 (Streamlit)
心血管数据的交互式可视化界面。
**启动命令:**
```bash
cd F:\My_Git_Project\CardioAI
streamlit run module1_dashboard/cardio_dashboard.py
```
**功能特性:**
- 年龄范围筛选
- 性别和心血管疾病状态筛选
- 统计数据展示
- BMI分布可视化
### 模块2: 心血管风险预测模型 (Flask + XGBoost)
基于 XGBoost 的心血管疾病风险预测 API。
**训练模型:**
```bash
cd F:\My_Git_Project\CardioAI
python module2_predictor/train_and_save.py
```
**启动预测服务:**
```bash
cd F:\My_Git_Project\CardioAI\module2_predictor
set FLASK_APP=app.py
flask run --host=0.0.0.0 --port=5000
```
**API 接口:**
- `POST /predict_cardio` - 提交11个特征值返回预测概率和结果
## 依赖说明
- pandas, openpyxl - 数据处理
- numpy, scikit-learn - 数值计算
- xgboost, joblib - 机器学习
- streamlit, plotly - 数据可视化
- Flask - Web 服务
- python-dotenv - 环境变量
- langchain-openai, dashscope, requests - AI 集成
## 注意事项
1. 数据文件路径可通过 `.env` 中的 `DATA_PATH` 配置
2. 确保 `.env` 文件不提交到版本库(已加入 .gitignore
3. 使用前请确保已正确配置 DeepSeek API Key