-
Notifications
You must be signed in to change notification settings - Fork 49
Embedding Hadrian
The Hadrian Basic Use page provides enough information to embed the Hadrian library in an application. This tutorial acts as a check-list with an explicit example.
This article was tested with Hadrian 0.8.1; newer versions should work with no modification. Scala >= 2.10 and sbt is required. Download sbt here and test it by typing sbt
on the command line.
Also download the Iris dataset and a simple tree classification for it.
In this tutorial, we will write a Scala application that runs a PFA engine on data from a CSV file, writing the result as a CSV file.
Create directory minihadrian
and add a file named build.sbt
with the following contents:
libraryDependencies += "com.opendatagroup" % "hadrian" % "0.8.1"
resolvers += "opendatagroup" at "http://repository.opendatagroup.com/maven"
Next, add a file named 'minihadrian.scala' with the following contents:
import com.opendatagroup.hadrian.jvmcompiler.defaultPFAVersion
object MiniHadrian {
def main(args: Array[String]) {
println(s"PFA version $defaultPFAVersion")
}
}
Run sbt
in the minihadrian
directory (close and restart it if it had been running before adding build.sbt
). You should see
% sbt
[info] Set current project to minihadrian (in build file:/tmp/minihadrian/)
> run
[info] Running MiniHadrian
PFA version 0.8.1
[success] Total time: 1 s, completed Nov 17, 2015 2:59:52 PM
>
(possibly with different version numbers).
Return to the Hadrian wiki table of contents.
Licensed under the Hadrian Personal Use and Evaluation License (PUEL).