Skip to content

Instantly share code, notes, and snippets.

@a-agmon
Last active July 6, 2022 09:04
Show Gist options
  • Save a-agmon/48d5d773ab8b0257c40b683002c78bce to your computer and use it in GitHub Desktop.
Save a-agmon/48d5d773ab8b0257c40b683002c78bce to your computer and use it in GitHub Desktop.
private def getInputVector(rawVector:Seq[Float]): DMatrix = {
val nRows = 1
val nCols = rawVector.length
val missingVal = Float.NaN
new DMatrix(rawVector.toArray[Float], nRows, nCols, missingVal)
}
def predict(recordID:String, features:Seq[Float]): (String, Float) = {
val xgbInput = getInputVector(features)
val result:Array[Array[Float]] = model.get.predict(xgbInput)
val score:Float = result(0)(0)
(recordID, score)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment