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

Seth Hendrickson commented on SPARK-17163:
------------------------------------------

Just to sum up some key points:

1. LogisticRegression provides a {{intercept: Double}} and {{coefficients: 
Vector}} because it relies on a binary assumption. 
MultinomialLogisticRegression provides a {{intercepts: Vector}} and 
{{coefficients: Matrix}} since it can have multiple classes. This is a major 
pain point for unifying these two interfaces. In mllib, this was "hacked" into 
a single interface such that when multinomial regression was called, the 
intercept was 0 (meaningless) and the coefficients (including the intercept) 
were flattened into a single vector. 

2. LogisticRegression uses pivoting, while MultinomialLogisticRegression does 
not. This is important because, although MLOR can be used for binary 
classification, it provides a different result when regularization is used. 
MLOR provides two sets of coefficients in the binary case, where BLOR provides 
one shared set of coefficients. Therefore, we cannot say that MLOR supercedes 
all functionality in BLOR - they differ in one major case. 

Unfortunately, I think we just missed a big chance to get this right when 2.0 
breaking changes were released. 

One potential solution would be to unify these into a single 
estimator/transformer called LogisticRegression. When two classes are used 
(binary case) we would produce the results as normal. When more than that are 
detected, we call into the newly implemented Multinomial algorithm. In the 
model, we store the coefficients as a matrix and intercepts as a vector always, 
but we provide public methods {{def intercept: Double}} and {{def coefficients: 
Vector}} which will produce the normal results in binary case but produce 
flattened coefficients vector in and 0 intercept in multinomial case. This is 
hacky, but we can still design the prediction methods to be optimal by using 
the internal coefficient matrix and vector of intercepts. We could also add 
{{def coefficientsMatrix: Matrix}} and {{def interceptVector: Vector}} for 
convenience in the multinomial case. To handle the difference between pivot/no 
pivot in the binary case, we could make an expertParam. 

Thoughts [~dbtsai] [~yanboliang]?

> Decide on unified multinomial and binary logistic regression interfaces
> -----------------------------------------------------------------------
>
>                 Key: SPARK-17163
>                 URL: https://issues.apache.org/jira/browse/SPARK-17163
>             Project: Spark
>          Issue Type: Sub-task
>          Components: ML, MLlib
>            Reporter: Seth Hendrickson
>
> Before the 2.1 release, we should finalize the API for logistic regression. 
> After SPARK-7159, we have both LogisticRegression and 
> MultinomialLogisticRegression models. This may be confusing to users and, is 
> a bit superfluous since MLOR can do basically all of what BLOR does. We 
> should decide if it needs to be changed and implement those changes before 2.1



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to