示例#1
0
        /// <summary>
        /// Trains this leaf based on input DataSets for signal and background
        /// </summary>
        public void Train(DataSet signal, DataSet background)
        {
            nSignal     = signal.Points.Count;
            nBackground = background.Points.Count;

            // Determines whether this is a final leaf or if it branches
            bool branch = ChooseVariable(signal, background);

            if (branch)
            {
                // Creates a branch
                output1 = new Leaf();
                output2 = new Leaf();

                DataSet signalLeft      = new DataSet(signal.Names);
                DataSet signalRight     = new DataSet(signal.Names);
                DataSet backgroundLeft  = new DataSet(background.Names);
                DataSet backgroundRight = new DataSet(background.Names);

                foreach (var dataPoint in signal.Points)
                {
                    if (DoSplit(dataPoint))
                    {
                        signalLeft.AddDataPoint(dataPoint);
                    }
                    else
                    {
                        signalRight.AddDataPoint(dataPoint);
                    }
                }

                foreach (var dataPoint in background.Points)
                {
                    if (DoSplit(dataPoint))
                    {
                        backgroundLeft.AddDataPoint(dataPoint);
                    }
                    else
                    {
                        backgroundRight.AddDataPoint(dataPoint);
                    }
                }

                //Console.WriteLine("Splitting sLeft: " + signalLeft.Points.Count + " sRight: " + signalRight.Points.Count
                //    + " bLeft: " + backgroundLeft.Points.Count + " bRight: " + backgroundRight.Points.Count);
                // Trains each of the resulting leaves
                output1.Train(signalLeft, backgroundLeft);
                output2.Train(signalRight, backgroundRight);
            }
            // Do nothing more if it is not a branch
        }
示例#2
0
 /// <summary>
 /// Trains the tree on signal and background samples
 /// </summary>
 public void Train(DataSet signal, DataSet background)
 {
     headnode.Train(signal, background);
 }