使用此代码时出现此错误:
def createLabeledPoints(fields):
q1 = fields[1]
q2 = fields[12]
q3 = fields[23]
result = fields[40]
return LabeledPoint(result, array([q1, q2, q3])
spark = SparkSession \
.builder \
.appName("myApp") \
.config("spark.mongodb.input.uri", "mongodb://127.0.0.1/newumc.classification_data") \
.config("spark.mongodb.output.uri", "mongodb://127.0.0.1/newumc.classification_data") \
.getOrCreate()
df = spark.read.format("com.mongodb.spark.sql.DefaultSource").load()
dt = df.rdd.map(createLabeledPoints)
model111 = DecisionTree.trainClassifier(dt, numClasses=467,
categoricalFeaturesInfo={0:2,1:2, 2:2}, impurity='gini', maxDepth=30, maxBins=32)
但是当我想保存我的模型" model111"并将其与烧瓶一起使用
import cPickle as pickle
pickle.dump(model111, open("rfc1.pkl","wb"))
这给出了一个错误:
TypeError: can't pickle lock objects
我是python中的新手...有没有办法解锁m模型所以我可以使用泡菜或有人可以向我建议任何解决方案