public override Parameters GetParameters(IGroupDataProvider data)
 {
     return(new Parameters(new Parameter[] { new DoubleParam("C", 100)
                                             {
                                                 Help = SvmClassification.cHelp
                                             } }));
 }
        public ClassificationModel Train(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data, int nthreads,
			Action<double> reportProgress)
        {
            return groupWiseSelection
                        ? TrainGroupWise(x, y, ngroups, data, nthreads)
                        : TrainGlobal(x, y, ngroups, data, nthreads, reportProgress);
        }
Exemplo n.º 3
0
 public ClassificationModel Train(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data, int nthreads,
                                  Action <double> reportProgress)
 {
     return(groupWiseSelection
                                         ? TrainGroupWise(x, y, ngroups, data, nthreads)
                                         : TrainGlobal(x, y, ngroups, data, nthreads, reportProgress));
 }
Exemplo n.º 4
0
 public PermissionsService(IRolesDataProvider roleDataProvider, IPermissionsDataProvider permissionsDataProvider, ILogger <PermissionsService> logger, IGroupDataProvider groupDataProvider)
 {
     _permissionsDataProvider = permissionsDataProvider ?? throw new ArgumentNullException(nameof(permissionsDataProvider));
     _roleDataProvider        = roleDataProvider ?? throw new ArgumentNullException(nameof(roleDataProvider));
     _logger            = logger;
     _groupDataProvider = groupDataProvider ?? throw new ArgumentNullException(nameof(groupDataProvider));
 }
Exemplo n.º 5
0
 public override Parameters GetParameters(IGroupDataProvider data)
 {
     return(new Parameters(new Parameter[] { new DoubleParam("s0", 0)
                                             {
                                                 Help = s0Help
                                             } }));
 }
 public static Parameters[] GetAllSubParameters(IGroupDataProvider data)
 {
     Parameters[] result = new Parameters[allMethods.Length];
     for (int i = 0; i < result.Length; i++){
         result[i] = allMethods[i].GetParameters(data);
     }
     return result;
 }
Exemplo n.º 7
0
 public static Parameters[] GetAllSubParameters(IGroupDataProvider data)
 {
     Parameters[] result = new Parameters[allMethods.Length];
     for (int i = 0; i < result.Length; i++)
     {
         result[i] = allMethods[i].GetParameters(data);
     }
     return(result);
 }
 public override Parameters GetParameters(IGroupDataProvider data)
 {
     return
         new Parameters(new Parameter[]{
             new DoubleParam("C", 100){Help = SvmClassification.cHelp},
             new DoubleParam("Reduction factor", 1.414){
                 Help = "The feature set will be recursively reduced in size by this factor."
             }
         });
 }
Exemplo n.º 9
0
 public ClassificationModel TrainGroupWise(int i, int[][] y, BaseVector[] x, IGroupDataProvider data)
 {
     int[][] yb = ToBinaryClasses(y, i);
     if (ranker == null || groupWiseNfeatures[i] >= x[0].Length)
     {
         return(classifier.Train(x, yb, 2, classifierParam, 1));
     }
     int[] o    = ranker.Rank(x, yb, 2, rankerParam, data, 1);
     int[] inds = nfeatures < o.Length ? ArrayUtils.SubArray(o, groupWiseNfeatures[i]) : o;
     return(new ClassificationOnSubFeatures(classifier.Train(ExtractFeatures(x, inds), yb, 2, classifierParam, 1), inds));
 }
Exemplo n.º 10
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);
 }
 public override Parameters GetParameters(IGroupDataProvider data)
 {
     return(new Parameters(new DoubleParam("C", 100)
     {
         Help = SvmClassification.cHelp
     },
                           new DoubleParam("Reduction factor", 1.414)
     {
         Help = "The feature set will be recursively reduced in size by this factor."
     }));
 }
