title: How to get the coefficients of the best logistic regression in a spark-ml CrossValidatorModel?
body: <p>I train a simple CrossValidatorModel using logistic regression and spark-ml pipelines. I can predict new data, but I'd like to go beyond the black box and do some analysis of the coefficients</p>
  
  <pre><code> val lr = new LogisticRegression().
    setFitIntercept(true).
    setMaxIter(maxIter).
    setElasticNetParam(alpha).
    setStandardization(true).
    setFamily("binomial").
    setWeightCol("weight").
    setFeaturesCol("features").
    setLabelCol("response")
  
  val assembler = new VectorAssembler().
    setInputCols(Array("feat1", "feat2")).
    setOutputCol("features")
  
  val modelPipeline = new Pipeline().
    setStages(Array(assembler,lr))
  
  val evaluator = new BinaryClassificationEvaluator()
    .setLabelCol("response")
  </code></pre>
  
  <p>Then I define a grid of parameters and I train over the grid to get the best model wrt AUC</p>
  
  <pre><code>val paramGrid = new ParamGridBuilder().
    addGrid(lr.regParam, lambdas).
    build()
  
  val pipeline = new CrossValidator().
    setEstimator(modelPipeline).
    setEvaluator(evaluator).
    setEstimatorParamMaps(paramGrid).
    setNumFolds(nfolds)
  
  val cvModel = pipeline.fit(train)
  </code></pre>
  
  <p>How do I get coefficients (the betas) of the best logistic regression model?</p>