modify: 删除隐私文件
This commit is contained in:
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
sample/
|
||||||
|
strategy_evaluation_results.csv
|
||||||
|
run_metadata.json
|
||||||
|
*.log
|
||||||
|
simulation.html
|
||||||
|
.DS_Store
|
||||||
|
overview_series.html
|
||||||
47
CHANGELOG.md
Normal file
47
CHANGELOG.md
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [1.1.0] - 2025-08-28
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Integrated GPT-based analysis for comprehensive traffic safety insights
|
||||||
|
- Added automated report generation with AI-powered recommendations
|
||||||
|
- Implemented natural language query processing for data exploration
|
||||||
|
- Added export functionality for analysis reports (PDF/CSV formats)
|
||||||
|
- Included sentiment analysis for accident description texts
|
||||||
|
|
||||||
|
### Enhanced
|
||||||
|
- Improved data visualization with interactive charts and heatmaps
|
||||||
|
- Optimized prediction algorithms with enhanced machine learning models
|
||||||
|
- Expanded dataset with additional traffic parameters and weather conditions
|
||||||
|
- Upgraded user interface with responsive design and dark mode support
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Resolved session state KeyError in multi-tab navigation
|
||||||
|
- Fixed data persistence issues between application refreshes
|
||||||
|
- Corrected timestamp parsing errors in accident data import
|
||||||
|
- Addressed memory leaks in large dataset processing
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
- Updated README with new GPT analysis features and usage examples
|
||||||
|
- Added API documentation for extended functionality
|
||||||
|
- Included sample datasets and tutorial guides
|
||||||
|
|
||||||
|
## [1.0.0] - 2025-08-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Initial release of TrafficSafeAnalyzer
|
||||||
|
- Streamlit app with tabs for data analysis, prediction, and strategy evaluation
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Resolved session state KeyError
|
||||||
|
|
||||||
|
## [1.0.0] - 2025-08-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Initial release of TrafficSafeAnalyzer.
|
||||||
|
- Streamlit app with tabs for data analysis, prediction, and strategy evaluation.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Resolved session state KeyError.
|
||||||
19
LICENSE
Normal file
19
LICENSE
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2025 TongNian
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
0
docs/install.md
Normal file
0
docs/install.md
Normal file
0
docs/usage.md
Normal file
0
docs/usage.md
Normal file
148
readme.md
Normal file
148
readme.md
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
# TrafficSafeAnalyzer
|
||||||
|
|
||||||
|
一个基于 Streamlit 的交通安全分析系统,支持事故数据分析、预测模型、异常检测和策略评估。
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
|
||||||
|
- 加载和清洗事故与策略数据(Excel 格式)
|
||||||
|
- 使用 ARIMA、KNN、GLM、SVR 等模型预测事故趋势
|
||||||
|
- 检测异常事故点
|
||||||
|
- 评估交通策略效果并提供推荐
|
||||||
|
|
||||||
|
## 安装步骤
|
||||||
|
|
||||||
|
### 前提条件
|
||||||
|
|
||||||
|
- Python 3.8+
|
||||||
|
- Git
|
||||||
|
- 可选:Docker(用于容器化部署)
|
||||||
|
|
||||||
|
### 安装
|
||||||
|
|
||||||
|
1. 克隆仓库:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/tongnian0613/TrafficSafeAnalyzer.git
|
||||||
|
cd TrafficSafeAnalyzer
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 创建虚拟环境(推荐):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda create -n trafficsa python=3.12 -y
|
||||||
|
conda activate trafficsa
|
||||||
|
pip install -r requirements.txt
|
||||||
|
streamlit run app.py
|
||||||
|
```
|
||||||
|
|
||||||
|
3. 安装依赖:
|
||||||
|
|
||||||
|
(1) 基本安装(必需依赖)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install streamlit pandas numpy matplotlib plotly scikit-learn statsmodels scipy
|
||||||
|
```
|
||||||
|
|
||||||
|
(2) 完整安装(包含所有可选依赖)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
(3) 或者手动安装可选依赖
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install streamlit-autorefresh openpyxl xlrd cryptography
|
||||||
|
```
|
||||||
|
|
||||||
|
(4) 运行应用:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
streamlit run app.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## 依赖项
|
||||||
|
|
||||||
|
列于 `requirements.txt`:
|
||||||
|
|
||||||
|
```txt
|
||||||
|
streamlit>=1.20.0
|
||||||
|
pandas>=1.3.0
|
||||||
|
numpy>=1.21.0
|
||||||
|
matplotlib>=3.4.0
|
||||||
|
plotly>=5.0.0
|
||||||
|
scikit-learn>=1.0.0
|
||||||
|
statsmodels>=0.13.0
|
||||||
|
scipy>=1.7.0
|
||||||
|
streamlit-autorefresh>=0.1.5
|
||||||
|
python-dateutil>=2.8.2
|
||||||
|
pytz>=2021.3
|
||||||
|
openpyxl>=3.0.9
|
||||||
|
xlrd>=2.0.1
|
||||||
|
cryptography>=3.4.7
|
||||||
|
openai>=2.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## 配置参数
|
||||||
|
|
||||||
|
- **数据文件**:上传事故数据(`accident_file`)和策略数据(`strategy_file`),格式为 Excel
|
||||||
|
- **环境变量**(可选):
|
||||||
|
- `LOG_LEVEL=DEBUG`:启用详细日志
|
||||||
|
- 示例:`export LOG_LEVEL=DEBUG`(Linux/macOS)或 `set LOG_LEVEL=DEBUG`(Windows)
|
||||||
|
|
||||||
|
## 输入输出格式
|
||||||
|
|
||||||
|
### 输入
|
||||||
|
- **事故数据 Excel**:需包含 `事故时间`、`所在街道`、`事故类型` 列
|
||||||
|
- **策略数据 Excel**:需包含 `发布时间`、`交通策略类型` 列
|
||||||
|
|
||||||
|
### 输出
|
||||||
|
- **预测结果**:CSV 文件(例如 `arima_forecast.csv`)
|
||||||
|
- **图表**:HTML 文件(例如 `overview_series.html`)
|
||||||
|
- **策略推荐**:文本文件(`recommendation.txt`)
|
||||||
|
|
||||||
|
## 调用示例
|
||||||
|
|
||||||
|
运行 Streamlit 应用:
|
||||||
|
```bash
|
||||||
|
streamlit run app.py
|
||||||
|
```
|
||||||
|
|
||||||
|
访问 http://localhost:8501,上传数据文件并交互分析。
|
||||||
|
|
||||||
|
## 常见问题排查
|
||||||
|
|
||||||
|
**问题**:`ModuleNotFoundError: No module named 'streamlit'`
|
||||||
|
**解决**:运行 `pip install -r requirements.txt` 或检查 Python 环境
|
||||||
|
|
||||||
|
**问题**:数据加载失败
|
||||||
|
**解决**:确保 Excel 文件格式正确,检查列名是否匹配
|
||||||
|
|
||||||
|
**问题**:`NameError: name 'strategy_metrics' is not defined`
|
||||||
|
**解决**:确保 `strategy_metrics` 函数定义在 `app.py` 中,且位于 `run_streamlit_app` 函数内
|
||||||
|
|
||||||
|
## 日志分析
|
||||||
|
|
||||||
|
- **日志文件**:`logs/app.log`(需在代码中配置 logging 模块)
|
||||||
|
- **查看日志**:`tail -f logs/app.log`
|
||||||
|
- **常见错误**:
|
||||||
|
- `ValueError`:检查输入数据格式
|
||||||
|
- `ConnectionError`:验证网络连接或文件路径
|
||||||
|
|
||||||
|
## 升级说明
|
||||||
|
|
||||||
|
- **当前版本**:v1.0.0
|
||||||
|
- **升级步骤**:
|
||||||
|
1. 备份数据和配置文件
|
||||||
|
2. 拉取最新代码:`git pull origin main`
|
||||||
|
3. 更新依赖:`pip install -r requirements.txt --upgrade`
|
||||||
|
4. 重启应用:`streamlit run app.py`
|
||||||
|
|
||||||
|
参考 `CHANGELOG.md` 查看版本变更详情。
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
MIT License - 详见 LICENSE 文件。
|
||||||
|
|
||||||
|
[](https://github.com/tongnian0613/TrafficSafeAnalyzer/LICENSE)
|
||||||
|
[](https://travis-ci.org/tongnian0613/repo)
|
||||||
1
recommendation.txt
Normal file
1
recommendation.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
建议在全市区域长期实施策略类型 交通管制措施
|
||||||
31
requirements.txt
Normal file
31
requirements.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Core dependencies
|
||||||
|
streamlit>=1.20.0
|
||||||
|
pandas>=1.3.0
|
||||||
|
numpy>=1.21.0
|
||||||
|
matplotlib>=3.4.0
|
||||||
|
plotly>=5.0.0
|
||||||
|
scikit-learn>=1.0.0
|
||||||
|
statsmodels>=0.13.0
|
||||||
|
|
||||||
|
# Scientific computing (optional but recommended)
|
||||||
|
scipy>=1.7.0
|
||||||
|
|
||||||
|
# Streamlit extensions (optional)
|
||||||
|
streamlit-autorefresh>=0.1.5
|
||||||
|
|
||||||
|
# Additional utilities
|
||||||
|
python-dateutil>=2.8.2
|
||||||
|
pytz>=2021.3
|
||||||
|
|
||||||
|
# For data processing
|
||||||
|
openpyxl>=3.0.9 # For Excel file support
|
||||||
|
xlrd>=2.0.1 # For older Excel files
|
||||||
|
|
||||||
|
# Security/authentication
|
||||||
|
cryptography>=3.4.7
|
||||||
|
|
||||||
|
# OpenAI
|
||||||
|
openai
|
||||||
|
|
||||||
|
# Note: hashlib and json are part of Python standard library
|
||||||
|
# Note: os and datetime are part of Python standard library
|
||||||
Reference in New Issue
Block a user