Skip to content

Commit 55675fb

Browse files
committed
Adding notice and code notice, Daisy system identification: Power Plant
1 parent 10844b3 commit 55675fb

23 files changed

+774
-21
lines changed

NOTICE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Apache DynaML
2+
Copyright 2015 The Apache Software Foundation
3+
4+
This product includes software developed at
5+
The Apache Software Foundation (http://www.apache.org/).
6+

data/powerplant.csv

Lines changed: 200 additions & 0 deletions
Large diffs are not rendered by default.

src/main/scala/io/github/mandar2812/dynaml/evaluation/BinaryClassificationMetrics.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.evaluation
220

321
import breeze.linalg.DenseVector

src/main/scala/io/github/mandar2812/dynaml/evaluation/BinaryClassificationMetricsSpark.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.evaluation
220

321
import breeze.linalg.DenseVector

src/main/scala/io/github/mandar2812/dynaml/evaluation/Metrics.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.evaluation
220

321
import breeze.linalg.DenseVector

src/main/scala/io/github/mandar2812/dynaml/evaluation/RegressionMetrics.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.evaluation
220

321
import breeze.linalg.DenseVector

src/main/scala/io/github/mandar2812/dynaml/evaluation/RegressionMetricsSpark.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.evaluation
220

321
import breeze.linalg.DenseVector
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
19+
package io.github.mandar2812.dynaml.examples
20+
21+
import breeze.linalg.DenseVector
22+
import com.quantifind.charts.Highcharts._
23+
import io.github.mandar2812.dynaml.evaluation.RegressionMetrics
24+
import io.github.mandar2812.dynaml.kernels.LocalSVMKernel
25+
import io.github.mandar2812.dynaml.models.svm.DLSSVM
26+
import io.github.mandar2812.dynaml.optimization.{GPMLOptimizer, GridSearch}
27+
import io.github.mandar2812.dynaml.pipes.{StreamDataPipe, DynaMLPipe, DataPipe}
28+
import org.apache.log4j.Logger
29+
30+
/**
31+
* Created by mandar on 4/3/16.
32+
*/
33+
object DaisyPowerPlant {
34+
def apply(kernel: LocalSVMKernel[DenseVector[Double]],
35+
deltaT: Int = 2, timelag:Int = 0, stepPred: Int = 3,
36+
num_training: Int = 150, column: Int = 7,
37+
opt: Map[String, String]) =
38+
runExperiment(kernel, deltaT, timelag,
39+
stepPred, num_training, column, opt)
40+
41+
def runExperiment(kernel: LocalSVMKernel[DenseVector[Double]],
42+
deltaT: Int = 2, timelag:Int = 0, stepPred: Int = 3,
43+
num_training: Int = 150, column: Int = 7,
44+
opt: Map[String, String]): Seq[Seq[AnyVal]] = {
45+
//Load Omni data into a stream
46+
//Extract the time and Dst values
47+
48+
val logger = Logger.getLogger(this.getClass)
49+
50+
val names = Map(6 -> "steam pressure",
51+
7 -> "main stem temperature",
52+
8 -> "reheat steam temperature")
53+
54+
//pipe training data to model and then generate test predictions
55+
//create RegressionMetrics instance and produce plots
56+
val modelTrainTest =
57+
(trainTest: ((Stream[(DenseVector[Double], Double)],
58+
Stream[(DenseVector[Double], Double)]),
59+
(DenseVector[Double], DenseVector[Double]))) => {
60+
61+
val model = new DLSSVM(trainTest._1._1, num_training, kernel)
62+
63+
val gs = opt("globalOpt") match {
64+
case "GS" => new GridSearch[model.type](model)
65+
.setGridSize(opt("grid").toInt)
66+
.setStepSize(opt("step").toDouble)
67+
.setLogScale(false)
68+
69+
case "ML" => new GPMLOptimizer[DenseVector[Double],
70+
Stream[(DenseVector[Double], Double)],
71+
DLSSVM](model)
72+
}
73+
74+
val startConf = kernel.state ++ Map("regularization" ->
75+
opt("regularization").toDouble)
76+
77+
val (_, conf) = gs.optimize(startConf, opt)
78+
79+
80+
81+
model.setRegParam(opt("regularization").toDouble).learn()
82+
83+
val res = trainTest._1._2.map(testpoint => (model.predict(testpoint._1), testpoint._2))
84+
85+
val scoresAndLabelsPipe = DataPipe((list: List[(Double, Double)]) =>
86+
list.map{l => (l._1*trainTest._2._2(-1) + trainTest._2._1(-1),
87+
l._2*trainTest._2._2(-1) + trainTest._2._1(-1))})
88+
89+
val scoresAndLabels = scoresAndLabelsPipe.run(res.toList)
90+
91+
val metrics = new RegressionMetrics(scoresAndLabels,
92+
scoresAndLabels.length)
93+
metrics.setName(names(column))
94+
95+
metrics.print()
96+
metrics.generatePlots()
97+
98+
//Plotting time series prediction comparisons
99+
line((1 to scoresAndLabels.length).toList, scoresAndLabels.map(_._2))
100+
hold()
101+
line((1 to scoresAndLabels.length).toList, scoresAndLabels.map(_._1))
102+
legend(List("Time Series", "Predicted Time Series (one hour ahead)"))
103+
unhold()
104+
105+
Seq(
106+
Seq(deltaT, 1, num_training, 200-num_training,
107+
metrics.mae, metrics.rmse, metrics.Rsq,
108+
metrics.corr, metrics.modelYield)
109+
)
110+
}
111+
112+
val preProcessPipe = DynaMLPipe.fileToStream >
113+
DynaMLPipe.trimLines >
114+
DynaMLPipe.replaceWhiteSpaces >
115+
DynaMLPipe.extractTrainingFeatures(
116+
List(0,column,1,2,3,4,5),
117+
Map()
118+
) >
119+
DynaMLPipe.removeMissingLines >
120+
StreamDataPipe((line: String) => {
121+
val splits = line.split(",")
122+
val timestamp = splits.head.toDouble
123+
val feat = DenseVector(splits.tail.map(_.toDouble))
124+
(timestamp, feat)
125+
}) >
126+
DynaMLPipe.deltaOperationVec(deltaT)
127+
128+
val trainTestPipe = DynaMLPipe.duplicate(preProcessPipe) >
129+
DynaMLPipe.splitTrainingTest(num_training, 200-num_training) >
130+
DynaMLPipe.gaussianStandardization >
131+
DataPipe(modelTrainTest)
132+
133+
trainTestPipe.run(("data/powerplant.csv",
134+
"data/powerplant.csv"))
135+
136+
}
137+
}

src/main/scala/io/github/mandar2812/dynaml/examples/FSExperiment.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.examples
220

321
import java.io.File

src/main/scala/io/github/mandar2812/dynaml/examples/PreprocessAdult.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.examples
220

321
import java.io.BufferedReader

src/main/scala/io/github/mandar2812/dynaml/examples/PreprocessForestCover.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.examples
220

321
import java.io.{BufferedReader, FileInputStream, InputStreamReader}

src/main/scala/io/github/mandar2812/dynaml/examples/PreprocessSusy.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.examples
220

321
import java.io.{BufferedReader, FileInputStream, InputStreamReader}

src/main/scala/io/github/mandar2812/dynaml/examples/TestAdult.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.examples
220

321
import java.io.File

src/main/scala/io/github/mandar2812/dynaml/examples/TestCommitteeNNOmni.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
119
package io.github.mandar2812.dynaml.examples
220

321

0 commit comments

Comments
 (0)