如何解决我收到的结果是Int类型,如何获取Apache Spark Mllib ALS推荐系统的String类型的userId?
Dataset <Row> ds = spark.read()
.option("header",false)
.option("inferSchema",true)
.csv("results.csv")
.toDF("artistname","userid","rate");
ds.show();
StringIndexer stringindexer = new StringIndexer()
.setInputCol("artistname")
.setOutputCol("artistnameindex");
StringIndexer stringindexer1 = new StringIndexer()
.setInputCol("userid")
.setOutputCol("useridindex");
StringIndexerModel model = stringindexer.fit(ds);
StringIndexerModel model1 = stringindexer1.fit(ds);
ds = model.transform(ds);
ds.show();
ds = model1.transform(ds);
ds.show();
//toDF("userId","courseId","proportionWatched");
ALS als = new ALS()
.setMaxIter(10)
.setRegParam(0.1)
.setItemCol("artistnameindex")
.setUserCol("useridindex")
.setRatingCol("rate");
ALSModel alsmodel = als.fit(ds);
Dataset <Row> result = alsmodel.recommendForAllUsers(5);
建议的Apache Spark Mllib库不接受字符串类型,因此出于这些原因我使用StringIndexer,但是结果为int类型,因此我希望将结果归为字符串类型,因为我的数据框userIds为String类型,我如何获取我的结果字符串类型
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。