[ 
https://issues.apache.org/jira/browse/SPARK-18291?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yanbo Liang updated SPARK-18291:
--------------------------------
    Target Version/s: 2.2.0  (was: 2.1.0)

> SparkR glm predict should output original label when family = "binomial"
> ------------------------------------------------------------------------
>
>                 Key: SPARK-18291
>                 URL: https://issues.apache.org/jira/browse/SPARK-18291
>             Project: Spark
>          Issue Type: Bug
>          Components: ML, SparkR
>            Reporter: Yanbo Liang
>            Assignee: Yanbo Liang
>         Attachments: SparkR2.1decisionoutputschemaforGLMs.pdf
>
>
> SparkR spark.glm predict should output original label when family = 
> "binomial".
> For example, we can run the following code in sparkr shell:
> {code}
> training <- suppressWarnings(createDataFrame(iris))
> training <- training[training$Species %in% c("versicolor", "virginica"), ]
> model <- spark.glm(training, Species ~ Sepal_Length + Sepal_Width,family = 
> binomial(link = "logit"))
> showDF(predict(model, training))
> {code}
> The prediction column is double value which makes no sense to users.
> {code}
> +------------+-----------+------------+-----------+----------+-----+-------------------+
> |Sepal_Length|Sepal_Width|Petal_Length|Petal_Width|   Species|label|         
> prediction|
> +------------+-----------+------------+-----------+----------+-----+-------------------+
> |         7.0|        3.2|         4.7|        1.4|versicolor|  0.0| 
> 0.8271421517601544|
> |         6.4|        3.2|         4.5|        1.5|versicolor|  0.0| 
> 0.6044595910413112|
> |         6.9|        3.1|         4.9|        1.5|versicolor|  0.0| 
> 0.7916340858281998|
> |         5.5|        2.3|         4.0|        1.3|versicolor|  
> 0.0|0.16080518180591158|
> |         6.5|        2.8|         4.6|        1.5|versicolor|  0.0| 
> 0.6112229217050189|
> |         5.7|        2.8|         4.5|        1.3|versicolor|  0.0| 
> 0.2555087295500885|
> |         6.3|        3.3|         4.7|        1.6|versicolor|  0.0| 
> 0.5681507664364834|
> |         4.9|        2.4|         3.3|        1.0|versicolor|  
> 0.0|0.05990570219972002|
> |         6.6|        2.9|         4.6|        1.3|versicolor|  0.0| 
> 0.6644434078306246|
> |         5.2|        2.7|         3.9|        1.4|versicolor|  
> 0.0|0.11293577405862379|
> |         5.0|        2.0|         3.5|        1.0|versicolor|  
> 0.0|0.06152372321585971|
> |         5.9|        3.0|         4.2|        1.5|versicolor|  
> 0.0|0.35250697207602555|
> |         6.0|        2.2|         4.0|        1.0|versicolor|  
> 0.0|0.32267018290814303|
> |         6.1|        2.9|         4.7|        1.4|versicolor|  0.0|  
> 0.433391153814592|
> |         5.6|        2.9|         3.6|        1.3|versicolor|  0.0| 
> 0.2280744262436993|
> |         6.7|        3.1|         4.4|        1.4|versicolor|  0.0| 
> 0.7219848389339459|
> |         5.6|        3.0|         4.5|        1.5|versicolor|  
> 0.0|0.23527698971404695|
> |         5.8|        2.7|         4.1|        1.0|versicolor|  0.0|  
> 0.285024533520016|
> |         6.2|        2.2|         4.5|        1.5|versicolor|  0.0| 
> 0.4107047877447493|
> |         5.6|        2.5|         3.9|        1.1|versicolor|  
> 0.0|0.20083561961645083|
> +------------+-----------+------------+-----------+----------+-----+-------------------+
> {code}
> The prediction value should be the original label like:
> {code}
> +------------+-----------+------------+-----------+----------+-----+----------+
> |Sepal_Length|Sepal_Width|Petal_Length|Petal_Width|   
> Species|label|prediction|
> +------------+-----------+------------+-----------+----------+-----+----------+
> |         7.0|        3.2|         4.7|        1.4|versicolor|  0.0| 
> virginica|
> |         6.4|        3.2|         4.5|        1.5|versicolor|  0.0| 
> virginica|
> |         6.9|        3.1|         4.9|        1.5|versicolor|  0.0| 
> virginica|
> |         5.5|        2.3|         4.0|        1.3|versicolor|  
> 0.0|versicolor|
> |         6.5|        2.8|         4.6|        1.5|versicolor|  0.0| 
> virginica|
> |         5.7|        2.8|         4.5|        1.3|versicolor|  
> 0.0|versicolor|
> |         6.3|        3.3|         4.7|        1.6|versicolor|  0.0| 
> virginica|
> |         4.9|        2.4|         3.3|        1.0|versicolor|  
> 0.0|versicolor|
> |         6.6|        2.9|         4.6|        1.3|versicolor|  0.0| 
> virginica|
> |         5.2|        2.7|         3.9|        1.4|versicolor|  
> 0.0|versicolor|
> |         5.0|        2.0|         3.5|        1.0|versicolor|  
> 0.0|versicolor|
> |         5.9|        3.0|         4.2|        1.5|versicolor|  
> 0.0|versicolor|
> |         6.0|        2.2|         4.0|        1.0|versicolor|  
> 0.0|versicolor|
> |         6.1|        2.9|         4.7|        1.4|versicolor|  
> 0.0|versicolor|
> |         5.6|        2.9|         3.6|        1.3|versicolor|  
> 0.0|versicolor|
> |         6.7|        3.1|         4.4|        1.4|versicolor|  0.0| 
> virginica|
> |         5.6|        3.0|         4.5|        1.5|versicolor|  
> 0.0|versicolor|
> |         5.8|        2.7|         4.1|        1.0|versicolor|  
> 0.0|versicolor|
> |         6.2|        2.2|         4.5|        1.5|versicolor|  
> 0.0|versicolor|
> |         5.6|        2.5|         3.9|        1.1|versicolor|  
> 0.0|versicolor|
> +------------+-----------+------------+-----------+----------+-----+----------+
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to