Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Smart Thermostat AWS Spark - part Spark cluster select best scenario
//select best scenario for each temperature cluster
val RDDtotalClustered = => ( (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 ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment