public void Learn(List <DataElement> data) { kMeans _kMeans = new kMeans(d); _gaussianDistributions = _kMeans.GetGroupRepresentatives(data, threshold); List <double[][]> mfccVectors = new List <double[][]>(); for (int i = 0; i < data.Count; i++) { mfccVectors.Add(data[i].MfccCoefficients); } em = new ExpectationMaximization(_gaussianDistributions.ToArray(), mfccVectors); int iterations = 0; while (iterations < maxIterations) { List <DataElement> prevMeans = new List <DataElement>(); foreach (var gd in _gaussianDistributions) { prevMeans.Add(new DataElement(gd.Mean)); } em.Compute(); List <DataElement> currMeans = new List <DataElement>(); foreach (var gd in _gaussianDistributions) { currMeans.Add(new DataElement(gd.Mean)); } List <double> meansDistances = MathHelper.CountMeansDistances(prevMeans, currMeans); if (!MathHelper.meansDistancesChanged(threshold, meansDistances)) { break; } iterations++; } AfterLearning = true; }
public GMM() { Name = "GMM"; kMeans _kMeans = new kMeans(Enum.GetNames(typeof(SongGenre)).Length); //_gaussianDistributions = _kMeans.GetGroupRepresentatives(TrainingData); }