In [1]:
import breeze.linalg.DenseVector
import io.github.mandar2812.dynaml.graphics.charts.Highcharts._
import io.github.mandar2812.dynaml.DynaMLPipe._
import io.github.mandar2812.dynaml.pipes._
import io.github.mandar2812.dynaml.utils.GaussianScaler
import scala.collection.mutable.{MutableList => ML}


Out[1]:
import breeze.linalg.DenseVector

import io.github.mandar2812.dynaml.graphics.charts.Highcharts._

import io.github.mandar2812.dynaml.DynaMLPipe._

import io.github.mandar2812.dynaml.pipes._

import io.github.mandar2812.dynaml.utils.GaussianScaler

import scala.collection.mutable.{MutableList => ML}

In [2]:
val deltaOperationARXMultiOutput = (deltaT: List[Int], deltaTargets: List[Int]) =>
    DataPipe((lines: Iterable[(Double, DenseVector[Double])]) =>
      lines.toList.sliding(math.max(deltaT.max, deltaTargets.max) + 1).map((history) => {

        val hist = history.take(history.length - 1).map(_._2)

        val num_outputs = deltaTargets.length

        val featuresAcc: ML[Double] = ML()

        val lags = deltaT ++ deltaTargets

        (0 until hist.head.length).foreach((dimension) => {
          //for each dimension/regressor take points t to t-order
          featuresAcc ++= hist.takeRight(lags(dimension))
            .map(vec => vec(dimension))
        })

        val outputs = history.last._2(0 until num_outputs)
        val features = DenseVector(featuresAcc.toArray)

        (features, outputs)
      }).toStream)


Out[2]:
deltaOperationARXMultiOutput: (List[Int], List[Int]) => DataPipe[Iterable[(Double, DenseVector[Double])], Stream[(DenseVector[Double], DenseVector[Double])]] = ammonite.$sess.cmd1$Helper$$Lambda$2099/880113504@f8d0a54

In [3]:
val deltaT = 2


Out[3]:
deltaT: Int = 2

In [4]:
val preProcessPipe = fileToStream >
  trimLines >
  replaceWhiteSpaces >
  extractTrainingFeatures(
    List(0,5,6,7,8,1,2,3,4),
    Map()
  ) >
  removeMissingLines >
  IterableDataPipe((line: String) => {
    val splits = line.split(",")
    val timestamp = splits.head.toDouble
    val data_vec = DenseVector(splits.tail.map(_.toDouble))
    (timestamp, data_vec)
  }) >
  deltaOperationARXMultiOutput(
    List.fill(4)(deltaT),
    List.fill(4)(deltaT))


Out[4]:
preProcessPipe: ComposedPipe[String, Iterable[(Double, DenseVector[Double])], Stream[(DenseVector[Double], DenseVector[Double])]] = ComposedPipe(
  ComposedPipe(
    ComposedPipe(
      ComposedPipe(
        ComposedPipe(
          ComposedPipe(
            io.github.mandar2812.dynaml.pipes.DataPipe$$anon$2@c96dcb8,
            io.github.mandar2812.dynaml.pipes.IterableDataPipe$$anon$2@4c2fa5da
          ),
          io.github.mandar2812.dynaml.pipes.IterableDataPipe$$anon$2@55a78827
        ),
        io.github.mandar2812.dynaml.pipes.DataPipe$$anon$2@493a4f4d
      ),
      io.github.mandar2812.dynaml.pipes.IterableDataPipe$$anon$4@74cfc8d9
    ),
    io.github.mandar2812.dynaml.pipes.IterableDataPipe$$anon$2@45ffa2ef
  ),
  io.github.mandar2812.dynaml.pipes.DataPipe$$anon$2@2c70ecc7
)

In [5]:
preProcessPipe("../data/steamgen.csv")


Out[5]:
res4: Stream[(DenseVector[Double], DenseVector[Double])] = Stream(
  (
    DenseVector(320.08238893611104, 321.7109901970145, 2.5067738530481467, 2.5459079477298627, 0.032701299739161395, 0.2847994364405881, 9.302970053314816, 9.66262058403806, 0.7235675006200512, 0.5271473870728786, 0.6916286704298222, 0.3830201937658643, -2.28305641205371, -3.716481387850976, 0.017982753309452384, 0.018717890028551235),
    DenseVector(320.91330769424036, 2.3605615428942226, 0.20365164556689003, 10.990955477930623)
  ),
  (
    DenseVector(321.7109901970145, 320.91330769424036, 2.5459079477298627, 2.3605615428942226, 0.2847994364405881, 0.20365164556689003, 9.66262058403806, 10.990955477930623, 0.5271473870728786, 0.589603122994395, 0.3830201937658643, 0.7058146274340293, -3.716481387850976, -1.5309929715976218, 0.018717890028551235, 0.020756328419717966),
    DenseVector(325.0025177260005, 0.02705418231106365, 0.3261868791391608, 12.430107125754343)
  ),
  (
    DenseVector(320.91330769424036, 325.0025177260005, 2.3605615428942226, 0.02705418231106365, 0.20365164556689003, 0.3261868791391608, 10.990955477930623, 12.430107125754343, 0.589603122994395, 0.3648542218621854, 0.7058146274340293, 0.7132777258023264, -1.5309929715976218, -3.1730650036929084, 0.020756328419717966, 0.02292744292495133),
    DenseVector(326.65276458017433, 0.28564942908940694, 0.7537762506116668, 13.68166562833737)
  ),
  (
    DenseVector(325.0025177260005, 326.65276458017433, 0.02705418231106365, 0.28564942908940694, 0.3261868791391608, 0.7537762506116668, 12.430107125754343, 13.68166562833737, 0.3648542218621854, 0.5765401012070599, 0.7132777258023264, 0.3619780966136396, -3.1730650036929084, -1.7962118855409344, 0.02292744292495133, 0.020370994255220536),
    DenseVector(326.1869163744934, 2.631328071118863, 1.851854064211498, 14.608886382335426)
  ),
  (
    DenseVector(326.65276458017433, 326.1869163744934, 0.28564942908940694, 2.63...

In [ ]: