Skip to content

Instantly share code, notes, and snippets.

Created November 6, 2017 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e4f7014b9fb46e8f44ccb424780d2feb to your computer and use it in GitHub Desktop.
Save anonymous/e4f7014b9fb46e8f44ccb424780d2feb to your computer and use it in GitHub Desktop.
import resource._
import ml.combust.bundle.BundleFile
import ml.combust.mleap.runtime.MleapContext.defaultContext
import ml.combust.mleap.runtime.MleapSupport._
import ml.combust.mleap.runtime.serialization.FrameReader
object HelloWorld {
def main(args: Array[String]) {
/**
* Loading the model in zip file; deserializing it
*/
val mleapTransformerLr = (for (bf <- managed(BundleFile("jar:file:/Users/harshvardhan/Downloads/airbnb.model.lr.zip"))) yield {
bf.loadMleapBundle().get.root
}).tried.get
/**
* Test Data
*/
val s = scala.io.Source.fromURL("https://s3-us-west-2.amazonaws.com/mleap-demo/frame.json").mkString
val bytes = s.getBytes("UTF-8")
/**
* Running the test data against the model to get a prediction
*/
for (frame <- FrameReader("ml.combust.mleap.json").fromBytes(bytes);
frameLr <- mleapTransformerLr.transform(frame);
frameLrSelect <- frameLr.select("price_prediction")) {
println("Price LR: " + frameLrSelect.dataset(0).getDouble(0))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment