Github user BryanCutler commented on a diff in the pull request:
https://github.com/apache/spark/pull/6300#discussion_r30759972
--- Diff: mllib/src/main/scala/org/apache/spark/ml/Predictor.scala ---
@@ -184,9 +185,45 @@ abstract class PredictionModel[FeaturesType, M <:
PredictionModel[FeaturesType,
}
}
+ protected def transformImpl(dataset: DataFrame): DataFrame = {
+ dataset.withColumn($(predictionCol), callUDF(predict _, DoubleType,
col($(featuresCol))))
+ }
+
/**
* Predict label for the given features.
* This internal method is used to implement [[transform()]] and output
[[predictionCol]].
*/
protected def predict(features: FeaturesType): Double
}
+
+
+/**
+ * :: DeveloperApi ::
+ *
+ * Abstraction for a model for prediction tasks that will broadcast the
model used to predict.
+ *
+ * @tparam FeaturesType Type of features.
+ * E.g., [[org.apache.spark.mllib.linalg.VectorUDT]]
for vector features.
+ * @tparam M Specialization of [[PredictionModel]]. If you subclass this
type, use this type
+ * parameter to specify the concrete type for the corresponding
model.
+ */
+@DeveloperApi
+abstract class PredictionModelBroadcasting[
+ FeaturesType, M <: PredictionModelBroadcasting[FeaturesType, M]
+ ]
+ extends PredictionModel[FeaturesType, M] {
+
+ protected def transformImpl(dataset: DataFrame, bcastModel:
Broadcast[M]): DataFrame = {
--- End diff --
I'm not sure if using the Broadcast variable as a parameter is a good idea
---
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]