Skip to content

Commit 993bdc8

Browse files
committed
Added overloaded apply() methods for ModelPredictionPipe
1 parent c394be6 commit 993bdc8

File tree

1 file changed

+27
-1
lines changed
  • dynaml-core/src/main/scala-2.11/io/github/mandar2812/dynaml/modelpipe

1 file changed

+27
-1
lines changed

dynaml-core/src/main/scala-2.11/io/github/mandar2812/dynaml/modelpipe/ModelPipe.scala

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package io.github.mandar2812.dynaml.modelpipe
22

33
import io.github.mandar2812.dynaml.models.Model
4-
import io.github.mandar2812.dynaml.pipes.DataPipe
4+
import io.github.mandar2812.dynaml.DynaMLPipe._
5+
import io.github.mandar2812.dynaml.pipes.{DataPipe, ReversibleScaler}
56

67
/**
78
* Top level trait for Pipes returning ML models.
@@ -45,7 +46,32 @@ class ModelPredictionPipe[T, -P, Q, R, +S, M <: Model[T, Q, R]](
4546
}
4647

4748
object ModelPredictionPipe {
49+
/**
50+
* Create a [[ModelPredictionPipe]] instance given
51+
* a pre-processing flow, a DynaML [[Model]] and a post-processing flow
52+
* respectively.
53+
* */
4854
def apply[T, P, Q, R, S, M <: Model[T, Q, R]](
4955
pre: DataPipe[P, Q], m: M, po: DataPipe[R, S]) =
5056
new ModelPredictionPipe[T, P, Q, R, S, M](pre, m, po)
57+
58+
/**
59+
* Create a [[ModelPredictionPipe]] instance
60+
* (having no pre or post processing steps)
61+
* given a DynaML [[Model]]
62+
*
63+
* */
64+
def apply[T, Q, R, M <: Model[T, Q, R]](m: M) =
65+
new ModelPredictionPipe[T, Q, Q, R, R, M](identityPipe[Q], m, identityPipe[R])
66+
67+
/**
68+
* Create a [[ModelPredictionPipe]] instance
69+
* given scaling relationships for features and outputs,
70+
* along with a DynaML [[Model]]
71+
*
72+
* */
73+
def apply[T, Q, R, M <: Model[T, Q, R]](
74+
featuresSc: ReversibleScaler[Q], outputSc: ReversibleScaler[R], m: M) =
75+
new ModelPredictionPipe[T, Q, Q, R, R, M](featuresSc, m, outputSc.i)
76+
5177
}

0 commit comments

Comments
 (0)