0
数値とカテゴリの機能をApache SparkのRandomForestRegressorに渡す方法:JavaのMLlib?Apache SparkのRandomForestRegressorに数値とカテゴリの機能を渡す方法:JavaのMLlib?
数字でもカテゴリでもできますが、一緒に実装する方法はわかりません。そこに誰のための
(予測に使用される唯一の数値機能)を次のように私の作業コードがあるString[] featureNumericalCols = new String[]{
"squareM",
"timeTimeToPragueCityCenter",
};
String[] featureStringCols = new String[]{ //not used
"type",
"floor",
"disposition",
};
VectorAssembler assembler = new VectorAssembler().setInputCols(featureNumericalCols).setOutputCol("features");
Dataset<Row> numericalData = assembler.transform(data);
numericalData.show();
RandomForestRegressor rf = new RandomForestRegressor().setLabelCol("price")
.setFeaturesCol("features");
// Chain indexer and forest in a Pipeline
Pipeline pipeline = new Pipeline()
.setStages(new PipelineStage[]{assembler, rf});
// Train model. This also runs the indexer.
PipelineModel model = pipeline.fit(trainingData);
// Make predictions.
Dataset<Row> predictions = model.transform(testData);
あなたは[VectorIndexer](httpsを見てきました://spark.apache.org/docs/latest/api/java/index.html#org.apache.spark.ml.feature.VectorIndexer)?ここには[documentation](https://spark.apache.org/docs/latest/ml-classification-regression.html#random-forest-regression)の例があります – Jeremy
アドバイスありがとうございました、私は見ました(setInputCol)ではなく、複数の列(setInputCol)を渡すことができます。 – Tom