-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathLearn.oms
45 lines (40 loc) · 1.23 KB
/
Learn.oms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
val images = Val[Array[File]]
val imageDirectory = Val[File]
val nbTrees = Val[Int]
val treeDepth = Val[Int]
val kFold = 10
val random = new util.Random(42)
val imagesArrays: Array[Array[File]] =
(0 until kFold).map(i => random.shuffle((workDirectory / "images").listFiles).toArray[File]).toArray
val learningOutput = Val[String]
val prepareFiles =
ScalaTask("""
val imageDirectory = newDir("image")
for
(f, i) <- images.zipWithIndex
do f.copy(imageDirectory / s"image$i.jpg")
""") set (
(inputs, outputs) += (nbTrees, treeDepth),
inputs += images,
outputs += imageDirectory
)
val learning = PythonTask(
workDirectory / "forest.py",
arguments = "images ${nbTrees} ${treeDepth}",
stdOut = learningOutput,
libraries = Seq("matplotlib", "scikit-learn", "pillow", "scikit-image")
) set (
inputs += (nbTrees, treeDepth),
inputFiles += (imageDirectory, "images", true),
outputs += (nbTrees, treeDepth)
)
DirectSampling(
sampling =
(nbTrees in (5 to 25 by 5)) x
(treeDepth in (3 to 18 by 3)),
evaluation =
DirectSampling(
sampling = (images in imagesArrays),
evaluation = prepareFiles -- learning
) hook (workDirectory / "points.csv", Seq(nbTrees, treeDepth, learningOutput))
)