示例#1
0
 private byte[] GetCurrentMeanPoint()
 {
     if (PointCount != 0)
     {
         return(ClusteringUtilities.MeanOf(this, PointDim));
     }
     else
     {
         return(Centroid.Values);
     }
 }
示例#2
0
        // returns the feature and value of the node and the rightmost index corresponding the left child node in the sorted band, if the feature is -1 then it is a leaf node
        private (byte, int, int) GetNodeValues(Interval intv)
        {
            int[] usedBands = ClusteringUtilities.PickFromRangeWithoutReplacement(_random, 0, BandCount, _bandCountPerSplit);
            (int band, int rightMostInd) = GetBestSplit(intv, usedBands);

            if (band == -1) // could not split the node, it is a leaf
            {
                return(GetMaxCountTarget(), -1, -1);
            }
            else
            {
                return(_points[band][_currentIndices[rightMostInd]], band, rightMostInd);
            }
        }
示例#3
0
 /// <summary>
 /// Initialize clusters with centroids determined by means of image points.
 /// </summary>
 /// <param name="polysInPoints">List of List of image indexes. Each list contains image indexes, the means of these points will be the centroid ponits</param>
 protected void InitManualClustersPoly(List <List <int> > polysInPoints)
 {
     _clusters = new Dictionary <uint, Cluster>();
     System.Diagnostics.Debug.WriteLine("polysInPoints.Count: " + polysInPoints.Count);
     foreach (List <int> poly in polysInPoints)
     {
         System.Diagnostics.Debug.WriteLine("poly.Count: " + poly.Count);
         Centroid      centroid = new Centroid(PointDim);
         List <byte[]> points   = new List <byte[]>();
         foreach (int p in poly)
         {
             points.Add(_points[p]);
         }
         byte[] sample = ClusteringUtilities.MeanOf(points, PointDim);
         centroid.CopyValuesFrom(sample);
         _clusters.Add(centroid.ID, new Cluster(_points, _distance, centroid));
     }
 }
示例#4
0
        /*private void InitSortingBand(int count)
         * {
         *  _currentBand = new byte[count];
         * }*/

        private void BootstrapAggregateIndices(int pointCount, int bootstrapPointCount)
        {
            _currentIndices = ClusteringUtilities.PickFromRangeWithReplacement(_random, 0, pointCount, bootstrapPointCount);
        }
 public void SetWeightedAverageOf(Centroid ctr1, int weight1, Centroid ctr2, int weight2)
 {
     Values = ClusteringUtilities.WeightedAverageOf(ctr1.Values, weight1, ctr2.Values, weight2);
 }
 public void SetMeanOf(IEnumerable <byte[]> points)
 {
     Values = ClusteringUtilities.MeanOf(points, Dim);
 }
 public void Subtract(byte[] other)
 {
     Values = ClusteringUtilities.Subtract(Values, other);
 }
 public void Add(byte[] other)
 {
     Values = ClusteringUtilities.Add(Values, other);
 }