Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/13129#discussion_r63474760
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
---
@@ -239,10 +239,7 @@ class GeneralizedLinearRegression @Since("2.0.0")
(@Since("2.0.0") override val
}
val familyAndLink = new FamilyAndLink(familyObj, linkObj)
- val numFeatures = dataset.select(col($(featuresCol))).limit(1).rdd
- .map { case Row(features: Vector) =>
- features.size
- }.first()
+ val numFeatures =
dataset.select(col($(featuresCol))).first().getAs[Vector](0).size
--- End diff --
It looks like Spark does not provide encoder for Vector. If I change to use
```as[Vector]```, the compiler will complain:
```
Error:(244, 61) Unable to find encoder for type stored in a Dataset.
Primitive types (Int, String, etc) and Product types (case classes) are
supported by importing spark.implicits._ Support for serializing other types
will be added in future releases.
val numFeatures =
dataset.select(col($(featuresCol))).as[Vector].first().size
^
```
---
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]