예제 #1
0
 protected virtual double[] AdjustTargetsAndSetWeights(IChannel ch)
 {
     if (_gradientWrapper == null)
     {
         return(GetGradient(ch));
     }
     else
     {
         double[] targetWeights             = null;
         double[] targets                   = _gradientWrapper.AdjustTargetAndSetWeights(GetGradient(ch), ObjectiveFunction, out targetWeights);
         Dataset.DatasetSkeleton dsSkeleton = TrainingScores.Dataset.Skeleton;
         return(targets);
     }
 }
예제 #2
0
        /// <summary>
        /// Attempts to create a feature from a ulong array. The intent
        /// is that this will handle query ID.
        /// </summary>
        public static TsvFeature CreateFeatureFromQueryId(Dataset.DatasetSkeleton skel)
        {
            Dictionary <uint, int> uvalToOrder = new Dictionary <uint, int>();

            foreach (uint uintQid in skel.QueryIds.Select(qid => (uint)qid).Distinct().OrderBy(x => x))
            {
                uvalToOrder[uintQid] = uvalToOrder.Count;
            }
            IntArray bins = IntArray.New(
                skel.NumDocs, IntArrayType.Dense, IntArray.NumBitsNeeded(uvalToOrder.Count),
                skel.QueryIds.SelectMany((qid, i) =>
                                         Enumerable.Repeat(uvalToOrder[(uint)qid], skel.Boundaries[i + 1] - skel.Boundaries[i])));

            uint[] valueMap = uvalToOrder.Keys.OrderBy(x => x).ToArray(uvalToOrder.Count);
            return(new TsvFeature(bins, valueMap, "m:QueryId"));
        }