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

Yanbo Liang updated SPARK-6496:
-------------------------------
    Description: 
This bug is easy to reproduce, when use Multinomial Logistic Regression to 
train multiclass classification model with non-null initialWeights, it will 
throw an exception.
When you run
{code}
val lr = new LogisticRegressionWithLBFGS().setNumClasses(3)
val model = lr.run(input, initialWeights)
{code}
It will throw
{code}
requirement failed: LogisticRegressionModel.load with numClasses = 3 and 
numFeatures = -1 expected weights of length -2 (without intercept) or 0 (with 
intercept), but was given weights of length 10
java.lang.IllegalArgumentException: requirement failed: 
LogisticRegressionModel.load with numClasses = 3 and numFeatures = -1 expected 
weights of length -2 (without intercept) or 0 (with intercept), but was given 
weights of length 10
{code}


  was:
This bug is easy to reproduce, when use Multinomial Logistic Regression to 
train multiclass classification model with non-null initialWeights, it will 
throw exception.
{code}
val lr = new LogisticRegressionWithLBFGS().setNumClasses(3)
val model = lr.run(input, initialWeights)
{code}

{code}
requirement failed: LogisticRegressionModel.load with numClasses = 3 and 
numFeatures = -1 expected weights of length -2 (without intercept) or 0 (with 
intercept), but was given weights of length 10
java.lang.IllegalArgumentException: requirement failed: 
LogisticRegressionModel.load with numClasses = 3 and numFeatures = -1 expected 
weights of length -2 (without intercept) or 0 (with intercept), but was given 
weights of length 10
        at scala.Predef$.require(Predef.scala:233)
        at 
org.apache.spark.mllib.classification.LogisticRegressionModel.<init>(LogisticRegression.scala:58)
        at 
org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS.createModel(LogisticRegression.scala:365)
        at 
org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS.createModel(LogisticRegression.scala:328)
        at 
org.apache.spark.mllib.regression.GeneralizedLinearAlgorithm.run(GeneralizedLinearAlgorithm.scala:336)
        at 
org.apache.spark.mllib.classification.LogisticRegressionSuite$$anonfun$11.apply$mcV$sp(LogisticRegressionSuite.scala:429)
        at 
org.apache.spark.mllib.classification.LogisticRegressionSuite$$anonfun$11.apply(LogisticRegressionSuite.scala:403)
        at 
org.apache.spark.mllib.classification.LogisticRegressionSuite$$anonfun$11.apply(LogisticRegressionSuite.scala:403)
        at 
org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
        at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
        at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
        at org.scalatest.Transformer.apply(Transformer.scala:22)
        at org.scalatest.Transformer.apply(Transformer.scala:20)
        at org.scalatest.FunSuiteLike$$anon$1.apply(FunSuiteLike.scala:166)
        at org.scalatest.Suite$class.withFixture(Suite.scala:1122)
        at org.scalatest.FunSuite.withFixture(FunSuite.scala:1555)
        at 
org.scalatest.FunSuiteLike$class.invokeWithFixture$1(FunSuiteLike.scala:163)
        at 
org.scalatest.FunSuiteLike$$anonfun$runTest$1.apply(FunSuiteLike.scala:175)
        at 
org.scalatest.FunSuiteLike$$anonfun$runTest$1.apply(FunSuiteLike.scala:175)
        at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
        at org.scalatest.FunSuiteLike$class.runTest(FunSuiteLike.scala:175)
        at org.scalatest.FunSuite.runTest(FunSuite.scala:1555)
        at 
org.scalatest.FunSuiteLike$$anonfun$runTests$1.apply(FunSuiteLike.scala:208)
        at 
org.scalatest.FunSuiteLike$$anonfun$runTests$1.apply(FunSuiteLike.scala:208)
        at 
org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:413)
        at 
org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
        at scala.collection.immutable.List.foreach(List.scala:318)
        at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
        at 
org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:396)
        at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:483)
        at org.scalatest.FunSuiteLike$class.runTests(FunSuiteLike.scala:208)
        at org.scalatest.FunSuite.runTests(FunSuite.scala:1555)
        at org.scalatest.Suite$class.run(Suite.scala:1424)
        at 
org.scalatest.FunSuite.org$scalatest$FunSuiteLike$$super$run(FunSuite.scala:1555)
        at 
org.scalatest.FunSuiteLike$$anonfun$run$1.apply(FunSuiteLike.scala:212)
        at 
org.scalatest.FunSuiteLike$$anonfun$run$1.apply(FunSuiteLike.scala:212)
        at org.scalatest.SuperEngine.runImpl(Engine.scala:545)
        at org.scalatest.FunSuiteLike$class.run(FunSuiteLike.scala:212)
        at 
org.apache.spark.mllib.classification.LogisticRegressionSuite.org$scalatest$BeforeAndAfterAll$$super$run(LogisticRegressionSuite.scala:171)
        at 
org.scalatest.BeforeAndAfterAll$class.liftedTree1$1(BeforeAndAfterAll.scala:257)
        at 
org.scalatest.BeforeAndAfterAll$class.run(BeforeAndAfterAll.scala:256)
        at 
org.apache.spark.mllib.classification.LogisticRegressionSuite.run(LogisticRegressionSuite.scala:171)
        at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:55)
        at 
org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2563)
        at 
org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2557)
        at scala.collection.immutable.List.foreach(List.scala:318)
        at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:2557)
        at 
org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1044)
        at 
org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1043)
        at 
org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2722)
        at 
org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1043)
        at org.scalatest.tools.Runner$.run(Runner.scala:883)
        at org.scalatest.tools.Runner.run(Runner.scala)
        at 
org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:137)
        at 
org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
{code}


> Multinomial Logistic Regression failed when initialWeights is not null
> ----------------------------------------------------------------------
>
>                 Key: SPARK-6496
>                 URL: https://issues.apache.org/jira/browse/SPARK-6496
>             Project: Spark
>          Issue Type: Bug
>          Components: MLlib
>    Affects Versions: 1.3.0
>            Reporter: Yanbo Liang
>
> This bug is easy to reproduce, when use Multinomial Logistic Regression to 
> train multiclass classification model with non-null initialWeights, it will 
> throw an exception.
> When you run
> {code}
> val lr = new LogisticRegressionWithLBFGS().setNumClasses(3)
> val model = lr.run(input, initialWeights)
> {code}
> It will throw
> {code}
> requirement failed: LogisticRegressionModel.load with numClasses = 3 and 
> numFeatures = -1 expected weights of length -2 (without intercept) or 0 (with 
> intercept), but was given weights of length 10
> java.lang.IllegalArgumentException: requirement failed: 
> LogisticRegressionModel.load with numClasses = 3 and numFeatures = -1 
> expected weights of length -2 (without intercept) or 0 (with intercept), but 
> was given weights of length 10
> {code}



--
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