Пример #1
0
        /// <summary>
        ///   Initializes a new instance of the Binary Split algorithm
        /// </summary>
        ///
        /// <param name="k">The number of clusters to divide the input data into.</param>
        /// <param name="distance">The distance function to use. Default is to
        /// use the <see cref="BestCS.Math.Distance.SquareEuclidean(double[], double[])"/> distance.</param>
        ///
        public BinarySplit(int k, Func <double[], double[], double> distance)
        {
            if (k <= 0)
            {
                throw new ArgumentOutOfRangeException("k");
            }
            if (distance == null)
            {
                throw new ArgumentNullException("distance");
            }

            // Create the object-oriented structure to hold
            //  information about the k-means' clusters.
            this.clusters = new KMeansClusterCollection(k, distance);
        }
Пример #2
0
        /// <summary>
        ///   Initializes a new instance of the KMeans algorithm
        /// </summary>
        ///
        /// <param name="k">The number of clusters to divide the input data into.</param>
        /// <param name="distance">The distance function to use. Default is to
        /// use the <see cref="BestCS.Math.Distance.SquareEuclidean(double[], double[])"/> distance.</param>
        ///
        public KMeans(int k, Func <double[], double[], double> distance)
        {
            if (k <= 0)
            {
                throw new ArgumentOutOfRangeException("k");
            }

            if (distance == null)
            {
                throw new ArgumentNullException("distance");
            }

            this.Tolerance          = 1e-5;
            this.ComputeInformation = true;
            this.UseCentroidSeeding = true;

            // Create the object-oriented structure to hold
            //  information about the k-means' clusters.
            this.clusters = new KMeansClusterCollection(k, distance);
        }
Пример #3
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="KMeansCluster"/> class.
 /// </summary>
 ///
 /// <param name="owner">The owner collection.</param>
 /// <param name="index">The cluster index.</param>
 ///
 public KMeansCluster(KMeansClusterCollection owner, int index)
 {
     this.owner = owner;
     this.index = index;
 }