Smart Thermostat AWS Spark - part Spark cluster select best scenario
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//select best scenario for each temperature cluster | |
val RDDtotalClustered = valRowsOnOff.map(result => ( (result._1, clusters.predict(Vectors.dense(result._2._1,result._2._2)) ), (result._2._3, 1L) ) | |
).reduceByKey((x, y) => (x._1 + y._1, x._2 + y._2) | |
).map(result => (result._1._2, ( result._2._1/result._2._2, result._1._1 ) ) | |
).reduceByKey((x, y) => if (x._1 < y._1) {(x._1, x._2)} else {(y._1, y._2)} | |
).mapValues(result => (math.round(result._1), result._2 )) | |
RDDtotalClustered.cache() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment