Databricks中的r sparkdataframe运行先知

发布于 2025-01-25 18:12:19 字数 1543 浏览 5 评论 0原文

我在R中有一个Spark DataFrame。我通过执行以下操作从雪花上检索了数据集:

snowflake_tbl_name <- "xxxxxx"
                          
tickerDF <- SparkR::read.df(  
  source = "snowflake",
  sfUrl = "xxxxxx.snowflakecomputing.com",
  sfUser = "xxxxxxx",
  sfPassword = "xxxxxxxxxx",
  sfDatabase = "xxxxxxxxx",
  sfSchema = "PUBLIC",
  sfWarehouse = "COMPUTE_WH",
  dbtable = snowflake_tbl_name)

数据集看起来像这样:

'SparkDataFrame': 4 variables:
 $ ds      : Date 2022-01-05 2022-01-06 2022-01-07 2022-01-10 2022-01-11 2022-01-12
 $ TICKER  : chr "HDEF" "HDEF" "HDEF" "HDEF" "HDEF" "HDEF"
 $ y       : num 23.870001 23.9 24.200001 24.200001 24.450001 24.6
 $ RUN_DATE: Date 2022-02-26 2022-02-26 2022-02-26 2022-02-26 2022-02-26 2022-02-26

          ds TICKER     y   RUN_DATE
1 2022-01-05   HDEF 23.87 2022-02-26
2 2022-01-06   HDEF 23.90 2022-02-26
3 2022-01-07   HDEF 24.20 2022-02-26
4 2022-01-10   HDEF 24.20 2022-02-26
5 2022-01-11   HDEF 24.45 2022-02-26
6 2022-01-12   HDEF 24.60 2022-02-26

我现在想使用Prophet软件包来预测y的未来值。

当我尝试简单地运行以下内容时,我会发现一个错误说明:

library(prophet)
library(dplyr)
m <- prophet::prophet(spark_df)


Error in as.environment(where) : 
  S4 object does not extend class "environment"
Some(<code style = 'font-size:10p'> Error in as.environment(where): S4 object does not extend 
class &quot;environment&quot; </code>)
Error in as.environment(where): S4 object does not extend class "environment"

有什么想法为什么可能是这种情况?

I have a Spark Dataframe in R. I retrieved the dataset from snowflake by doing the following:

snowflake_tbl_name <- "xxxxxx"
                          
tickerDF <- SparkR::read.df(  
  source = "snowflake",
  sfUrl = "xxxxxx.snowflakecomputing.com",
  sfUser = "xxxxxxx",
  sfPassword = "xxxxxxxxxx",
  sfDatabase = "xxxxxxxxx",
  sfSchema = "PUBLIC",
  sfWarehouse = "COMPUTE_WH",
  dbtable = snowflake_tbl_name)

The dataset looks something like this:

'SparkDataFrame': 4 variables:
 $ ds      : Date 2022-01-05 2022-01-06 2022-01-07 2022-01-10 2022-01-11 2022-01-12
 $ TICKER  : chr "HDEF" "HDEF" "HDEF" "HDEF" "HDEF" "HDEF"
 $ y       : num 23.870001 23.9 24.200001 24.200001 24.450001 24.6
 $ RUN_DATE: Date 2022-02-26 2022-02-26 2022-02-26 2022-02-26 2022-02-26 2022-02-26

          ds TICKER     y   RUN_DATE
1 2022-01-05   HDEF 23.87 2022-02-26
2 2022-01-06   HDEF 23.90 2022-02-26
3 2022-01-07   HDEF 24.20 2022-02-26
4 2022-01-10   HDEF 24.20 2022-02-26
5 2022-01-11   HDEF 24.45 2022-02-26
6 2022-01-12   HDEF 24.60 2022-02-26

I now want to use the prophet package to predict future values for y.

When I try and simply run the following, I get an error stating:

library(prophet)
library(dplyr)
m <- prophet::prophet(spark_df)


Error in as.environment(where) : 
  S4 object does not extend class "environment"
Some(<code style = 'font-size:10p'> Error in as.environment(where): S4 object does not extend 
class "environment" </code>)
Error in as.environment(where): S4 object does not extend class "environment"

Any idea why this may be the case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的背包 2025-02-01 18:12:19

代码似乎没有任何错误。我不熟悉火花数据帧,但先知需要两个列DS和Y,因此您可以将它们放入常规的两列数据帧中,看看是否有帮助。

我遇到了试图运行带有RSTAN和RCPP的过时版本的先知模型的问题,您可能需要检查依赖项。

要实际预测,您需要将模型与make_future_dataframe

make_future_dataframe(m,ersige,freeq =“ day”,include_history = true)>

There doesn't seem to be anything wrong the the code. I'm not familiar with spark data frames but prophet requires two columns ds and y, so you could just put them into a regular two column dataframe and see if that helps.

I have had issues trying to run prophet models with outdated versions of rstan and Rcpp, you may want to check your dependencies.

To actually forecast you need to use the model with make_future_dataframe

make_future_dataframe(m, periods, freq = "day", include_history = TRUE)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文