Exemplo n.º 12
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));
 }
        public ClassificationModel TrainGlobal(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data, int nthreads,
			Action<double> reportProgress)
        {
            if (ranker == null || nfeatures >= x[0].Length){
                return classifier.Train(x, y, ngroups, classifierParam, nthreads, reportProgress);
            }
            int[] o = ranker.Rank(x, y, ngroups, rankerParam, data, nthreads);
            int[] inds = nfeatures < o.Length ? ArrayUtils.SubArray(o, nfeatures) : o;
            return
                new ClassificationOnSubFeatures(classifier.Train(ExtractFeatures(x, inds), y, ngroups, classifierParam, nthreads),
                    inds);
        }
 public int[] Rank(BaseVector[] x, float[] y, Parameters param, IGroupDataProvider data, int nthreads)
 {
     int nfeatures = x[0].Length;
     double[] s = new double[nfeatures];
     for (int i = 0; i < nfeatures; i++){
         float[] xx = new float[x.Length];
         for (int j = 0; j < xx.Length; j++){
             xx[j] = (float)x[j][i];
         }
         s[i] = CalcScore(xx, y);
     }
     return ArrayUtils.Order(s);
 }
 public GroupMemberNotificationService(ILogger <GroupMemberNotificationService> logger,
                                       IEmailService emailService,
                                       IOptionsSnapshot <GovNotifyConfiguration> notifyConfig,
                                       IOptionsSnapshot <ApplicationGateway> gatewayConfig,
                                       IUserDataProvider userDataProvider,
                                       IGroupDataProvider groupDataProvider)
 {
     _logger                 = logger;
     _emailService           = emailService;
     _govNotifyConfiguration = notifyConfig.Value;
     _userDataProvider       = userDataProvider;
     _groupDataProvider      = groupDataProvider ?? throw new ArgumentNullException(nameof(groupDataProvider));
     _fqdn = gatewayConfig.Value.FQDN ?? throw new ArgumentNullException(nameof(gatewayConfig.Value.FQDN));
 }
        public override int[] Rank(BaseVector[] x, double[] y, Parameters param, IGroupDataProvider data, int nthreads)
        {
            int nfeatures = x[0].Length;

            double[] s = new double[nfeatures];
            for (int i = 0; i < nfeatures; i++)
            {
                double[] xx = new double[x.Length];
                for (int j = 0; j < xx.Length; j++)
                {
                    xx[j] = x[j][i];
                }
                s[i] = CalcScore(xx, y);
            }
            return(ArrayUtils.Order(s));
        }
        public override int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data,
			int nthreads, Action<double> reportProgress)
        {
            SvmParameter sp = new SvmParameter{
                kernelFunction = new LinearKernelFunction(),
                svmType = SvmType.CSvc,
                c = param.GetParam<double>("C").Value
            };
            bool[] invert;
            SvmProblem[] problems = CreateProblems(x, y, ngroups, out invert);
            int[][] rankedSets = new int[problems.Length][];
            for (int i = 0; i < problems.Length; ++i){
                rankedSets[i] = RankBinary(problems[i], sp);
            }
            return CombineRankedFeaturesLists(rankedSets);
        }
Exemplo n.º 18
0
        public override int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data,
			int nthreads, Action<double> reportProgress)
        {
            double s0 = param.GetParam<double>("s0").Value;
            int nfeatures = x[0].Length;
            int[][] yy = RearrangeGroups(y, ngroups);
            double[] s = new double[nfeatures];
            for (int i = 0; i < nfeatures; i++){
                double[] xx = new double[x.Length];
                for (int j = 0; j < xx.Length; j++){
                    xx[j] = x[j][i];
                }
                s[i] = CalcPvalue(xx, yy, ngroups, s0);
            }
            return ArrayUtils.Order(s);
        }
 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;
 }
Exemplo n.º 20
0
        public int[] Rank(BaseVector[] x, float[] y, Parameters param, IGroupDataProvider data, int nthreads)
        {
            int nfeatures = x[0].Length;

            float[]  yr = ArrayUtils.RankF(y);
            double[] s  = new double[nfeatures];
            for (int i = 0; i < nfeatures; i++)
            {
                float[] xx = new float[x.Length];
                for (int j = 0; j < xx.Length; j++)
                {
                    xx[j] = (float)x[j][i];
                }
                float[] xxr = ArrayUtils.RankF(xx);
                s[i] = CalcScore(xxr, yr);
            }
            return(ArrayUtils.Order(s));
        }
Exemplo n.º 21
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);
 }
