Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-12468

getParamMap in Pyspark ML API returns empty dictionary in example for Documentation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 1.5.2
    • None
    • PySpark
    • None

    Description

      The `extractParamMap()` method for a model that has been fit returns an empty dictionary, e.g. (from the [Pyspark ML API Documentation](http://spark.apache.org/docs/latest/ml-guide.html#example-estimator-transformer-and-param)):

      ```python
      from pyspark.mllib.linalg import Vectors
      from pyspark.ml.classification import LogisticRegression
      from pyspark.ml.param import Param, Params

      1. Prepare training data from a list of (label, features) tuples.
        training = sqlContext.createDataFrame([
        (1.0, Vectors.dense([0.0, 1.1, 0.1])),
        (0.0, Vectors.dense([2.0, 1.0, -1.0])),
        (0.0, Vectors.dense([2.0, 1.3, 1.0])),
        (1.0, Vectors.dense([0.0, 1.2, -0.5]))], ["label", "features"])
      1. Create a LogisticRegression instance. This instance is an Estimator.
        lr = LogisticRegression(maxIter=10, regParam=0.01)
      2. Print out the parameters, documentation, and any default values.
        print "LogisticRegression parameters:\n" + lr.explainParams() + "\n"
      1. Learn a LogisticRegression model. This uses the parameters stored in lr.
        model1 = lr.fit(training)
      1. Since model1 is a Model (i.e., a transformer produced by an Estimator),
      2. we can view the parameters it used during fit().
      3. This prints the parameter (name: value) pairs, where names are unique IDs for this
      4. LogisticRegression instance.
        print "Model 1 was fit using parameters: "
        print model1.extractParamMap()
        ```

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zakbrown Zachary Brown
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: