是什么导致了这个错误。我有点迷路了。我所发现的一切都帮不了我。
堆栈跟踪:
Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: Column features must be of type struct<type:tinyint,size:int,indices:array<int>,values:array<double>> but was actually struct<type:tinyint,size:int,indices:array<int>,values:array<double>>.
at scala.Predef$.require(Predef.scala:224)
at org.apache.spark.ml.util.SchemaUtils$.checkColumnType(SchemaUtils.scala:43)
at org.apache.spark.ml.PredictorParams$class.validateAndTransformSchema(Predictor.scala:51)
at org.apache.spark.ml.classification.Classifier.org$apache$spark$ml$classification$ClassifierParams$$super$validateAndTransformSchema(Classifier.scala:58)
at org.apache.spark.ml.classification.ClassifierParams$class.validateAndTransformSchema(Classifier.scala:42)
at org.apache.spark.ml.classification.ProbabilisticClassifier.org$apache$spark$ml$classification$ProbabilisticClassifierParams$$super$validateAndTransformSchema(ProbabilisticClassifier.scala:53)
at org.apache.spark.ml.classification.ProbabilisticClassifierParams$class.validateAndTransformSchema(ProbabilisticClassifier.scala:37)
at org.apache.spark.ml.classification.ProbabilisticClassifier.validateAndTransformSchema(ProbabilisticClassifier.scala:53)
at org.apache.spark.ml.Predictor.transformSchema(Predictor.scala:144)
at org.apache.spark.ml.PipelineStage.transformSchema(Pipeline.scala:74)
at org.apache.spark.ml.Predictor.fit(Predictor.scala:100)
at classifier.Clasafie.trainModel_MPC(Clasafie.java:46)
at classifier.Clasafie.MPC_Classifier(Clasafie.java:75)
at classifier.Clasafie.main(Clasafie.java:30)
代码部分:
public static MultilayerPerceptronClassificationModel trainModel_MPC(SparkSession session,JavaRDD<LabeledPoint> data)
{
int[] layers = {784,800};
MultilayerPerceptronClassifier model = new MultilayerPerceptronClassifier().setLayers(layers)
.setSeed((long) 42).setBlockSize(128).setMaxIter(1000);
Dataset<Row> dataset = session.createDataFrame(data.rdd(), LabeledPoint.class);
return model.fit(dataset);
}
1条答案
按热度按时间kxe2p93d1#
我认为问题在于使用
LabelPoint
从正确的包初始化。检查完整的包并使用on from ml包,而不是从mllib。
我想,你用的是-
请使用(spark v2.0.0中介绍)-