bajiang commited on
Commit
e4b734c
Β·
0 Parent(s):

Initial commit: upload model and source code

Browse files
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ random_forest_model.pkl filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸ”‹ Electricity Price Predictor (Random Forest Regression)
2
+
3
+ This is a custom regression model trained to predict electricity prices ($/kWh) in California, based on a variety of grid-level and environmental features such as EV charging demand, solar/wind production, carbon emissions, and storage indicators.
4
+
5
+ The model is trained using `RandomForestRegressor` from `scikit-learn`, with 24 engineered features and a structured tabular dataset. This project is intended to support intelligent energy systems, such as EV charging optimization, energy scheduling, or smart grid simulation.
6
+
7
+ ---
8
+
9
+ ## πŸ“Œ Model Details
10
+
11
+ - πŸ“ˆ **Model**: RandomForestRegressor (n_estimators=200)
12
+ - 🧠 **Framework**: scikit-learn
13
+ - 🧾 **Input Features**: 24 numerical values (see full list below)
14
+ - 🎯 **Target Variable**: Electricity Price ($/kWh)
15
+ - πŸ—ƒοΈ **Data**: Structured time-series dataset with hourly EV/grid info
16
+ - πŸ§ͺ **Evaluation**:
17
+ - MSE: *e.g., 0.0023*
18
+ - RΒ²: *e.g., 0.89*
19
+ - MAPE: *e.g., 6.5%*
20
+
21
+ ---
22
+
23
+ ## πŸ”’ Input Features
24
+
25
+ The model expects a list of 24 numeric features:
26
+
27
+ ```text
28
+ ['Year', 'Month', 'Day', 'DayOfWeek', 'Hour',
29
+ 'EV Charging Demand (kW)', 'Solar Energy Production (kW)', 'Wind Energy Production (kW)',
30
+ 'Battery Storage (kWh)', 'Charging Station Capacity (kW)', 'EV Charging Efficiency (%)',
31
+ 'Number of EVs Charging', 'Peak Demand (kW)', 'Renewable Energy Usage (%)',
32
+ 'Grid Stability Index', 'Carbon Emissions (kgCO2/kWh)', 'Power Outages (hours)',
33
+ 'Energy Savings ($)', 'Total_Renewable_Energy_Production', 'Effective_Charging_Capacity',
34
+ 'Adjusted_Charging_Demand', 'Net_Energy_Cost', 'Carbon_Footprint_Reduction',
35
+ 'Renewable_Energy_Efficiency']
36
+
37
+ ```
38
+ ---
39
+ ---
40
+
41
+ ## πŸ§ͺ Usage Example
42
+
43
+ ### πŸ”Ή Option 1: Load and use the model directly
44
+
45
+ ```python
46
+ import joblib
47
+ import numpy as np
48
+
49
+ # Load trained model
50
+ model = joblib.load("random_forest_model.pkl")
51
+
52
+ # Sample input (replace with actual values)
53
+ features = [0.5] * 24
54
+
55
+ # Make prediction
56
+ price = model.predict(np.array(features).reshape(1, -1))[0]
57
+ print(f"Predicted Electricity Price: ${price:.4f}")
58
+ ```
59
+
60
+ ---
61
+
62
+ ### πŸ”Ή Option 2: Use helper function in `predict.py`
63
+
64
+ ```python
65
+ from predict import predict
66
+
67
+ features = [0.5] * 24
68
+ result = predict(features)
69
+ print(f"Predicted Price: ${result:.4f}")
70
+ ```
71
+
72
+ ---
73
+
74
+ ### πŸ”Ή Option 3: Try it online (Gradio Web Demo)
75
+
76
+ If deployed, you can try it here:
77
+ [πŸ‘‰ Live Demo on Spaces](https://huggingface.co/spaces/YOUR_USERNAME/electricity-price-predictor-demo)
78
+
79
+ ---
80
+
81
+ ## πŸ“Š Sample Dataset
82
+
83
+ This repository includes a sample dataset: `processed_electric_price_filled.csv`.
84
+ It contains hourly records of EV charging demand, solar/wind energy production, grid stability, and electricity prices.
85
+
86
+ ### Load and explore:
87
+
88
+ ```python
89
+ import pandas as pd
90
+
91
+ df = pd.read_csv("processed_electric_price_filled.csv")
92
+ print(df.head())
93
+ ```
94
+
95
+ ---
96
+
97
+ ## πŸ“ Files Included
98
+
99
+ | File | Description |
100
+ |-------------------------------------|--------------------------------------------------|
101
+ | `random_forest_model.pkl` | Trained RandomForestRegressor model |
102
+ | `predict.py` | Python function to load and run predictions |
103
+ | `app.py` (optional) | Gradio-based interactive demo |
104
+ | `requirements.txt` | Python dependencies |
105
+ | `processed_electric_price_filled.csv` | Training/test dataset |
106
+ | `README.md` | This documentation |
107
+
108
+ ---
109
+
110
+ ## πŸ‘¨β€πŸ’» Author
111
+
112
+ **bajiang(Georgia)**
113
+
114
+ ---
115
+
116
+ ## πŸ“„ License
117
+
118
+ MIT License – You are free to use, modify, and distribute this project with proper attribution.
119
+
120
+
121
+
122
+
predict.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+ import numpy as np
3
+
4
+ # Load the trained model
5
+ model = joblib.load("random_forest_model.pkl")
6
+
7
+ def predict(features):
8
+ """features: list of 24 numeric values"""
9
+ features = np.array(features).reshape(1, -1)
10
+ return model.predict(features)[0]
processed_electric_price_filled.csv ADDED
The diff for this file is too large to render. See raw diff
 
random_forest_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:524d90e3d96d2364837146c907394160de08660b2cfedeadc5778db9e5b831e2
3
+ size 435340417
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ scikit-learn
2
+ numpy
3
+ pandas
4
+ joblib
5
+ matplotlib
6
+ gradio