Ejemplo n.º 1
0
        public static IDictionary <int, string> GetComponentTypes()
        {
            MetadataRepository repository       = new MetadataRepository();
            OptionSetMetadata  componentTypeSet = repository.GetOptionSet("componenttype") as OptionSetMetadata;

            LabelConverter lc = new LabelConverter();

            return(componentTypeSet.Options.ToDictionary(k => k.Value.GetValueOrDefault(), e => ((string)lc.ConvertTo(e.Label, typeof(string), null, true)).Replace(" ", "")));
        }
Ejemplo n.º 2
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];
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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 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;
        }
Ejemplo n.º 5
0
 public NDCGPairwise(LabelFeatureCore labelFeatureCore, LabelConverter labelConvert, DataPartitionType[] dataTypes,
     int ndcgAt, bool dropEmptyQueries, float scoreForEmptyQuery)
     : base(labelFeatureCore, labelConvert, dataTypes)
 {
     this.ndcg = new NDCG(dropEmptyQueries, scoreForEmptyQuery, ndcgAt);
 }
Ejemplo n.º 6
0
        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>();
        }
Ejemplo n.º 7
0
 //dataType==null <=> all the data are used in one partition
 public PrecRecall(LabelFeatureData labelFeatureData, LabelConverter labelConvert, DataPartitionType[] dataTypes)
     : base(labelFeatureData, labelConvert, dataTypes)
 {
     this.stats = new int[2, 2];
 }
Ejemplo n.º 8
0
 //dataType==null <=> all the data are used in one partition
 public ClassError(LabelFeatureCore labelFeatureCore, LabelConverter labelConvert, DataPartitionType[] dataTypes)
     : base(labelFeatureCore, labelConvert, dataTypes)
 {
 }