Ejemplo n.º 1
0
 public RegressionModel Train(BaseVector[] x, float[] y, IGroupDataProvider data)
 {
     if (ranker == null || nfeatures >= x[0].Length)
     {
         return(regressionMethod.Train(x, y, regressionParam, 1));
     }
     int[] o    = ranker.Rank(x, y, rankerParam, data, 1);
     int[] inds = nfeatures < o.Length ? ArrayUtils.SubArray(o, nfeatures) : o;
     return
         (new RegressionOnSubFeatures(
              regressionMethod.Train(ClassificationWithRanking.ExtractFeatures(x, inds), y, regressionParam, 1), inds));
 }
Ejemplo n.º 2
0
 public RegressionModel[] Train(BaseVector[] x, float[] y, IGroupDataProvider data)
 {
     int[]             o      = ranker.Rank(x, y, rankerParam, data, 1);
     int[]             sizes  = GetSizes(x[0].Length, reductionFactor, maxFeatures);
     RegressionModel[] result = new RegressionModel[sizes.Length];
     for (int i = 0; i < result.Length; i++)
     {
         if (i == 0 && sizes[0] == x[0].Length)
         {
             result[0] = classifier.Train(x, y, classifierParam, 1);
         }
         else
         {
             int[] inds = ArrayUtils.SubArray(o, sizes[i]);
             result[i] =
                 new RegressionOnSubFeatures(
                     classifier.Train(ClassificationWithRanking.ExtractFeatures(x, inds), y, classifierParam, 1), inds);
         }
     }
     return(result);
 }