0

IllegalArgumentException:MultilayerPerceptronClassifier_...参数求解器给出无效值自动

我相信我在 spark 3.0.0、scala 2.1.2 中加载 MultilayerPerceptronClassificationModel 时发现了一个错误,我已经测试过并且可以看到至少在 Spark 2.4.3、Scala 2.11 中不存在。.

我在 databricks 集群上使用 pyspark 并“从 pyspark.ml.classification import MultilayerPerceptronClassificationModel”导入库</p>

当运行 model=MultilayerPerceptronClassificationModel.("load") 然后模型。transform (df) 我收到以下错误:IllegalArgumentException: MultilayerPerceptronClassifier_8055d1368e78 parameter solver given invalid value auto。

通过运行 spark 文档中给出的示例可以轻松复制此问题:http: //spark.apache.org/docs/latest/ml-classification-regression.html#multilayer-perceptron-classifier

然后添加一个保存模型、加载模型和转换语句,如下所示:

from pyspark.ml.classification import MultilayerPerceptronClassifier
from pyspark.ml.evaluation import MulticlassClassificationEvaluator

# Load training data
data = spark.read.format("libsvm")\
    .load("data/mllib/sample_multiclass_classification_data.txt")

# Split the data into train and test
splits = data.randomSplit([0.6, 0.4], 1234)
train = splits[0]
test = splits[1]

# specify layers for the neural network:
# input layer of size 4 (features), two intermediate of size 5 and 4
# and output of size 3 (classes)
layers = [4, 5, 4, 3]

# create the trainer and set its parameters
trainer = MultilayerPerceptronClassifier(maxIter=100, layers=layers, blockSize=128, seed=1234)

# train the model
model = trainer.fit(train)

# compute accuracy on the test set
result = model.transform(test)
predictionAndLabels = result.select("prediction", "label")
evaluator = MulticlassClassificationEvaluator(metricName="accuracy")
print("Test set accuracy = " + str(evaluator.evaluate(predictionAndLabels)))

from pyspark.ml.classification import MultilayerPerceptronClassifier, MultilayerPerceptronClassificationModel
model.save(Save_location)
model2. MultilayerPerceptronClassificationModel.load(Save_location)

result_from_loaded = model2.transform(test)
4

1 回答 1

0

Bug 已确认 Jira 打开::https ://issues.apache.org/jira/browse/SPARK-32232

于 2020-07-09T07:27:05.290 回答