title: How to map the coefficient obtained from logistic regression model to the feature names in pyspark
body: <p>I  built a  logistic regression model using a pipeline flow to the one listed by databricks. 
  <a href="https://docs.databricks.com/spark/latest/mllib/binary-classification-mllib-pipelines.html" rel="nofollow noreferrer">https://docs.databricks.com/spark/latest/mllib/binary-classification-mllib-pipelines.html</a></p>
  
  <p>the features (numeric and string features) were encoded using <code>OneHotEncoderEstimator</code> and then transformed using standard scaler. </p>
  
  <p>I would like to know how to map the weights(coefficients) obtained from logistic regression to the feature names in the original dataframe.</p>
  
  <p>In other words, how to get the corresponding features to the weights or the coefficients obtained from the model</p>
  
  <p>Thank you</p>
  
  <p>I have tried to extract the features from the lrModel.schema, which gave a list of <code>structField</code> showing the features </p>
  
  <p>I tried to extract the features from the schema and map to the weights but not successful</p>
  
  <pre><code>from pyspark.ml.classification import LogisticRegression
  
  # Create initial LogisticRegression model
  lr = LogisticRegression(labelCol="label", featuresCol="scaledFeatures", maxIter=10)
  
  # Train model with Training Data
  
  lrModel = lr.fit(trainingData)
  
  predictions = lrModel.transform(trainingData)
  
  LRschema = predictions.schema
  </code></pre>
  
  <p>the expected outcome from the extraction a list of tuples(feature weight, feature name)</p>