Example #1
0
        private SampleCollection CreateNextSamples(SampleCollection allNegSamples, double falsePositiveRate, int maxSampleNum)
        {
            int selectSampleCount = (int)(maxSampleNum / falsePositiveRate);

            if (selectSampleCount <= 0)
            {
                selectSampleCount = allNegSamples.Count;
            }
            SampleCollection negSamples = allNegSamples.GetNegSamples(selectSampleCount);
            int oldNum = negSamples.Count;

            negSamples = this.GetPositivePredictedSamples(negSamples);
            if (DebugMsg.Debug)
            {
                string msg = string.Format("选取了{0}个负样本,通过了{1}个,误检率为{2:P5}\r\n",
                                           oldNum, negSamples.Count, (MyFloat)negSamples.Count / oldNum);
                DebugMsg.AddMessage(msg, 0);
            }
            if (negSamples.Count > maxSampleNum)
            {
                negSamples.TrimExcess(maxSampleNum);
            }
            GC.Collect();
            return(negSamples);
        }
Example #2
0
        /// <summary>
        /// 使用当前的级联分类器对负目标negSamples进行分类,返回错分的目标,作为新的负样本集negSamples
        /// </summary>
        /// <param name="negSamples"></param>
        /// <returns></returns>
        private SampleCollection GetPositivePredictedSamples(SampleCollection samplecoll)
        {
            SampleCollection newCollection = new SampleCollection(samplecoll.Count);

            foreach (ISample sample in samplecoll)
            {
                if (true == this.Predict(sample))
                {
                    newCollection.Add(sample);
                }
            }
            newCollection.TrimExcess();
            return(newCollection);
        }