Skip to content

Commit

Permalink
Added new grouped wavelet filters into DynaML Pipes library
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar2812 committed Dec 14, 2016
1 parent 0f04003 commit 2219649
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.github.mandar2812.dynaml.models.gp.AbstractGPRegressionModel
import io.github.mandar2812.dynaml.optimization.{CoupledSimulatedAnnealing, GPMLOptimizer, GloballyOptWithGrad, GridSearch}
import io.github.mandar2812.dynaml.pipes.{DataPipe, ReversibleScaler, Scaler, StreamDataPipe}
import io.github.mandar2812.dynaml.utils.{GaussianScaler, MVGaussianScaler, MinMaxScaler}
import io.github.mandar2812.dynaml.wavelets.{HaarWaveletFilter, InverseHaarWaveletFilter}
import io.github.mandar2812.dynaml.wavelets.{GroupedHaarWaveletFilter, HaarWaveletFilter, InvGroupedHaarWaveletFilter, InverseHaarWaveletFilter}
import org.apache.log4j.Logger
import org.renjin.script.RenjinScriptEngine
import org.renjin.sexp._
Expand Down Expand Up @@ -553,6 +553,10 @@ object DynaMLPipe {
* */
val invHaarWaveletFilter = (order: Int) => InverseHaarWaveletFilter(order)

val groupedHaarWaveletFilter = (orders: Array[Int]) => GroupedHaarWaveletFilter(orders)

val invGroupedHaarWaveletFilter = (orders: Array[Int]) => InvGroupedHaarWaveletFilter(orders)

def trainParametricModel[
G, T, Q, R, S, M <: ParameterizedLearner[G, T, Q, R, S]
](regParameter: Double, step: Double = 0.05,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ case class GroupedHaarWaveletFilter(orders: Array[Int]) extends ReversibleScaler

assert(partitionIndices.length == orders.length, "Number of partitions must be equal to number of variable groups")

override val i: Scaler[DenseVector[Double]] = InvGroupedHaarWaveletFilter(orders)
override val i: InvGroupedHaarWaveletFilter = InvGroupedHaarWaveletFilter(orders)

override def run(data: DenseVector[Double]): DenseVector[Double] = DenseVector(
partitionIndices.zip(componentFilters).map(limitsAndFilter => {
Expand All @@ -107,7 +107,7 @@ case class InvGroupedHaarWaveletFilter(orders: Array[Int]) extends Scaler[DenseV

val partitionIndices: Array[(Int, Int)] =
orders.map(twoExp).scanLeft(0)(_+_).sliding(2).map(c => (c.head, c.last)).toArray

assert(partitionIndices.length == orders.length, "Number of partitions must be equal to number of variable groups")

override def run(data: DenseVector[Double]): DenseVector[Double] = DenseVector(
Expand Down

0 comments on commit 2219649

Please sign in to comment.