我是预测新手,我正在尝试使用 r 中的预测包。
有人可以解释一下预测函数中平均值和拟合值之间的区别吗?
例如,
fcast<-forecast(ts,h=30)
fcast$mean
fcast$fitted
Run Code Online (Sandbox Code Playgroud)
该文档说“平均值是作为时间序列的点预测”,“拟合是拟合值(一步预测)”。
举个例子来说明差异就很好了。非常感谢任何帮助。
我正在尝试运行下面的代码,但收到以下错误。该代码使用预测包中的 auto.arima 来确定 arima 模型并将其拟合到某些数据。它还在 xreg 参数中使用回归量。我认为 xreg 中两列的名称可能是问题所在,但我不确定为什么。列的名称类似于“struct.c.NA..NA..211L..”,它们是函数的输出。如果我在 xreg 参数中没有这些列的情况下运行 auto.arima ,它似乎做得很好。非常感谢任何有关如何解决此问题的提示。
代码:
auto.arima(df2_comb[1:100,names(df2_comb)=='ECDD'], xreg = df2_comb[,names(df2_comb)!='ECDD'][1:100,names(df2_comb[,!names(df2_comb)%in%c('ECDD','order_dts')])])
Run Code Online (Sandbox Code Playgroud)
错误:
Error in auto.arima(df2_comb[1:100, names(df2_comb) == "ECDD"], xreg = df2_comb[, :
xreg should be a numeric matrix or vector
Run Code Online (Sandbox Code Playgroud)
数据:
dput(df2_comb[1:100,])
structure(list(ECDD = c(319.4, 319.4, 319.4, 319.4, 319.4, 319.4,
319.4, 319.4, 319.4, 319.4, 319.4, 319.4, 319.4, 319.4, 319.4,
319.4, 319.4, 319.4, 319.4, 198, 142, 254, 178, 97, 113, 116,
109, 127, 102, 99, 107, 109, 89, 101, 106, 319.4, 319.4, 319.4,
319.4, …Run Code Online (Sandbox Code Playgroud) 我有一个类似于下面的示例数据的列表。列表中的每个条目都遵循“source/number_something/”模式。我想创建一个新列表,如下面的输出,其中条目只是“某物”。我想我可以使用 for 循环和字符串拆分,_但后面的一些文本也包括_. 这似乎可以用正则表达式完成,但我不太擅长正则表达式。非常感谢任何提示。
示例数据:
['source/108_cash_total/',
'source/108_customer/',
'source/108_daily_units_total/',
'source/108_discounts/',
'source/108_employee/',
'source/56_cash_total/',
'source/56_customer/',
'source/56_daily_units_total/',
'source/56_discounts/',
'source/56_employee/']
Run Code Online (Sandbox Code Playgroud)
输出:
['cash_total',
'customer',
'daily_units_total',
'discounts',
'employee',
'cash_total',
'customer/',
'daily_units_total',
'discounts',
'employee']
Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的数据框。我想在数据框中查找包含字符串 'abc' 的所有列,并返回这些字段的列表,如下例所示。如果我正在寻找行,我会使用 isin,但我不确定如何获取列。非常感谢任何提示。
例子:
Print df
Field1 Field2 Field3
f_abc 23 dog
Df3 bb ju
Return
Field1
Run Code Online (Sandbox Code Playgroud) 我使用自制软件在我的Mac上安装了spark。我正在尝试查找安装目录。我已经尝试使用Google搜索,但是运气不佳。似乎应该不会那么棘手。谁能告诉我在Mac终端中或从spark shell运行需要什么才能找到spark的安装目录?
更新:
码:
brew info apache-spark
Run Code Online (Sandbox Code Playgroud)
输出:
apache-spark: stable 2.3.2, HEAD
Engine for large-scale data processing
https://spark.apache.org/
/usr/local/Cellar/apache-spark/2.3.2 (1,058 files, 244.6MB) *
Built from source on 2018-10-30 at 14:16:30
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/apache-spark.rb
==> Requirements
Required: java = 1.8 ?
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 4,534 (30 days), 14,340 (90 days), 56,698 (365 days)
install_on_request: 4,263 (30 days), 13,490 (90 days), 51,876 (365 days)
build_error: 0 (30 days)
Run Code Online (Sandbox Code Playgroud)
码:
which spark-shell
Run Code Online (Sandbox Code Playgroud)
输出:
/Users/sshields/anaconda2/bin/spark-shell
Run Code Online (Sandbox Code Playgroud) r ×2
apache-spark ×1
forecast ×1
forecasting ×1
homebrew ×1
macos ×1
pandas ×1
python ×1
python-2.7 ×1
regex ×1
time-series ×1