/// <summary> /// UseKMeans is an extension that call KMeans through LearningAPI /// </summary> /// <param name="api">the LearningAPI object</param> /// <param name="settings">the desired clustering settings</param> /// <returns></returns> public static LearningApi UseKMeans(this LearningApi api, ClusteringSettings settings, double[] maxDistance = null) { var alg = new KMeansAlgorithm(settings.Clone(), maxDistance); api.AddModule(alg, "Rbm"); return(api); }
/// <summary> /// UseKMeans is an extansion that call KMeans through LearningAPI /// </summary> /// <param name="api">the LearningAPI object</param> /// <param name="settings">the desired clustering settings</param> /// <returns></returns> public static LearningApi UseKMeans(this LearningApi api, ClusteringSettings settings, double[][] centroids = null, double[] maxDistance = null) { var alg = new KMeans(settings, centroids, maxDistance); api.AddModule(alg, "Rbm"); return(api); }
/// <summary> /// Clonses settings object. /// </summary> /// <returns></returns> internal ClusteringSettings Clone() { ClusteringSettings sett = this.MemberwiseClone() as ClusteringSettings; if (this.InitialCentroids != null) { List <double[]> copyCentroids = new List <double[]>(); foreach (var centroid in this.InitialCentroids) { Array arr = new double[centroid.Length]; centroid.CopyTo(arr, 0); copyCentroids.Add(arr as double[]); } sett.InitialCentroids = copyCentroids.ToArray(); } return(sett); }
/// <summary> /// Installs the KMeanFunctionRecognitionModule in the LearningApi pipeline. /// </summary> /// <param name="api"></param> /// <param name="settings"></param> /// <returns></returns> public static LearningApi UseKMeansFunctionRecognitionModule(this LearningApi api, ClusteringSettings settings) { var alg = new KMeansFunctionRecognitionAlgorithm(settings); api.AddModule(alg, "KMeanFunctionRecognitionModule"); return(api); }