Pyspark ML: how to get subModels values with CrossValidator()

我是研究僧i 提交于 2020-01-03 03:17:05

问题


I would like to get the cross-validation's (internal) training accuracy, using PySpark end ML library:

lr = LogisticRegression()
param_grid = (ParamGridBuilder()
                     .addGrid(lr.regParam, [0.01, 0.5])
                     .addGrid(lr.maxIter, [5, 10])
                     .addGrid(lr.elasticNetParam, [0.01, 0.1])
                     .build())
evaluator = MulticlassClassificationEvaluator(predictionCol='prediction')
cv = CrossValidator(estimator=lr, 
                    estimatorParamMaps=param_grid, 
                    evaluator=evaluator, 
                    numFolds=5)
model_cv = cv.fit(train)
predictions_lr = model_cv.transform(validation)
predictions = evaluator.evaluate(predictions_lr)

In order to take the accuracy metric for each c.v. folder, I have tried:

print(model_cv.subModels)

but the result of this method is empty (None).

How could I get the accuracy of each folder?

来源:https://stackoverflow.com/questions/57014775/pyspark-ml-how-to-get-submodels-values-with-crossvalidator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!