Exemplo n.º 22
0
        private const long MaxFileSizeBytes          = 5242880; // 5MB

        public GroupService(ISystemClock systemClock,
                            ILogger <DiscussionService> logger,
                            IPermissionsService permissionsService,
                            IFileCommand fileCommand,
                            IImageBlobStorageProvider blobStorageProvider,
                            IFileTypeValidator fileTypeValidator,
                            IGroupImageService imageService,
                            IGroupCommand groupCommand,
                            IHtmlSanitizer htmlSanitizer,
                            IGroupDataProvider groupDataProvider,
                            IContentService contentService)
        {
            _systemClock         = systemClock ?? throw new ArgumentNullException(nameof(systemClock));
            _blobStorageProvider = blobStorageProvider ?? throw new ArgumentNullException(nameof(blobStorageProvider));
            _permissionsService  = permissionsService ?? throw new ArgumentNullException(nameof(permissionsService));
            _fileTypeValidator   = fileTypeValidator ?? throw new ArgumentNullException(nameof(fileTypeValidator));
            _groupCommand        = groupCommand ?? throw new ArgumentNullException(nameof(groupCommand));
            _groupDataProvider   = groupDataProvider ?? throw new ArgumentNullException(nameof(groupDataProvider));
            _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
            _imageService   = imageService ?? throw new ArgumentNullException(nameof(imageService));
            _htmlSanitizer  = htmlSanitizer ?? throw new ArgumentNullException(nameof(htmlSanitizer));
            _contentService = contentService ?? throw new ArgumentNullException(nameof(contentService));
        }
 public ClassificationModel Train(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data, int nthreads)
 {
     return Train(x, y, ngroups, data, nthreads, null);
 }
 public override Parameters GetParameters(IGroupDataProvider data)
 {
     return(new Parameters());
 }
        public ClassificationModel TrainGroupWise(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data,
			int nthreads)
        {
            ClassificationModel[] c = new ClassificationModel[ngroups];
            ThreadDistributor td = new ThreadDistributor(nthreads, ngroups, i => { c[i] = TrainGroupWise(i, y, x, data); });
            td.Start();
            return new GroupWiseClassifier(c);
        }
 public ClassificationModel TrainGroupWise(int i, int[][] y, BaseVector[] x, IGroupDataProvider data)
 {
     int[][] yb = ToBinaryClasses(y, i);
     if (ranker == null || groupWiseNfeatures[i] >= x[0].Length){
         return classifier.Train(x, yb, 2, classifierParam, 1);
     }
     int[] o = ranker.Rank(x, yb, 2, rankerParam, data, 1);
     int[] inds = nfeatures < o.Length ? ArrayUtils.SubArray(o, groupWiseNfeatures[i]) : o;
     return new ClassificationOnSubFeatures(classifier.Train(ExtractFeatures(x, inds), yb, 2, classifierParam, 1), inds);
 }
Exemplo n.º 27
0
 public override Parameters GetParameters(IGroupDataProvider data)
 {
     return new Parameters(new Parameter[]{new DoubleParam("s0", 0){Help = s0Help}});
 }
Exemplo n.º 28
0
 public UserService(IUserDataProvider userDataProvider, IGroupDataProvider groupDataProvider)
 {
     _userDataProvider  = userDataProvider;
     _groupDataProvider = groupDataProvider;
 }
 public int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data, int nthreads)
 {
     return(Rank(x, y, ngroups, param, data, nthreads, null));
 }
 public override Parameters GetParameters(IGroupDataProvider data)
 {
     return new Parameters(new Parameter[]{new DoubleParam("C", 100){Help = SvmClassification.cHelp}});
 }
Exemplo n.º 31
0
        public ClassificationModel TrainGroupWise(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data,
                                                  int nthreads)
        {
            ClassificationModel[] c  = new ClassificationModel[ngroups];
            ThreadDistributor     td = new ThreadDistributor(nthreads, ngroups, i => { c[i] = TrainGroupWise(i, y, x, data); });

            td.Start();
            return(new GroupWiseClassifier(c));
        }
Exemplo n.º 32
0
 public ClassificationModel Train(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data, int nthreads)
 {
     return(Train(x, y, ngroups, data, nthreads, null));
 }
