/// <summary> /// Divides the input data into K clusters modeling each /// cluster as a multivariate Gaussian distribution. /// </summary> /// public int[] Compute(double[][] data, double[] weights) { if (clusters.Model == null) { Initialize(data, weights); } // Create the mixture options var mixtureOptions = new MixtureOptions() { Threshold = this.Tolerance, InnerOptions = this.Options, Iterations = this.Iterations, Logarithm = this.UseLogarithm }; MultivariateMixture <MultivariateNormalDistribution> model = clusters.Model; // Fit a multivariate Gaussian distribution model.Fit(data, weights, mixtureOptions); for (int i = 0; i < clusters.Model.Components.Length; i++) { clusters.Centroids[i] = new MixtureComponent <MultivariateNormalDistribution>(model, i); } if (ComputeLogLikelihood) { LogLikelihood = model.LogLikelihood(data); } if (ComputeLabels) { return(clusters.Nearest(data)); } return(null); }
int[] IClusteringAlgorithm <double[]> .Compute(double[][] data, double threshold) { Compute(data, threshold); return(clusters.Nearest(data)); }