Beispiel #1
0
        /// <summary>
        /// Constructor of McBoostTreeLoss
        /// </summary>
        /// <param name="dp">the input data used to train boosted regression trees</param>
        /// <param name="learnRate">the input learning rate specified in training</param>
        public McBoostTreeLoss(LabelFeatureDataCoded labelFeatureDataCoded, LabelConverter labelConvert,
                               float learnRate)
        {
            this.learnRate = learnRate;

            this.numClass = 0;
            this.numSamples = labelFeatureDataCoded.NumDataPoint;
            this.classLabels = new int[labelFeatureDataCoded.NumDataPoint];
            for (int i = 0; i < this.numSamples; i++)
            {
                this.classLabels[i] = (int)labelConvert.convert(labelFeatureDataCoded.GetLabel(i));
                if (this.classLabels[i] + 1 > this.numClass)
                    this.numClass = this.classLabels[i] + 1;
            }

            //qiangwu: we probably don't need a matrix to store the label information though it is more convinent coding-wise
            this.classLabelsMatrix = BulidClassLabelsMatrix(this.classLabels, this.numClass);

            this.classProb = new float[this.numClass][];
            this.classFunValue = new float[this.numClass][];
            this.pseudoResponses = new float[this.numClass][];
            this.weights = new float[this.numClass][];

            for (int k = 0; k < this.numClass; k++)
            {
                this.classProb[k] = new float[this.numSamples];
                this.classFunValue[k] = new float[this.numSamples];
                this.pseudoResponses[k] = new float[this.numSamples];
                this.weights[k] = new float[this.numSamples];
            }

            //float[] weightsByLabel = WeightsByLabel(this.classLabels);
            //float[] probWeights = new float[this.numSamples];
        }
Beispiel #2
0
        /// <summary>
        /// Constructor of BoostTreeRankNetLoss
        /// </summary>
        /// <param name="dp">the input data used to train boosted regression trees</param>
        /// <param name="learnRate">the input learning rate specified in training</param>
        public BoostTreeNoGainLambdaLoss(LabelFeatureDataCoded labelFeatureDataCoded, LabelConverter labelConvert,
                                   float learnRate, float labelWeight, StepSizeType stepSizeType, FindStepLib fs,
                                   float labelForUnlabeled, double scoreForDegenerateQuery, int truncLevel)
        {
            this.learnRate = learnRate;
            this.labelWeight = labelWeight;

            this.labelForUnlabeled = labelForUnlabeled;
            this.scoreForDegenerateQuery = scoreForDegenerateQuery;
            this.truncLevel = truncLevel;

            this.labels = new float[labelFeatureDataCoded.NumDataPoint];

            for (int i = 0; i < labelFeatureDataCoded.NumDataPoint; i++)
            {
                this.labels[i] = labelConvert.convert(labelFeatureDataCoded.GetLabel(i));
            }

            this.numSamples = labels.Length;

            this.score = new float[this.numSamples];
            this.funValue = new float[this.numSamples];
            this.pseudoResponses = new float[this.numSamples];
            this.weights = new float[this.numSamples];

            this.labelFeatureDataCoded = labelFeatureDataCoded;

            //data member to compute the optimal adjustment factor (step size) for leaf nodes response
            this.qcAccum = this.CreateQueryCollection();
            this.qcCurrent = this.CreateQueryCollection();
            this.fs = fs;
            this.stepSizeType = stepSizeType;
        }
Beispiel #3
0
        public BoostTreeRegressionLoss(LabelFeatureDataCoded labelFeatureDataCoded, 
                                       float learnRate)
        {
            this.learnRate = learnRate;

            this.numSamples = labelFeatureDataCoded.NumDataPoint;
            this.labels = new float[labelFeatureDataCoded.NumDataPoint];

            //for (int i = 0; i < labelFeatureDataCoded.NumDataPoint; i++)
            //{
            //    this.labels[i] = labelConvert.convert(labelFeatureDataCoded.GetLabel(i));
            //}
            for (int i = 0; i < labelFeatureDataCoded.NumDataPoint; i++)
            {
                this.labels[i] = labelFeatureDataCoded.GetLabel(i);
            }

            this.scores = new float[this.numSamples];
            this.funValues = new float[this.numSamples];
            this.pseudoResponses = new float[this.numSamples];
            //this.weights = new float[this.numSamples];

            this.labelFeatureDataCoded = labelFeatureDataCoded;
        }