//Přesunout MeansPointy do správných clusterů private bool UpdateClusterMembership() { MinIndex min = new MinIndex(); bool changed = false; double[] distances = new double[_numberOfClusters]; double[] sse_count = new double[_numberOfClusters]; double result = 0; for (int i = 0; i < _normalizedDataToCluster.Count; ++i) { for (int k = 0; k < _numberOfClusters; ++k) { distances[k] = ElucDist.Get(_normalizedDataToCluster[i], _clusters[k]); } int newClusterId = min.Get(distances); if (newClusterId != _normalizedDataToCluster[i].Cluster) { changed = true; _normalizedDataToCluster[i].Cluster = _rawDataToCluster[i].Cluster = newClusterId; if (print) { Console.WriteLine("Width: " + _rawDataToCluster[i].Width + ", Lenght: " + _rawDataToCluster[i].Length + " ----> Cluster " + newClusterId); } } //SSE pro cluster sse_count[newClusterId] = sse_count[newClusterId] + distances.Min(); } //SSE celkové for (int o = 0; o < sse_count.Length; o++) { result = result + sse_count[o]; } sse = result; if (changed == false) { return(false); } if (IsClusterEmpty(_normalizedDataToCluster)) { return(false); } return(true); }
private bool AddDataRow(int key, TValue val) { if (HasDataRow(key)) { return(false); } dataSet.Add(key, val); if (MinData == null || MinIndex.CompareTo(key) > 0) { MinData = val; MinIndex = key; } if (MaxData == null || MaxIndex.CompareTo(key) < 0) { MaxData = val; MaxIndex = key; } return(true); }