Extract results from CrossValidator with paramGrid in pySpark

大城市里の小女人 提交于 2019-12-01 09:31:05

You'll have to combine different bits of data:

  • Estimator ParamMaps extracted using getEstimatorParamMaps method.
  • Training metrics which can be retrieved using avgMetrics parameter.

First get names and values of all parameters declared in the map:

params = [{p.name: v for p, v in m.items()} for m in cvModel.getEstimatorParamMaps()]

Thane zip with metrics and convert to a data frame

import pandas as pd

pd.DataFrame.from_dict([
    {cvModel.getEvaluator().getMetricName(): metric, **ps} 
    for ps, metric in zip(params, cvModel.avgMetrics)
])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!