Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我收到的结果是Int类型,如何为Apache Spark Mllib ALS reccomendation系统获取字符串类型的用户ID Dataset ds=spark.read() .选项(“标题”,false) .option(“推断模式”,true) .csv(“results.csv”) .toDF(“艺人名称”、“用户ID”、“费率”); ds.show(); StringIndexer StringIndexer=新的StringIndexer() .setInputCol(“艺人姓名”) .setOutputCol(“artistnameindex”); StringIndexer StringIndexer 1=新的StringIndexer() .setInputCol(“用户ID”) .setOutputCol(“用户索引”); StringIndexerModel=stringindexer.fit(ds); StringIndexerModel1=stringindexer1.fit(ds); ds=模型转换(ds); ds.show(); ds=model1.transform(ds); ds.show(); //toDF(“用户ID”、“courseId”、“比例关注”); ALS=新的ALS() .setMaxIter(10) .setRegParam(0.1) .setItemCol(“artistnameindex”) .setUserCol(“useridindex”) .setRatingCol(“费率”); ALSModel ALSModel=als.fit(ds); 数据集结果=alsmodel.recommendForAllUsers(5);_Java_Apache Spark_Apache Spark Mllib - Fatal编程技术网

Java 我收到的结果是Int类型,如何为Apache Spark Mllib ALS reccomendation系统获取字符串类型的用户ID Dataset ds=spark.read() .选项(“标题”,false) .option(“推断模式”,true) .csv(“results.csv”) .toDF(“艺人名称”、“用户ID”、“费率”); ds.show(); StringIndexer StringIndexer=新的StringIndexer() .setInputCol(“艺人姓名”) .setOutputCol(“artistnameindex”); StringIndexer StringIndexer 1=新的StringIndexer() .setInputCol(“用户ID”) .setOutputCol(“用户索引”); StringIndexerModel=stringindexer.fit(ds); StringIndexerModel1=stringindexer1.fit(ds); ds=模型转换(ds); ds.show(); ds=model1.transform(ds); ds.show(); //toDF(“用户ID”、“courseId”、“比例关注”); ALS=新的ALS() .setMaxIter(10) .setRegParam(0.1) .setItemCol(“artistnameindex”) .setUserCol(“useridindex”) .setRatingCol(“费率”); ALSModel ALSModel=als.fit(ds); 数据集结果=alsmodel.recommendForAllUsers(5);

Java 我收到的结果是Int类型,如何为Apache Spark Mllib ALS reccomendation系统获取字符串类型的用户ID Dataset ds=spark.read() .选项(“标题”,false) .option(“推断模式”,true) .csv(“results.csv”) .toDF(“艺人名称”、“用户ID”、“费率”); ds.show(); StringIndexer StringIndexer=新的StringIndexer() .setInputCol(“艺人姓名”) .setOutputCol(“artistnameindex”); StringIndexer StringIndexer 1=新的StringIndexer() .setInputCol(“用户ID”) .setOutputCol(“用户索引”); StringIndexerModel=stringindexer.fit(ds); StringIndexerModel1=stringindexer1.fit(ds); ds=模型转换(ds); ds.show(); ds=model1.transform(ds); ds.show(); //toDF(“用户ID”、“courseId”、“比例关注”); ALS=新的ALS() .setMaxIter(10) .setRegParam(0.1) .setItemCol(“artistnameindex”) .setUserCol(“useridindex”) .setRatingCol(“费率”); ALSModel ALSModel=als.fit(ds); 数据集结果=alsmodel.recommendForAllUsers(5);,java,apache-spark,apache-spark-mllib,Java,Apache Spark,Apache Spark Mllib,Apache Spark Mllib library for reccomendation不接受字符串类型,因此我使用了StringIndexer,但结果是int类型的,因此我希望结果是字符串类型的,因为我的dataframe用户ID是字符串类型的。我如何获取字符串类型的结果 Dataset <Row> ds = spark.read() .option("header", false) .option("inferSchema", t

Apache Spark Mllib library for reccomendation不接受字符串类型,因此我使用了StringIndexer,但结果是int类型的,因此我希望结果是字符串类型的,因为我的dataframe用户ID是字符串类型的。我如何获取字符串类型的结果

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);