Sahil Garg commited on
Commit
52f3cd7
·
1 Parent(s): 1457ba8

README.md updated

Browse files
Files changed (2) hide show
  1. README.md +108 -10
  2. ml/__init__.py +0 -0
README.md CHANGED
@@ -12,20 +12,57 @@ pinned: false
12
 
13
  AI-powered predictive maintenance for solar PV inverters using ML models and LLM-based diagnosis.
14
 
15
- ## API Endpoints
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ### POST /analyze
18
- Accepts voltage and current sensor data, returns ML predictions and agent diagnosis.
 
19
 
20
  **Request:**
21
  ```json
22
  {
23
  "vdc1": [600.0, 601.0, 602.0],
24
  "idc1": [10.0, 10.1, 10.2],
25
- "api_key": "your_google_api_key_here" // Optional: enables AI diagnosis
 
26
  }
27
  ```
28
 
 
 
 
 
 
29
  **Response:**
30
  ```json
31
  {
@@ -37,15 +74,76 @@ Accepts voltage and current sensor data, returns ML predictions and agent diagno
37
  "confidence": 0.85
38
  },
39
  "agent_output": {
40
- "diagnosis": "...",
41
  "urgency": "Low",
42
- "recommended_action": "...",
43
- "justification": ["..."]
44
  }
45
  }
46
  ```
47
 
48
- ## ML Pipeline
49
- - **Anomaly Detection**: Isolation Forest + LSTM Autoencoder
50
- - **Failure Forecasting**: XGBoost (Time-to-Failure + Failure Probability)
51
- - **Agent Reasoning**: Gemini 2.5 Flash Lite via LangChain
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  AI-powered predictive maintenance for solar PV inverters using ML models and LLM-based diagnosis.
14
 
15
+ ## Features
16
+
17
+ - **Anomaly Detection**: Isolation Forest + LSTM Autoencoder
18
+ - **Failure Forecasting**: XGBoost models for time-to-failure and failure probability
19
+ - **AI Diagnosis**: Gemini LLM provides maintenance recommendations
20
+ - **REST API**: FastAPI-based service with automatic documentation
21
+
22
+ ## Quick Start
23
+
24
+ ### Installation
25
+
26
+ ```bash
27
+ git clone <repository-url>
28
+ cd pdm-agent
29
+ pip install -r requirements.txt
30
+ ```
31
+
32
+ ### Environment Setup
33
+
34
+ Set your Google API key for LLM features:
35
+ ```bash
36
+ export GOOGLE_API_KEY=your_api_key_here
37
+ ```
38
+
39
+ ### Run
40
+
41
+ ```bash
42
+ uvicorn app:app --host 0.0.0.0 --port 7860 --reload
43
+ ```
44
+
45
+ ## API Usage
46
 
47
  ### POST /analyze
48
+
49
+ Analyzes sensor data and returns ML predictions with optional AI diagnosis.
50
 
51
  **Request:**
52
  ```json
53
  {
54
  "vdc1": [600.0, 601.0, 602.0],
55
  "idc1": [10.0, 10.1, 10.2],
56
+ "api_key": "your_google_api_key_here",
57
+ "asset_id": "PV_INVERTER_001"
58
  }
59
  ```
60
 
61
+ **Parameters:**
62
+ - `vdc1`, `idc1`: Voltage and current sensor readings
63
+ - `api_key`: Optional Google API key for AI diagnosis
64
+ - `asset_id`: Optional asset identifier (auto-generated if not provided)
65
+
66
  **Response:**
67
  ```json
68
  {
 
74
  "confidence": 0.85
75
  },
76
  "agent_output": {
77
+ "diagnosis": "Minor voltage fluctuations detected...",
78
  "urgency": "Low",
79
+ "recommended_action": "Continue monitoring...",
80
+ "justification": ["Voltage within range", "Current stable"]
81
  }
82
  }
83
  ```
84
 
85
+ ### Data Processing Pipeline
86
+
87
+ 1. **Input Validation**: Ensures voltage/current arrays match and contain sufficient data points
88
+ 2. **Data Preparation**: Pads input to 100 data points for consistent processing
89
+ 3. **Feature Engineering**: Creates 7 statistical features using rolling window analysis:
90
+ - Voltage mean/standard deviation
91
+ - Power mean/standard deviation
92
+ - Power delta and slope
93
+ - Normalized efficiency
94
+ 4. **ML Inference**: Processes features through anomaly detection and prediction models
95
+ 5. **Agent Analysis**: LLM analyzes ML results for human-readable diagnosis (if API key provided)
96
+
97
+ ## Configuration
98
+
99
+ - `GOOGLE_API_KEY`: Required for AI diagnosis features
100
+ - Models: Gemini 2.5 Flash Lite, XGBoost, LSTM Autoencoder
101
+ - Port: 7860 (configurable)
102
+
103
+ ## Docker
104
+
105
+ ```bash
106
+ docker build -t pdm-agent .
107
+ docker run -p 7860:7860 -e GOOGLE_API_KEY=your_key pdm-agent
108
+ ```
109
+
110
+ ## Testing
111
+
112
+ ```bash
113
+ # Test the API
114
+ curl -X POST "http://localhost:7860/analyze" \
115
+ -H "Content-Type: application/json" \
116
+ -d '{
117
+ "vdc1": [600.0, 601.0, 602.0],
118
+ "idc1": [10.0, 10.1, 10.2],
119
+ "api_key": "your_api_key",
120
+ "asset_id": "PV_INVERTER_001"
121
+ }'
122
+ ```
123
+
124
+ ## 📊 ML Models
125
+
126
+ ### Anomaly Detection
127
+ - **Isolation Forest**: Unsupervised outlier detection
128
+ - **LSTM Autoencoder**: Sequence-based anomaly scoring
129
+
130
+ ### Predictive Models
131
+ - **XGBoost Classifier**: Failure probability prediction
132
+ - **XGBoost Regressor**: Time-to-failure estimation
133
+
134
+ ### LLM Agent
135
+ - **Gemini 2.5 Flash Lite**: Diagnostic reasoning and recommendations
136
+
137
+ ## 🤝 Contributing
138
+
139
+ 1. Fork the repository
140
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
141
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
142
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
143
+ 5. Open a Pull Request
144
+
145
+
146
+ ## License
147
+
148
+ MIT License
149
+
ml/__init__.py DELETED
File without changes