Example #1
0
        /// <summary>
        /// Generates cluster set using selected datapoints
        /// </summary>
        /// <param name="isChosen">Is datapoint is chosen</param>
        /// <returns></returns>
        public ClusterSet GetClusterSet(bool[] isChosen)
        {
            var clusterSet = new ClusterSet();

            // generates datapoint
            for (var i = 0; i < Rows.Count; i++)
            {
                var dataPoint = new DataPoint {
                    Id = i
                };
                // gets all points of datapoint
                for (var j = StringHeadings.Length; j < FieldsCount; j++)
                {
                    dataPoint.Add(double.Parse(Rows[i][j]));
                }

                // new cluster
                var cluster = new Cluster {
                    Id = i
                };
                cluster.AddDataPoint(dataPoint);
                cluster.SetCentroid();

                // add to set
                clusterSet.AddCluster(cluster);
            }

            return(clusterSet);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Agnes"/> class.
        /// </summary>
        /// <param name="clusters">The clusters.</param>
        /// <param name="distanceMetric">The distance metric.</param>
        /// <param name="strategy">The strategy.</param>
        public Agnes(ClusterSet clusters, DistanceMetric distanceMetric, MergeStrategy strategy)
        {
            _clusters = clusters;
            _initialNumberOfClusters = clusters.Count;
            _distanceMetric          = distanceMetric;
            _strategy = strategy;

            // creating initial dissimilarity matrix from _clusters
            BuildDissimilarityMatrix();

            _chValue = new List <double>();
            _chIndex = new List <int>();
        }