Ale37 commited on
Commit
ee4dd77
·
1 Parent(s): 0364cf7

Started writing model implementation

Browse files
Files changed (1) hide show
  1. src/model.py +53 -0
src/model.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from darts import TimeSeries
2
+ from darts.datasets import ILINetDataset
3
+ from darts.metrics import mape
4
+ from darts.model import ExponentialSmoothing
5
+ from darts.utils.missing_values import fill_missing_values
6
+ import numpy as np
7
+ import pandas as pd
8
+
9
+ def load_ILINetDataset():
10
+ """
11
+ Dataset's Components Descriptions:
12
+
13
+ * % WEIGHTED ILI: Combined state-specific data of patients visit to healthcare providers for ILI reported each week weighted by state population
14
+
15
+ * % UNWEIGHTED ILI: Combined state-specific data of patients visit to healthcare providers for ILI reported each week unweighted by state population
16
+
17
+ * AGE 0-4: Number of patients between 0 and 4 years of age
18
+
19
+ * AGE 25-49: Number of patients between 25 and 49 years of age
20
+
21
+ * AGE 25-64: Number of patients between 25 and 64 years of age
22
+
23
+ * AGE 5-24: Number of patients between 5 and 24 years of age
24
+
25
+ * AGE 50-64: Number of patients between 50 and 64 years of age
26
+
27
+ * AGE 65: Number of patients above (>=65) 65 years of age
28
+
29
+ * ILITOTAL: Total number of ILI patients. For this system, ILI is defined as fever (temperature of 100°F [37.8°C] or greater) and a cough and/or a sore throat
30
+
31
+ * NUM. OF PROVIDERS: Number of outpatient healthcare providers
32
+
33
+ * TOTAL PATIENTS: Total number of patients
34
+ """
35
+ ilidata = ILINetDataset().load().astype(np.float32)
36
+
37
+ return ilidata
38
+
39
+
40
+ def preprocess_data(ilidata):
41
+ ilitotal = ilidata['ILITOTAL']
42
+ covariates = ilidata.drop_columns(col_names='ILITOTAL')
43
+
44
+ # Apply logaritmic transformation
45
+ log_ili = ilitotal.map(np.log)
46
+
47
+ # Remove -inf values
48
+ pd_log_ili = log_ili.pd_dataframe()
49
+ pd_log_ili['ILITOTAL'].replace(to_replace=-np.inf, value=np.nan, inplace=True)
50
+ log_ili = TimeSeries.from_dataframe(pd_log_ili)
51
+
52
+ log_ili = fill_missing_values(log_ili)
53
+