Exemplo n.º 33
0
        public void Initialize(IConfigSource config)
        {
            IConfig groupsConfig = config.Configs["Groups"];

            if (groupsConfig == null)
            {
                // Do not run this module by default.
                return;
            }
            else
            {
                m_groupsEnabled = groupsConfig.GetBoolean("Enabled", false);
                if (!m_groupsEnabled)
                {
                    return;
                }

                if (groupsConfig.GetString("Module", "Default") != "FlexiGroups")
                {
                    m_groupsEnabled = false;

                    return;
                }

                m_log.Info("[GROUPS]: Initializing FlexiGroups");

                m_groupData = ProviderFactory.GetProviderFromConfigName(m_log, groupsConfig, groupsConfig.GetString("Provider"));


                m_groupNoticesEnabled   = groupsConfig.GetBoolean("XmlRpcNoticesEnabled", true);
                m_debugEnabled          = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true);
            }
        }
Exemplo n.º 34
0
        public override int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data,
                                   int nthreads, Action <double> reportProgress)
        {
            int nfeatures = x[0].Length;

            int[][]    yy    = RearrangeGroups(y, ngroups);
            double[][] score = new double[ngroups][];
            for (int k = 0; k < ngroups; k++)
            {
                score[k] = new double[nfeatures];
            }
            for (int i = 0; i < nfeatures; i++)
            {
                double[] xx = new double[x.Length];
                for (int j = 0; j < xx.Length; j++)
                {
                    xx[j] = x[j][i];
                }
                double[] singleFeatureScores = CalcGolubScore(xx, yy, ngroups);
                for (int c = 0; c < ngroups; ++c)
                {
                    score[c][i] = singleFeatureScores[c];
                }
            }
            return(CombineRankedFeaturesLists(nfeatures, score));
        }
 public abstract Parameters GetParameters(IGroupDataProvider data);
 public abstract int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data,
                            int nthreads, Action <double> reportProgress);
Exemplo n.º 37
0
 public ClassificationModel TrainGlobal(BaseVector[] x, int[][] y, int ngroups, IGroupDataProvider data, int nthreads,
                                        Action <double> reportProgress)
 {
     if (ranker == null || nfeatures >= x[0].Length)
     {
         return(classifier.Train(x, y, ngroups, classifierParam, nthreads, reportProgress));
     }
     int[] o    = ranker.Rank(x, y, ngroups, rankerParam, data, nthreads);
     int[] inds = nfeatures < o.Length ? ArrayUtils.SubArray(o, nfeatures) : o;
     return
         (new ClassificationOnSubFeatures(classifier.Train(ExtractFeatures(x, inds), y, ngroups, classifierParam, nthreads),
                                          inds));
 }
Exemplo n.º 38
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public GroupFacade()
 {
     groupData = ClassFactory.GetIGroupDataProvider();
 }
Exemplo n.º 39
0
 public GroupService(IGroupDataProvider groupDataProvider)
 {
     _groupDataProvider = groupDataProvider;
 }
 public Parameters GetParameters(IGroupDataProvider data)
 {
     return new Parameters();
 }
Exemplo n.º 41
0
        public override int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data,
                                   int nthreads, Action <double> reportProgress)
        {
            double s0        = param.GetParam <double>("s0").Value;
            int    nfeatures = x[0].Length;

            int[][]  yy = RearrangeGroups(y, ngroups);
            double[] s  = new double[nfeatures];
            for (int i = 0; i < nfeatures; i++)
            {
                double[] xx = new double[x.Length];
                for (int j = 0; j < xx.Length; j++)
                {
                    xx[j] = x[j][i];
                }
                s[i] = CalcPvalue(xx, yy, ngroups, s0);
            }
            return(ArrayUtils.Order(s));
        }
        public override int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data,
                                   int nthreads, Action <double> reportProgress)
        {
            SvmParameter sp = new SvmParameter {
                kernelFunction = new LinearKernelFunction(),
                svmType        = SvmType.CSvc,
                c = param.GetParam <double>("C").Value
            };

            bool[]       invert;
            SvmProblem[] problems   = CreateProblems(x, y, ngroups, out invert);
            int[][]      rankedSets = new int[problems.Length][];
            for (int i = 0; i < problems.Length; ++i)
            {
                rankedSets[i] = RankBinary(problems[i], sp);
            }
            return(CombineRankedFeaturesLists(rankedSets));
        }
 public abstract int[] Rank(BaseVector[] x, double[] y, Parameters param, IGroupDataProvider data, int nthreads);