MCPcopy Create free account
hub / github.com/Hrishikesh332/HCDS-EPD / gen_sample_data

Function gen_sample_data

utils.py:38–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 return gen_sample_data(), "sample"
37
38def gen_sample_data():
39 regions = [
40 'LONDON', 'NORTH WEST', 'MIDLANDS', 'SOUTH EAST',
41 'EAST OF ENGLAND', 'SOUTH WEST', 'NORTH EAST AND YORKSHIRE',
42 'SOUTH OF ENGLAND', 'NORTH OF ENGLAND',
43 'MIDLANDS AND EAST OF ENGLAND', 'UNIDENTIFIED'
44 ]
45
46 bnf_codes = [
47 "01: Gastro-Intestinal System", "02: Cardiovascular System",
48 "03: Respiratory System", "04: Central Nervous System",
49 "05: Infections", "06: Endocrine System",
50 "07: Obstetrics and Gynaecology", "08: Malignant Disease",
51 "09: Nutrition and Blood", "10: Musculoskeletal Diseases",
52 "11: Eye", "12: Ear, Nose and Throat", "13: Skin",
53 "14: Immunological Products", "15: Anaesthesia",
54 "18: Preparations used in Diagnosis", "19: Other Drugs",
55 "20: Dressings", "21: Appliances"
56 ]
57
58 date_range = pd.date_range('2020-01-01', '2025-08-01', freq='MS')
59 data = []
60
61 np.random.seed(42)
62
63 for region in regions:
64 for bnf_code in bnf_codes:
65 base_cost = 15000
66
67 for i, date in enumerate(date_range):
68 trend = base_cost * 0.002 * i
69 seasonal = base_cost * 0.15 * np.sin(2 * np.pi * i / 12)
70 noise = np.random.normal(0, base_cost * 0.08)
71
72 covid_impact = 0
73 if date.year in [2020, 2021]:
74 covid_impact = base_cost * 0.2 * np.random.uniform(-1, 1)
75
76 cost = base_cost + trend + seasonal + noise + covid_impact
77 cost = max(0, cost)
78
79 data.append({
80 'YEAR_MONTH': date,
81 'REGIONAL_OFFICE_NAME': region,
82 'BNF_CHAPTER_PLUS_CODE': bnf_code,
83 'TOTAL_COST': cost
84 })
85
86 return pd.DataFrame(data)
87
88def train_arima(ts_data, forecast_periods=5):
89 if len(ts_data) < 3:

Callers 1

load_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected