Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
more troubleshooting collect errors
  • Loading branch information
vjtrost88 committed Apr 23, 2017
1 parent d32f729 commit 4a76d9a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Project/src/main/scala/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,21 @@ object Driver {
val end = System.nanoTime
println("KMeans Run-Time: " + (end - start) / 10e9 + "s")

val clusterCenters = model.clusterCenters map (_.toArray)
val clusterCenters = model.clusterCenters map (_.toArray).collect()
val cost = model.computeCost(parsedData)
println("Cost: " + cost)

//write cluster centers to file
val ccs = clusterCenters.collect()
val writer1 = new PrintWriter(new File("uberNightClusterCenters.txt"))
ccs.foreach(x => writer1.write(x + "\n"))
clusterCenters.foreach(x => writer1.write(x + "\n"))
writer1.close()

//show cluster centers and the number of members in them
//write to file
val clusterInd = model.predict(parsedData)
val cis = clusterInd.collect()
val clusterInd = model.predict(parsedData).collect()
val clusterSizes = clusterInd.countByValue()
val writer2 = new PrintWriter(new File("uberNightClusterSizes.txt"))
cis.foreach(x => writer2.write(x + "\n"))
clusterSizes.foreach(x => writer2.write(x + "\n"))
writer2.close()


Expand Down

0 comments on commit 4a76d9a

Please sign in to comment.