Skip to content

Commit

Permalink
Made GaussianMixtureModel class serializable
Browse files Browse the repository at this point in the history
Modified sum function for better performance
  • Loading branch information
Travis Galoppo committed Nov 11, 2014
1 parent 5c96c57 commit c1a8e16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class GMMExpectationMaximization private (
/** Sum the values in array of doubles */
private def sum(x : Array[Double]) : Double = {
var s : Double = 0.0
x.foreach(u => s += u)
(0 until x.length).foreach(j => s += x(j))
s
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import org.apache.spark.mllib.linalg.Vector
* from each Gaussian i=1..k with probability w(i); mu(i) and sigma(i) are the respective
* mean and covariance for each Gaussian distribution i=1..k.
*/
class GaussianMixtureModel(val w: Array[Double], val mu: Array[Vector], val sigma: Array[Matrix]) {
class GaussianMixtureModel(
val w: Array[Double],
val mu: Array[Vector],
val sigma: Array[Matrix]) extends Serializable {

/** Number of gaussians in mixture */
def k: Int = w.length;
Expand Down

0 comments on commit c1a8e16

Please sign in to comment.