Last active
February 26, 2023 12:08
-
-
Save a-agmon/b0a247c56f25afcecf16f56e4bb12a68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class PredictionResult(key: String, ts:Timestamp, | |
label: Float, prediction: Float, ratio: Float) | |
def predict(appId:String, recordsIter:Iterator[FeaturesRecord]): | |
Seq[PredictionResult] = { | |
val predDF = for { | |
(trainSeq, actualValSeq) <- getForecastDataset(appId, recordsIter.toSeq) | |
booster <- trainXGBBooster(trainSeq) | |
forecastedVal <- predictXGBBooster(appId, booster, actualValSeq) | |
} yield forecastedVal | |
predDF match { | |
case Success(predictionResults) => predictionResults | |
case Failure(exc) => throw new RuntimeException(s"prediction failed due to $exc") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment