-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_mock_data.py
More file actions
58 lines (46 loc) · 1.8 KB
/
generate_mock_data.py
File metadata and controls
58 lines (46 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pandas as pd
import numpy as np
import datetime
def generate_mock_data(filename='Voltacore_EV_Battery_Demo_Data.xlsx', num_weeks=104):
"""
Generates a realistic mock dataset for the Voltacore case study.
"""
dates = pd.date_range(end=datetime.datetime.today(), periods=num_weeks, freq='W-MON')
data = []
base_sales = 5000
for date in dates:
# Seasonality
month = date.month
seasonality = 1.0 + 0.2 * np.sin(2 * np.pi * month / 12)
# Trend
trend = 1.0 + (0.05 * (np.random.rand() - 0.5)) # Small random trend
# Events
is_holiday = 1 if month == 12 or month == 1 else 0
is_promo = 1 if np.random.rand() > 0.8 else 0
# Sales Calculation
sales = base_sales * seasonality * trend
if is_holiday: sales *= 1.3
if is_promo: sales *= 1.5
# Noise
sales += np.random.normal(0, 200)
# Inventory (Simulate overstock/understock)
inventory = sales * (1.0 + (np.random.rand() - 0.5) * 0.4)
# Fuel Price
fuel_price = 100 + (np.random.rand() * 50)
row = {
'Date': date,
'Weekly_Sales_Units': int(sales),
'Unit_Price_USD': 150 + np.random.uniform(-5, 5),
'Unit_Cost_USD': 100 + np.random.uniform(-2, 2),
'Current_Inventory_Units': int(inventory),
'Transport_Distance_km': 1000 + np.random.normal(0, 200),
'Fuel_Price_Index': fuel_price,
'Holiday_Flag': is_holiday,
'Promotion_Flag': is_promo
}
data.append(row)
df = pd.DataFrame(data)
df.to_excel(filename, index=False)
print(f"Generated {filename}")
if __name__ == "__main__":
generate_mock_data()