Sparklyr ALS未返回预期答案

时间:2018-04-21 16:33:11

标签: r apache-spark-mllib sparklyr

我将在以下方面进行协作过滤建议:this link

我通过此代码连接到spark:

sc <- spark_connect(master="local" , method = c("shell"),
                    config=list(spark.driver.memory = "2g"), 
                    app_name = "sparklyr",version="2.0.0",
                    extensions = sparklyr::registered_extensions(),
                    spark_home = 
                      normalizePath(path.expand(path = "C:/spark"), 
                                    winslash = "\\", mustWork = NA)


 )



jDF2 <- sdf_copy_to(sc,jDF, "spark_jester", overwrite=T)

implicit_model <- ml_als_factorization(jDF2,  
                                       rating.column = "rating", 
                                       user.column = "user", 
                                       item.column = "item",
                                       iter.max = 5, 
                                       regularization.parameter = 0.01, 
                                       implicit.preferences = TRUE, 
                                       alpha = 1.0)

implicit_predictions <- implicit_model$.model %>%
  invoke("transform", spark_dataframe(jDF2)) %>%
  collect()

我的数据是:

> jDF
       user item rating
1      3385    1   7.91
3315   3385   13   9.17
6963   3385   24   5.34
10301  3385   35   8.16
13443  3385   46  -8.74
18441  3385   57   7.14
22514  3385   68   8.88
27513  3385   79  -8.25
32513  3385   90   5.87
35686  3385    2   6.21
39743  3385    4   7.72
44096  3385    5   6.12
48574  3385    6  -0.73

运行代码后出现以下错误:

  

UseMethod中的错误(&#34;调用&#34;):没有适用的方法来调用&#39;   应用于类&#34; NULL&#34;

的对象

当我检查模型时,我得到了这个:

> summary(implicit_model)
                        Length Class      Mode       
uid                     1      -none-     character  
param_map               3      -none-     list       
rank                    1      -none-     numeric    
recommend_for_all_items 1      -none-     function   
recommend_for_all_users 1      -none-     function   
item_factors            2      tbl_spark  list       
user_factors            2      tbl_spark  list       
user_col                1      -none-     character  
item_col                1      -none-     character  
prediction_col          1      -none-     character  
.jobj                   2      spark_jobj environment

这里有什么错误吗?

0 个答案:

没有答案