Exemplo n.º 1
0
        public HistogramAggregator(int nClasses, HistogramData data)
        {
            // bins_ = new int[nClasses];
            dataHandle_ = data.GetMemory();

            sampleCount_ = 0;
        }
Exemplo n.º 2
0
        public void Aggregate(IDataPointCollection data, int index, Object userData)
        {
            DataPointCollection concreteData  = (DataPointCollection)(data);
            HistogramData       histogramData = (HistogramData)(userData);

            histogramData.Increment(dataHandle_, concreteData.GetIntegerLabel((int)index));
            // bins_[concreteData.GetIntegerLabel((int)index)]++;
            sampleCount_ += 1;
        }
Exemplo n.º 3
0
        //public int FindTallestBinIndex()
        //{
        //  int maxCount = bins_[0];
        //  int tallestBinIndex = 0;

        //  for (int i = 1; i < bins_.Length; i++)
        //  {
        //    if (bins_[i] > maxCount)
        //    {
        //      maxCount = bins_[i];
        //      tallestBinIndex = i;
        //    }
        //  }

        //  return tallestBinIndex;
        //}

        #region IStatisticsAggregator implementation
        public void Clear(Object userData)
        {
            HistogramData histogramData = (HistogramData)(userData);

            histogramData.Clear(dataHandle_);
            //for (int b = 0; b < bins_.Length; b++)
            //  bins_[b] = 0;

            sampleCount_ = 0;
        }
Exemplo n.º 4
0
        public void Aggregate(HistogramAggregator aggregator, Object userData)
        {
            // System.Diagnostics.Debug.Assert(aggregator.bins_.Length == bins_.Length);

            HistogramData histogramData = (HistogramData)(userData);

            histogramData.Aggregate(dataHandle_, aggregator.dataHandle_);

            //for (int b = 0; b < bins_.Length; b++)
            //  bins_[b] += aggregator.bins_[b];

            sampleCount_ += aggregator.sampleCount_;
        }
Exemplo n.º 5
0
        public double Entropy(HistogramData data)
        {
            //if (sampleCount_ == 0)
            //  return 0.0;

            //double result = 0.0;
            //for (int b = 0; b < bins_.Length; b++)
            //{
            //  double p = (double)bins_[b] / (double)sampleCount_;
            //  result -= p == 0.0 ? 0.0 : p * Math.Log(p, 2.0);
            //}

            //return result;

            return(data.Entropy(dataHandle_, sampleCount_));
        }
Exemplo n.º 6
0
 public float GetProbability(int classIndex, HistogramData data)
 {
     // return (float)(bins_[classIndex]) / sampleCount_;
     return((float)(data.GetBin(dataHandle_, classIndex) / sampleCount_));
 }