You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Imran Younus (JIRA)" <ji...@apache.org> on 2016/01/09 03:16:39 UTC

[jira] [Comment Edited] (SPARK-12732) Fix LinearRegression.train for the case when label is constant and fitIntercept=false

    [ https://issues.apache.org/jira/browse/SPARK-12732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15090346#comment-15090346 ] 

Imran Younus edited comment on SPARK-12732 at 1/9/16 2:16 AM:
--------------------------------------------------------------

I would propose to do something like this for simplicity:

if (yStd == 0.0) {
    if ($(fitIntercept)) {
...
...
} else {
    yStd = 1.0
}

Since the model is trained in scaled space, setting `yStd = 1` will simply not scale `y` at all, and will produce the results as expected. Otherwise, we'll have to fix division by zero at several places in the code.


was (Author: iyounus):
[~holdenk] [~sethah] [~dbtsai] I would propose to do something like this for simplicity:

```
if (yStd == 0.0) {
      if ($(fitIntercept)) {
...
...
} else {
      yStd = 1.0
}
```
Since the model is trained in scaled space, setting `yStd = 1` will simply not scale `y` at all, and will produce the results as expected. Otherwise, we'll have to fix division by zero at several places in the code.

> Fix LinearRegression.train for the case when label is constant and fitIntercept=false
> -------------------------------------------------------------------------------------
>
>                 Key: SPARK-12732
>                 URL: https://issues.apache.org/jira/browse/SPARK-12732
>             Project: Spark
>          Issue Type: Bug
>            Reporter: Imran Younus
>            Priority: Minor
>
> If the target variable is constant, then the linear regression must check if the fitIntercept is true or false, and handle these two cases separately.
> If the fitIntercept is true, then there is no training needed and we set the intercept equal to the mean of y.
> But if the fit intercept is false, then the model should still train.
> Currently, LinearRegression handles both cases in the same way. It doesn't train the model and sets the intercept equal to the mean of y. Which, means that it returns a non-zero intercept even when the user forces the regression through the origin.



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

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