有没有办法从fable::NNETAR
模型中获得变量重要性的视图?像nnet
下面这个虚构的例子吗?
library(tidyverse)
library(fable)
#> Loading required package: fabletools
library(NeuralNetTools)
library(nnet)
ts <- tibble(index = 1:1000) %>%
mutate(
y = seq(0.5, 1000 / 2, by = 0.5) + arima.sim(model = list(
ar = c(0.2, 0.3),
ma = 0.2,
order = c(2, 1, 1)
), 999) %>% as.double(),
x1 = seq(0.5, 1000 / 2, by = 0.5),
x2 = 1:1000,
x3 = 1
) %>%
as_tsibble(index = index)
# Possible to extract variable importance from fable::NNETAR ...
mod <- ts %>%
model(NNet = NNETAR(y ~ x1 + x2 + x3))
#> Warning: Constant xreg column, setting `scale_inputs=FALSE`
# ... as per the nnet / garson example?
nnet(y ~ x1 + x2 + x3, data = ts, size = 1) %>%
garson() +
ggtitle("NN Variable Importance")
#> # weights: 6
#> initial value 53799287.386267
#> final value 53627119.744357
#> converged
由reprex 包(v0.3.0)于 2019 年 9 月 18 日创建