predictionio-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Gabrieli <dgabri...@salesforce.com>
Subject Ideas for handling large number of predictors
Date Mon, 20 Mar 2017 16:17:36 GMT
Hi,

I am trying to avoid hard coding the variable names into the predict
function. Wondering how other people do it.

 I've noticed a few engine templates have a pattern like this:

class Query(
  val attr0 : Double,
  val attr1 : Double,
  val attr2 : Double
) extends Serializable

def predict(model: NaiveBayesModel, query: Query): PredictedResult = {
    val label = model.predict(Vectors.dense(
      Array(query.attr0, query.attr1, query.attr2)
    ))
    new PredictedResult(label)
}


Is there a way to write the program without such strong coupling between
the Query and predict function?


I've also seen an array being used like this:

case class Query(
  val features: Array[Double]
) extends Serializable

val qryRow0 = Vectors.dense(query.features)
val score = model.aAFTSRModel.predict(qryRow)

Which is less verbose but then order matters in that array.....

I think ideally the Query class would just be a single map attribute and
the predict function could be passed that map directly or using something
similar to Python's **kwargs behavior.


Thanks

Mime
View raw message