Energy consumption task using prophet, lapply and map function

example of sql connection

Displaying records 1 - 10
id Date Time Global_active_power Global_reactive_power Global_intensity Voltage Sub_metering_1 Sub_metering_2 Sub_metering_3
1 2007-01-01 00:00:00 2.580 0.136 10.6 241.97 0 0 0
2 2007-01-01 00:01:00 2.552 0.100 10.4 241.75 0 0 0
3 2007-01-01 00:02:00 2.550 0.100 10.4 241.64 0 0 0
4 2007-01-01 00:03:00 2.550 0.100 10.4 241.71 0 0 0
5 2007-01-01 00:04:00 2.554 0.100 10.4 241.98 0 0 0
6 2007-01-01 00:05:00 2.550 0.100 10.4 241.83 0 0 0
7 2007-01-01 00:06:00 2.534 0.096 10.4 241.07 0 0 0
8 2007-01-01 00:07:00 2.484 0.000 10.2 241.29 0 0 0
9 2007-01-01 00:08:00 2.468 0.000 10.2 241.23 0 0 0
10 2007-01-01 00:09:00 2.486 0.000 10.2 242.18 0 0 0

Data by year, month, week, day

## # A tibble: 5 x 9
##   Year       Global_reactive~ Global_active_p~ kitchen_kwh laundry_kwh
##   <date>                <dbl>            <dbl>       <dbl>       <dbl>
## 1 2006-01-01            2890.             697.        27.5        48.8
## 2 2007-01-01           61231.            9712.       643.        854. 
## 3 2008-01-01           61707.            9415.       585.        662. 
## 4 2009-01-01           68509.            9372.       593.        592. 
## 5 2010-01-01           59201.            8089.       452.        504. 
## # ... with 4 more variables: waterheat_aircond_kwh <dbl>, Other_kwh <dbl>,
## #   Voltage <dbl>, Global_intensity <dbl>
## # A tibble: 5 x 9
##   Year       Global_reactive~ Global_active_p~ kitchen_kwh laundry_kwh
##   <date>                <dbl>            <dbl>       <dbl>       <dbl>
## 1 2006-01-01            2890.             697.        27.5        48.8
## 2 2007-01-01           61231.            9712.       643.        854. 
## 3 2008-01-01           61707.            9415.       585.        662. 
## 4 2009-01-01           68509.            9372.       593.        592. 
## 5 2010-01-01           59201.            8089.       452.        504. 
## # ... with 4 more variables: waterheat_aircond_kwh <dbl>, Other_kwh <dbl>,
## #   Voltage <dbl>, Global_intensity <dbl>

Forecast

Prophet

## n.changepoints greater than number of observations. Using 3
## $Year
## 
## $MonthYear
## 
## $WeekYear
## 
## $Date
## Making 2 forecasts with cutoffs between 2009-05-30 and 2009-11-26
## Warning: Unknown or uninitialised column: 'y'.

## Warning: Unknown or uninitialised column: 'y'.
## Skipping MAPE because y close to 0

gabriel

22/7/2019