/// <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; }
/// <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 BoostTreeRankNetLoss(LabelFeatureDataCoded labelFeatureDataCoded, LabelConverter labelConvert, 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)); } 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; }
/// <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]; }
public Metrics(LabelFeatureCore labelFeatureCore, LabelConverter labelConvert, DataPartitionType[] dataTypes) { this.labelFeatureCore = labelFeatureCore; this.dataTypes = dataTypes; this.optimalID = -1; this.labels = new float[labelFeatureCore.NumDataPoint]; if (labelConvert != null) { for (int i = 0; i < labelFeatureCore.NumDataPoint; i++) { this.labels[i] = labelConvert.convert(labelFeatureCore.GetLabel(i)); } } else { for (int i = 0; i < labelFeatureCore.NumDataPoint; i++) { this.labels[i] = labelFeatureCore.GetLabel(i); } } this.dataSegments = new int[(int)DataPartitionType.cTypes][]; this.metricsCur = new float[(int)DataPartitionType.cTypes][]; for (int i = 0; i < (int)DataPartitionType.cTypes; i++) { metricsCur[i] = new float[SIZE]; } foreach (DataPartitionType dataType in dataTypes) { DataSet dataSet = labelFeatureCore.DataGroups.GetDataPartition(dataType); int[] dataSegment = dataSet.DataIndex; if (dataSegment != null) { dataSegments[(int)dataType] = dataSegment; } else { //we will fill in the non-existing data sections with 0 //throw new Exception("data partition does not exist"); } } this.results_list = new List<Result>(); }