blob: baff6a6ec0ba1884f4ecd2d7600182c4427ddd8b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package scalam
import scalax.file.Path
import breeze.linalg.DenseVector
class DataSet(val points: Seq[(Double, Double)], val name: String) {
def save(path: Path) = {
path.createFile(createParents = true, failIfExists = false)
for (processor <- path.outputProcessor; out = processor.asOutput)
for ((x, y) <- points) out.write(x + " " + y + "\n")
}
lazy val (xs, ys) = points.unzip match {
case (x, y) => (DenseVector(x: _*), DenseVector(y: _*))
}
}
object DataSet {
def apply(x: DenseVector[Double], y: DenseVector[Double], name: String = "") = new DataSet(x.data zip y.data, name)
}
|