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

Unintended exception thrown in pyspark.ml.LogisticRegression.getThreshold

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 2.4.0, 3.1.0, 3.2.0, 3.3.0
    • 3.3.0
    • ML, PySpark
    • None

    Description

      If LogisticRegression.getThreshold is called with model having multiple thresholds we suppose to raise an exception,

      ValueError: Logistic Regression getThreshold only applies to binary classification ...
      

      However, thresholds (List[float]) are incorrectly passed to str.join, resulting in unintended TypeError

      >>> from pyspark.ml.classification import LogisticRegression
      ... 
      ... model = LogisticRegression(thresholds=[1.0, 2.0, 3.0])
      >>> model.getThreshold()
      Traceback (most recent call last):
        Input In [7] in <module>
          model.getThreshold()
        File /path/to/spark/python/pyspark/ml/classification.py:1003 in getThreshold
          + ",".join(ts)
      Type Error: sequence item 0: expected str instance, float found
      
      

      Attachments

        Activity

          People

            zero323 Maciej Szymkiewicz
            zero323 Maciej Szymkiewicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: