Github user sethah commented on the issue: https://github.com/apache/spark/pull/16740 I agree having a special case is unsatisfying from an engineering perspective. In Spark it's a bit different than R since every iteration of IRLS will launch a Spark job, making a pass over the data, so the cost of the extra iterations is much higher. We have special-cased other algorithms for this reason. It's entirely possible I'm missing something since I do not know the GLM code quite so well, and I did not thoroughly check it, but this code seemed to do the trick: ````scala if (numFeatures == 0 && getFitIntercept) { val agg = dataset.agg(sum(w * col(getLabelCol)), sum(w)).first() val mu = agg.getDouble(0) / agg.getDouble(1) val diagInvAtA = (familyAndLink.family.variance(mu) * familyAndLink.link.deriv(mu)) / agg.getDouble(0) val model = copyValues(new GeneralizedLinearRegressionModel(uid, Vectors.zeros(0), familyAndLink.link.link(mu)).setParent(this)) val trainingSummary = new GeneralizedLinearRegressionTrainingSummary(dataset, model, Array(diagInvAtA), 1, getSolver) return model.setSummary(Some(trainingSummary)) } ```` The best answer here may depend on the use cases - do we expect users to be training "intercept-only" models often? If yes, then the savings on the iteration time may be worth it. If not, it _is_ a clunky solution. We can see what others think. Also, I got some strange failures when training with no features and `fitIntercept == false`. We should just throw an error in this case and add a test for it.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org