在Pyspark中保存随机森林分类器模型时出错

问题描述 投票:0回答:1
rf = RandomForestClassifier().setFeaturesCol("features").setLabelCol("label")
pipeline = Pipeline(stages=[tokenizer, hashingTF, idf, rf])
model = pipeline.fit(training) 
model.save(sc, '<path_to_save>')

我试图通过使用上面的代码保存模型文件。但是出现意外错误 -

TypeError: save() takes exactly 2 arguments (3 given)

我不明白这个错误。我只传递了2个参数,但仍然收到此错误。有人有想法吗?我在这做错了什么?

pyspark random-forest apache-spark-ml
1个回答
0
投票

我不知道这是怎么回事。但删除第一个字段'sc'对我有用。

model.save('<path_to_save>')

我可以通过此命令保存模型文件。

© www.soinside.com 2019 - 2024. All rights reserved.