Homepage
tidyverts / fabletools Goto Github PK
View Code? Open in Web Editor NEWGeneral fable features useful for extension packages
Home Page: http://fabletools.tidyverts.org/
General fable features useful for extension packages
Home Page: http://fabletools.tidyverts.org/
Changes to tsibble mean fablelite can no longer be installed.
> remotes::install_github("tidyverts/fablelite")
Downloading GitHub repo tidyverts/fablelite@master
✔ checking for file ‘/tmp/RtmpmOyHbR/remotes7aa24fd10a7/tidyverts-fablelite-e24a578/DESCRIPTION’ ...
─ preparing ‘fablelite’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘fablelite_0.0.0.9100.tar.gz’
Installing package into ‘/home/hyndman/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package ‘fablelite’ ...
** R
** inst
** byte-compile and prepare package for lazy loading
Error : object ‘tbl_sum’ is not exported by 'namespace:tsibble'
ERROR: lazy loading failed for package ‘fablelite’
* removing ‘/home/hyndman/R/x86_64-pc-linux-gnu-library/3.5/fablelite’
* restoring previous ‘/home/hyndman/R/x86_64-pc-linux-gnu-library/3.5/fablelite’
Error in utils::install.packages(pkgs = pkgs, lib = lib, repos = myrepos, :
(converted from warning) installation of package ‘/tmp/RtmpmOyHbR/file7aa4c62d3f5/fablelite_0.0.0.9100.tar.gz’ had non-zero exit status
Getting an error with geom_forecast():
library(ggplot2)
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
library(tsibbledata)
library(fable)
#> Loading required package: fablelite
tsibbledata::aus_livestock %>%
autoplot() +
guides(color = FALSE) +
geom_forecast()
#> Plot variable not specified, automatically selected `var = Count`
#> Warning: Computation failed in `stat_forecast()`:
#> All inputs to rbind.fill must be data.frames
Sorry for the messy plot. It was the first internal dataset I could find that replicated the error I was seeing on internal company data. It's clearer with less paths, but the forecast geom isn't being added to the underlying plot.
Should make it easier to unnest()
From this page: https://tidyverts.github.io/tidy-forecasting-principles/methods.html I run the example:
olympic_running %>%
model(lm = TSLM(Time ~ trend())) %>%
interpolate(olympic_running)
I get this error:
Error: A mable must contain at least one model. To remove all models, first convert to a tibble with as_tibble()
.
The backtrace says:> rlang::last_trace()
x
_fseq
(_lhs
)), env, env))_fseq
(_lhs
)), env, env)\-base::eval(quote(`_fseq`(`_lhs`)), env, env)
\-global::`_fseq`(`_lhs`)
\-magrittr::freduce(value, `_function_list`)
+-base::withVisible(function_list[[k]](value))
\-function_list[[k]](value)
+-generics::interpolate(., olympic_running)
\-fablelite:::interpolate.mdl_df(., olympic_running)
\-`%>%`(...)
+-base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
\-base::eval(quote(`_fseq`(`_lhs`)), env, env)
\-base::eval(quote(`_fseq`(`_lhs`)), env, env)
\-fablelite:::`_fseq`(`_lhs`)
\-magrittr::freduce(value, `_function_list`)
\-function_list[[i]](value)
+-dplyr::transmute(...)
\-dplyr:::transmute.default(...)
+-dplyr::select(out, one_of(keep))
\-fablelite:::select.mdl_df(out, one_of(keep))
Here's my sessionInfo:
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
...
other attached packages:
[1] dplyr_0.8.0 ggplot2_3.1.0 tsibbledata_0.0.0.9000 tsibble_0.6.2.9000 fable_0.0.0.9100 fablelite_0.0.0.9100
Similar to previous install problem with namespace which I see was fixed. However ...
Trying to install fablelite on Mac:
platform x86_64-apple-darwin15.6.0
version.string R version 3.5.2 (2018-12-20)
with error message "object 'n_keys' not found whilst loading namespace 'fablelite'":
devtools::install_github("tidyverts/fablelite")
Downloading GitHub repo tidyverts/fablelite@master
✔ checking for file ‘/private/var/folders/ks/x4lpc3qx7jj2h0vxd3ppqrsw0000gn/T/Rtmp7NlNge/remotes6f14bc40af6/tidyverts-fablelite-87cdee8/DESCRIPTION’ ...
─ preparing ‘fablelite’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘fablelite_0.0.0.9100.tar.gz’
Transformations should be handled automatically, requiring the model function to provide point forecasts and distributions.
library(tsibble)
library(lubridate)
library(tsibbledata)
library(fable)
google_2015 <- gafa_stock %>%
filter(Symbol == "GOOG") %>%
mutate(day = row_number()) %>%
update_tsibble(index = day, regular = TRUE) %>%
filter(year(Date) == 2015)
google_2015_tr <- google_2015 %>%
head(-8) %>%
stretch_tsibble(.init = 3, .step = 1)
fc <- google_2015_tr %>%
model(RW(Close ~ drift())) %>%
forecast(h=8) %>%
group_by(.id) %>%
mutate(h = row_number()) %>%
ungroup()
fc %>%
accuracy(google_2015, by = "h")
#> Error in abs(.train): non-numeric argument to mathematical function
Created on 2019-04-01 by the reprex package (v0.2.1)
Currently the combination forecast variance assumes that the correlation across h is identical... can we do better than this?
Elaborating on the example from README:
library(fable)
library(tsibble)
library(tsibbledata)
library(lubridate)
# Adding a new measurable
aus_retail <- aus_retail %>% mutate(Const=1)
aus_retail %>%
filter(
State %in% c("New South Wales", "Victoria"),
Industry == "Department stores"
) %>%
model(
lm = TSLM(Turnover~trend()),
) %>%
forecast %>%
autoplot(filter(aus_retail, year(Month) > 2010), level = NULL)
works well, however mentioning a column name (Const
) in place of trend()
:
library(tsibble)
library(tsibbledata)
library(lubridate)
aus_retail %>%
filter(
State %in% c("New South Wales", "Victoria"),
Industry == "Department stores"
) %>%
model(
lm = TSLM(Turnover~0+Const),
) %>%
forecast %>%
autoplot(filter(aus_retail, year(Month) > 2010), level = NULL)
results in
Error in eval(predvars, data, env): object 'Const' not found
(same with Q1, ..., Q4
in #125)
After load fablelite package from Github, library(fablelite) command gets error message "fablelite.rdb is corrupt".
Because fable has a dependency on fablelite, fable cannot be used until this error is fixed.
version:
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 5.1
year 2018
month 07
day 02
svn rev 74947
language R
version.string R version 3.5.1 (2018-07-02)
nickname Feather Spray
RStudio Version 1.1.383
> devtools::install_github("tidyverts/fablelite", force = TRUE)
Downloading GitHub repo tidyverts/fablelite@master
from URL https://api.github.com/repos/tidyverts/fablelite/zipball/master
Installing fablelite
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
'/private/var/folders/n1/11dpffjn3r11dq0v3m1xd_zc0000gq/T/RtmpfXceZA/devtools14da36f494d26/tidyverts-fablelite-700b12c' \
--library='/Library/Frameworks/R.framework/Versions/3.5/Resources/library' --install-tests
* installing *source* package 'fablelite' ...
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded
* DONE (fablelite)
> library(fablelite)
Error: package or namespace load failed for ‘fablelite’ in get(method, envir = home):
lazy-load database '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/fablelite/R/fablelite.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4], :
restarting interrupted promise evaluation
2: In get(method, envir = home) :
restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
devtools::install_github("tidyverts/fablelite")
...
Error: package or namespace load failed for ‘fablelite’:
object 'is_vector_s3' not found whilst loading namespace 'fablelite'
Error: loading failed
Execution halted
ERROR: loading failed
I tried it on R 3.4.3 and R 3.5.1
fablelite should handle augment if it is missing for a particular model, requiring developers to specify fitted
and residuals
methods only.
fablelite
methods for fitted
and residuals
should also perform back-transformations where appropriate (interfering when type = "response" for residuals
to calculate it with back-transformations).
When doing a one period ahead forecast with geom_forecast, geom_forecast() throws an error. For any other time horizon, or just using the default, it works fine.
library(tidyverse)
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following object is masked from 'package:dplyr':
#>
#> id
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
library(fable)
#> Loading required package: fablelite
library(tsibbledata)
aus_livestock%>%
nest(-Animal, -State) %>%
slice(10) %>%
unnest() %>%
ggplot(aes(Month, Count)) +
geom_path() +
geom_forecast(fc.args = list(h = 20))
aus_livestock%>%
nest(-Animal, -State) %>%
slice(10) %>%
unnest() %>%
ggplot(aes(Month, Count)) +
geom_path() +
geom_forecast(fc.args = list(h = 1))
#> Error in check.length(gparname): 'gpar' element 'fontsize' must not be length 0
Created on 2019-03-11 by the reprex package (v0.2.1)
generics is on CRAN now.
Convenient for filtering and grouping
related: r-lib/roxygen2#388
library(tidyverse)
library(tsibble)
library(fable)
fit1 <- WWWusage %>% as_tsibble() %>%
model(
naive = NAIVE(value)
)
fit2 <- WWWusage %>% as_tsibble() %>%
model(
mean = MEAN(value)
)
fit <- bind_cols(fit1,fit2)
glance(fit)
library(tsibble)
library(fable)
library(lubridate)
library(ggplot2)
elec_mth <- tsibbledata::elecdemand %>%
filter_index(~ "2014-01-30") %>%
index_by(datehour = floor_date(index, "hour")) %>%
summarise(avg_supply = mean(Demand)) %>%
mutate(
hour = hour(datehour),
date = as_date(datehour)
)
elec_fc <- elec_mth %>%
model(ets = ETS(avg_supply)) %>%
forecast(h = 24)
#> Selecting index: "datehour"
elec_fc$date <- as_date(elec_fc$datehour)
# elec_fc %>%
# autoplot(data = elec_mth) +
# sugrrants::facet_calendar(~ date)
elec_mth %>%
ggplot(aes(x = hour, y = avg_supply)) +
geom_line() +
geom_forecast(
aes(ymin = lower, ymax = upper, level = level),
fortify(elec_fc), stat = "identity"
) +
sugrrants::facet_calendar(~ date)
#> Error: All columns in a tibble must be 1d or 2d objects:
#> * Column `x` is function
Created on 2018-12-31 by the reprex package (v0.2.1)
Ideally,
geom_forecast(
mapping = aes(x = x, y = y, distribution = ..distribution..), data = fbl_ts,
levels = c(80, 95), stats = "identity", other_args
)
x
& y
inherit from ggplot()
levels
better to be constants instead of aesthetic mapping.stats = "identity"
better to be the default instead of "forecast"A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.