🤖 AI Methodology Documentation
Complete transparency on how EcoPower AI analyzes your energy data and generates recommendations.
Overview: Hybrid AI Architecture
EcoPower AI utilizes a Hybrid AI Engine that combines the power of Generative AI (Google Gemini 2.5 Flash) with robust statistical forecasting.
This approach ensures you get the deep reasoning and pattern recognition capabilities of a Large Language Model (LLM), backed by a failsafe statistical model to ensure service reliability even without internet connectivity.
Fallback Model: Statistical Moving Average & Linear Regression
1. Pattern Detection
Purpose
Identify recurring consumption patterns in your historical energy data.
How It Works
- Analyzes the last 30 days of hourly energy consumption data
- Groups data by hour of day (0-23) and day of week (Monday-Sunday)
- Calculates average consumption for each hour across all days
- Identifies peak usage times and low-demand periods
Example
If you consistently use 3.0 kWh between 12 PM - 2 PM (peak solar hours), the AI detects this pattern and uses it for future predictions.
Code Implementation
// Build hourly pattern averages
foreach ($historical_data as $record) {
$hour = $record['hour_of_day'];
$consumption = floatval($record['consumption_kwh']);
if (!isset($hourly_patterns[$hour])) {
$hourly_patterns[$hour] = [];
}
$hourly_patterns[$hour][] = $consumption;
}
// Calculate average consumption per hour
foreach ($hourly_patterns as $hour => $consumptions) {
$hourly_averages[$hour] = array_sum($consumptions) / count($consumptions);
}
2. Trend Analysis
Purpose
Detect whether your overall energy consumption is increasing, decreasing, or stable.
How It Works
- Calculates total daily consumption for the last 7 days
- Applies linear regression to detect trend slope
- Classifies trend as: Increasing (slope > 0.5), Decreasing (slope < -0.5), or Stable
- Adjusts future predictions based on trend direction
Formula
Linear regression slope: slope = Σ[(x - x̄)(y - ȳ)] / Σ[(x - x̄)²]
Impact on Predictions
If consumption is trending upward, predictions are adjusted slightly higher. If trending downward, predictions are adjusted lower. This ensures predictions adapt to changing usage patterns.
3. Moving Average Forecasting
Purpose
Smooth out short-term fluctuations and predict future consumption.
How It Works
- Takes the last 7 days (168 hours) of consumption data
- Calculates weighted moving average
- Uses this average as baseline for predictions
- Combines with hourly patterns for more accurate forecasts
Formula
Moving Average = Σ(consumption values) / number of values
Why Moving Averages?
Moving averages reduce noise in data and provide a stable baseline for predictions. They're particularly effective for energy consumption, which has regular daily patterns.
4. Anomaly Detection
Purpose
Identify unusual energy consumption spikes that deviate from normal patterns.
How It Works
- Calculates mean (average) consumption across all historical data
- Calculates standard deviation (σ) to measure variability
- Sets anomaly threshold at:
mean + 2σ - Flags any consumption above this threshold as an anomaly
Statistical Basis
In a normal distribution, 95% of values fall within 2 standard deviations of the mean. Values beyond this range are statistically unusual and warrant investigation.
Use Cases
- Detect equipment malfunctions (e.g., faulty appliances consuming excess power)
- Identify unusual usage patterns (e.g., forgot to turn off high-power devices)
- Alert users to potential energy waste
5. Optimization Engine
Purpose
Recommend the optimal energy source (solar, grid, or generator) for each time period to minimize fuel consumption and costs.
Decision Logic
Rule 1: Prioritize Solar (8 AM - 5 PM)
- Peak solar hours (11 AM - 2 PM): Always recommend solar
- Non-peak solar hours: Recommend solar for low-moderate consumption
- High consumption during non-peak: Recommend grid for reliability
Rule 2: Minimize Generator Usage
- Low consumption (< 1 kWh): Always use grid, never generator
- Moderate consumption (1-2.5 kWh): Prefer grid over generator
- High consumption (> 2.5 kWh): Use grid if stable, generator only as backup
Fuel Savings Calculation
Fuel Saved = (Predicted kWh) × 0.3 L/kWh
Based on average diesel generator consumption rate of 0.3 liters per kWh
Cost Savings Calculation
Cost Savings = (Generator Cost - Recommended Source Cost) × Predicted kWh
Where: Generator = ₦0.35/kWh, Grid = ₦0.15/kWh, Solar = ₦0.05/kWh
6. Environmental Impact Calculation
CO₂ Emission Calculation
CO₂ Reduced (kg) = Fuel Saved (liters) × 2.68 kg CO₂/liter
Based on EPA standard emission factor for diesel fuel
Baseline Comparison
All savings are calculated against a baseline scenario where 100% of energy comes from a generator. This represents the worst-case environmental impact.
Real-World Equivalents
- Trees Planted: CO₂ Reduced ÷ 21 kg (average CO₂ absorbed by one tree per year)
- Car Kilometers: CO₂ Reduced ÷ 0.12 kg/km (average car emissions)
7. Confidence Scoring
How Confidence is Calculated
Each prediction includes a confidence score (0-100%) based on:
- Data Availability: More historical data points = higher confidence
- Pattern Stability: Consistent patterns = higher confidence
- Trend Volatility: Stable trends = higher confidence
Formula
Base Confidence = min(95, 60 + (data_points × 2))
Final Confidence = Base Confidence - (trend_volatility_penalty)
Interpretation
- 80-95%: High confidence - strong historical patterns
- 70-79%: Good confidence - adequate data available
- 50-69%: Moderate confidence - limited data or volatile patterns
8. Data Requirements & Limitations
Minimum Data Requirements
- For Predictions: At least 24 hours of historical data
- For Accurate Patterns: 7+ days of data recommended
- For Trend Analysis: 7+ days required
Limitations
- Predictions assume future patterns will resemble historical patterns
- Cannot predict sudden changes in usage (e.g., new appliances, seasonal changes)
- Solar recommendations assume functional solar panels with adequate capacity
- Grid recommendations assume grid availability and stability
Best Practices
- Input data regularly (daily or hourly) for best results
- Include notes for unusual consumption periods
- Review and update predictions weekly
- Adjust recommendations based on actual grid/solar availability
Transparency Commitment
EcoPower AI is committed to full transparency in AI decision-making. Every prediction, recommendation, and calculation is based on documented statistical methods. No hidden algorithms, no proprietary black boxes.
All source code is available for review, and we provide detailed explanations for every AI output. If you have questions about how a specific recommendation was generated, please contact us.