Skip to content

Instantly share code, notes, and snippets.

@alaiacano
Created June 17, 2014 21:56
Show Gist options
  • Save alaiacano/4c3aa99a39ef088c1f66 to your computer and use it in GitHub Desktop.
Save alaiacano/4c3aa99a39ef088c1f66 to your computer and use it in GitHub Desktop.
pmml example
// load the data and convert it to a Glass object.
val data: TypedPipe[Glass] = TextLine(args("input"))
.map{line => Glass.fromTextLine(line)}
// open the SVM model used to predict the type of glass.
val svmModel = getClass.getResource(modelFile).openStream()
val svmModelEvaluator = Predictable.buildEvaluator(svmModel)
val predictedType: TypedPipe[(Int, GlassType.PredictType)] = data
// turn the Glass object into a GlassType
.map(GlassType.fromGlass)
// predict type
.map{ meas => (meas.id, meas.predict(svmModelEvaluator)) }
// write output
.write(TypedTsv[(Int, GlassType.PredictType)](outputTypeFile))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment