EngEleLuiz/datacenter-energy-platform-v2

GitHub: EngEleLuiz/datacenter-energy-platform-v2

面向数据中心能源管理的端到端数据工程平台,集成实时遥测采集、ML 异常检测、PUE 预测和 GFM/GFL 逆变器模式分类功能。

Stars: 0 | Forks: 0

# 数据中心能源智能平台 [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/fd3efd7983051556.svg)](https://github.com/EngEleLuiz/datacenter-energy-platform-v2/actions) [![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://datacenter-energy-platform-v2.streamlit.app) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-311/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) 用于实时数据中心遥测、ML 驱动的异常检测以及 Grid-Forming/Grid-Following (GFM/GFL) 逆变器模式分类的端到端平台。 ## 在线演示 ▶ **[datacenter-energy-platform-v2.streamlit.app](https://datacenter-energy-platform-v2.streamlit.app)** ## 功能说明 | 模块 | 描述 | |---|---| | **GFM/GFL 分类器** | 使用时间滚动特征从 5 分钟 SCADA 遥测数据中检测逆变器控制模式 (Grid-Following、Grid-Forming、Transitioning) | | **异常检测** | 基于服务器遥测数据 (CPU、内存、网络、电源) 的 Isolation Forest 异常检测 | | **PUE 预测** | 基于 LSTM 的 Power Usage Effectiveness 预测 | | **实时仪表板** | 带有 SHAP 解释、Grafana KPI、天气/能源定价的 Streamlit 仪表板 | ## 架构 ``` ┌─────────────────┐ Kafka ┌──────────────────┐ │ data-generator │ ─────────────► │ ml-worker │ │ (Container 1) │ │ (Container 3) │ │ │ │ Airflow DAGs │ │ Inverter sim │ │ MLflow tracking│ │ Server sim │ └────────┬─────────┘ │ UPS sim │ │ model artifacts └─────────────────┘ ▼ ┌──────────────────┐ │ dashboard │ PostgreSQL ◄──────────────│ (Container 2) │ MinIO ◄──────────────│ Streamlit │ MLflow ◄──────────────│ Port 8501 │ └──────────────────┘ ``` ## 容器 | 容器 | 镜像大小 | 用途 | |---|---|---| | `generator` | ~200 MB | 运行逆变器/服务器/UPS 模拟器 → Kafka | | `dashboard` | ~600 MB | Streamlit 应用 + ML 推理 | | `ml-worker` | ~2 GB | Airflow DAGs + 模型训练 (仅限本地) | ## 快速开始 ``` # 1. Clone git clone https://github.com/EngEleLuiz/datacenter-energy-platform-v2 cd datacenter-energy-platform-v2 # 2. 配置 secrets cp .env.example .env # 使用你的密码编辑 .env(所需键请参见 .env.example) # 3. 启动 infrastructure + generator + dashboard docker compose up -d postgres minio kafka mlflow grafana generator dashboard # 4. 打开 dashboard open http://localhost:8501 # 5. (可选)启动 Airflow — 仅限本地训练 docker compose --profile local up -d ml-worker open http://localhost:8080 ``` ## Streamlit Cloud 部署 仪表板在 [Streamlit Cloud](https://streamlit.io/cloud) 上运行,无需额外配置。 **Streamlit Cloud 中的设置:** - Repository: `EngEleLuiz/datacenter-energy-platform-v2` - Branch: `main` - Main file path: `dashboard/app.py` - Python version: `3.11` Secrets (在 Streamlit Cloud → App Settings → Secrets 中设置): ``` OPENWEATHER_API_KEY = "your_key_here" POSTGRES_HOST = "your_db_host" POSTGRES_USER = "your_user" POSTGRES_PASSWORD = "your_password" POSTGRES_DB = "your_db" ``` 如果未设置 secrets,仪表板将以 **演示模式** 运行 (即时模拟数据,无需外部连接)。 ## 项目结构 ``` datacenter-energy-platform-v2/ ├── data_generator/ # Container 1 — simulators │ ├── ups_inverter_simulator.py │ ├── server_simulator.py │ ├── kafka_producer.py │ └── requirements.txt # minimal: kafka, pandas, numpy ├── dashboard/ # Container 2 — Streamlit │ ├── app.py │ └── requirements.txt # streamlit, sklearn, shap, plotly ├── dags/ # Container 3 — Airflow DAGs ├── docker/ # One Dockerfile per container │ ├── data-generator/Dockerfile │ ├── dashboard/Dockerfile │ └── ml-worker/Dockerfile ├── ml/ # Trained model artifacts │ ├── gfm_classifier.pkl │ ├── gfm_scaler.pkl │ └── gfm_features.json ├── notebooks/ # Research (not in any container) │ ├── 03_gfm_gfl_classifier.ipynb │ └── 06_nrel_validation.ipynb ├── paper/ # IEEE submission (LaTeX) │ └── paper_gfm_gfl_classifier.tex ├── tests/ │ └── test_simulators.py ├── .env.example # Secret template — copy to .env ├── docker-compose.yml # All secrets via .env, no hardcoding └── .gitignore # Excludes .env, *.pkl, *.csv, fix_*.py ``` ## 研究 GFM/GFL 分类器记录在提交给 IEEE 的论文中: 关键结果: - F1-macro = 0.988 (仿真,5 种子均值,基于场景的划分) - 跨场景保留率:97.8% (训练 B+C → 测试 A+D) - 继电器优化延迟:14.2 ms (200 棵树,满足 IEC 61850 GOOSE 标准) - 外部验证:NREL #253 (燃料电池逆变器,110 次实验) ## CI/CD ``` push → ruff lint → pytest → docker build (generator + dashboard) ``` Airflow DAGs 通过 `docker compose --profile local up` 在本地运行。 MLflow 实验在 `http://localhost:5000` 进行追踪。 ## 许可证 MIT — 详见 [LICENSE](LICENSE) *基于 Python 3.11、Streamlit、scikit-learn、XGBoost、SHAP、Apache Kafka、Apache Airflow、MLflow、PostgreSQL、MinIO、Grafana 构建。*
标签:Airflow, Apex, Docker容器, GFL, GFM, Grafana, Isolation Forest, Kafka, Kubernetes, LSTM, MLflow, PUE预测, Python, SCADA, SHAP, SonarQube插件, Streamlit, 人工智能, 哈希传递, 异常检测, 微电网, 攻击面发现, 数据中心, 数据工程, 数据生成器, 无后门, 时间序列, 智能电网, 机器学习, 测试用例, 深度学习, 用户模式Hook绕过, 电力系统, 端到端平台, 能源管理, 访问控制, 请求拦截, 软件成分分析, 逆变器分析, 逆向工具, 遥测, 预测性维护