Skip to content

Instantly share code, notes, and snippets.

@a-agmon
Last active March 6, 2023 08:29
Show Gist options
  • Save a-agmon/151c571373856577fbea252985296b44 to your computer and use it in GitHub Desktop.
Save a-agmon/151c571373856577fbea252985296b44 to your computer and use it in GitHub Desktop.
case class PredictionResult(key: String, ts:Timestamp,
label: Float, prediction: Float, ratio: Float)
private def predictXGBBooster(app_id: String, booster: Booster,
predictSeq: Seq[FeaturesRecord]):
Try[Seq[PredictionResult]] = Try {
val forecastedVal = booster.predict(predictSeq.toDMatrix)
predictSeq.zip(forecastedVal).map { case (FeaturesRecord(_, ts, _, label), forecast) =>
PredictionResult(app_id, ts, label, forecast(0), label / forecast(0))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment