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

    https://github.com/apache/flink/pull/871#discussion_r34139297
  
    --- Diff: 
flink-staging/flink-ml/src/main/scala/org/apache/flink/ml/pipeline/Predictor.scala
 ---
    @@ -172,9 +198,42 @@ object Predictor {
           }
         }
       }
    +
    +  /** [[EvaluateDataSetOperation]] which takes a [[PredictOperation]] to 
calculate a tuple
    +    * of true label value and predicted label value, when provided with a 
DataSet of
    +    * [[LabeledVector]].
    +    *
    +    * @param predictOperation An implicit PredictOperation that takes a 
Flink Vector and returns
    +    *                         a Double
    +    * @tparam Instance The [[Predictor]] instance that calls the function
    +    * @tparam Model The model that the calling [[Predictor]] uses for 
predictions
    +    * @return An EvaluateDataSetOperation for LabeledVector
    +    */
    +  implicit def LabeledVectorEvaluateDataSetOperation[
    +  Instance <: Predictor[Instance],
    +  Model](
    +      implicit predictOperation: PredictOperation[Instance, Model, 
FlinkVector, Double])
    +    : EvaluateDataSetOperation[Instance, LabeledVector, Double] = {
    +    new EvaluateDataSetOperation[Instance, LabeledVector, Double] {
    +      override def evaluateDataSet(
    +          instance: Instance,
    +          evaluateParameters: ParameterMap,
    +          testing: DataSet[LabeledVector])
    +      : DataSet[(Double,  Double)] = {
    --- End diff --
    
    I think I fixed this and the above, does it look right like this?
    
    ```scala
    implicit def LabeledVectorEvaluateDataSetOperation[Instance <: 
Predictor[Instance],Model]
        (implicit predictOperation: PredictOperation[Instance, Model, 
FlinkVector, Double])
      : EvaluateDataSetOperation[Instance, LabeledVector, Double] = {
      new EvaluateDataSetOperation[Instance, LabeledVector, Double] {
        override def evaluateDataSet(
            instance: Instance,
            evaluateParameters: ParameterMap,
            testing: DataSet[LabeledVector])
          : DataSet[(Double,  Double)] = {
          val resultingParameters = instance.parameters ++ evaluateParameters
          val model = predictOperation.getModel(instance, resultingParameters)
    
          testing.mapWithBcVariable(model){
            (element, model) => {
              (element.label, predictOperation.predict(element.vector, model))
            }
          }
        }
      }
    }
    ```


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

Reply via email to