Github user sethah commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16699#discussion_r100896289
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
 ---
    @@ -168,6 +179,7 @@ private[regression] trait 
GeneralizedLinearRegressionBase extends PredictorParam
         }
     
         val newSchema = super.validateAndTransformSchema(schema, fitting, 
featuresDataType)
    +    if (isSetOffsetCol(this)) SchemaUtils.checkNumericType(schema, 
$(offsetCol))
    --- End diff --
    
    Are we requiring users to provide an offset when predicting on new data? I 
don't think we should, i.e. I think we should assume offset is zero if no 
offset column is provided. More specifically, I think this test should pass:
    
    ````scala
    test("predict with no offset") {
        val trainData = Seq(
          OffsetInstance(2.0, 1.0, 2.0, Vectors.dense(0.0, 5.0).toSparse),
          OffsetInstance(8.0, 2.0, 3.0, Vectors.dense(1.0, 7.0)),
          OffsetInstance(3.0, 3.0, 1.0, Vectors.dense(2.0, 11.0)),
          OffsetInstance(9.0, 4.0, 4.0, Vectors.dense(3.0, 13.0))
        ).toDF()
        val testData = Seq(
          Instance(2.0, 1.0, Vectors.dense(0.0, 5.0).toSparse),
          Instance(8.0, 2.0, Vectors.dense(1.0, 7.0)),
          Instance(3.0, 3.0, Vectors.dense(2.0, 11.0)),
          Instance(9.0, 4.0, Vectors.dense(3.0, 13.0))
        ).toDF()
        val trainer = new GeneralizedLinearRegression()
          .setFamily("poisson")
          .setWeightCol("weight")
          .setOffsetCol("offset")
    
        val model = trainer.fit(trainData)
        model.transform(testData).show()
      }
    ````


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to