0
我试图测试这个代码,我星火文档中找到,为了应对阿帕奇星火类别特征,使用Java:1的-K编码Apache的星火在Java
SparkSession spark = SparkSession
.builder().master("local[4]")
.appName("1-of-K encoding Test")
.getOrCreate();
List<Row> data = Arrays.asList(
RowFactory.create(0, "a"),
RowFactory.create(1, "b"),
RowFactory.create(2, "c"),
RowFactory.create(3, "a"),
RowFactory.create(4, "a"),
RowFactory.create(5, "c")
);
StructType schema = new StructType(new StructField[]{
new StructField("id", DataTypes.IntegerType, false,Metadata.empty()),
new StructField("category", DataTypes.StringType, false, Metadata.empty())
});
Dataset<Row> df = spark.createDataFrame(data, schema);
StringIndexerModel indexer = new StringIndexer()
.setInputCol("category")
.setOutputCol("categoryIndex")
.fit(df);
但我得到这个错误;拟合函数不能被称为
你有什么想法?
谢谢你现在工作对我来说,(我发现在Apache的MLIB文档中的例子) –