Beispiel #1
0
        public static async Task <LabellingJob> CreateLabellingJob(ILabellingJobRepository jobRepo,
                                                                   IJobIterationRepository iterationRepo, IDataStore dataStore, IPredictiveModel model,
                                                                   ISelectionStrategy selectionStrategy, IStoppingCriterion stoppingCriterion,
                                                                   ISeedingStrategy seedingStrategy, IJobIterationNotifier notifier, IDataFormat dataFormat,
                                                                   int batchSize, int seedSize)
        {
            var job = new LabellingJob()
            {
                JobID             = Guid.NewGuid(),
                DataStore         = dataStore,
                Model             = model,
                SelectionStrategy = selectionStrategy,
                StoppingCriterion = stoppingCriterion,
                DataFormat        = dataFormat,
                BatchSize         = batchSize
            };

            await jobRepo.Add(job);

            JobIteration iteration = new JobIteration()
            {
                JobID = job.JobID,
                PreviousIterationID = Guid.Empty,
                QueryIDs            = (await seedingStrategy.GetQueryIDs(dataStore, dataFormat, seedSize)).ToArray()
            };

            await iterationRepo.Add(iteration);

            notifier.OnLabelsRequested(iteration);

            return(job);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ILabellingJobRepository jobRepo       = new LabellingJobRepositoryFactory().Create();
            IJobIterationRepository iterationRepo = new JobIterationRepositoryFactory().Create();

            IDataStore dataStore = new DataStoreFactory().CreateOrReplace("TestJack", DataFormats.CIFAR10.GetFormat());

            IPredictiveModelFactory     modelFactory    = new PredictiveModelFactory();
            Dictionary <string, string> modelParameters = new Dictionary <string, string>();

            modelParameters.Add("k", "15");
            modelParameters.Add("numberOfClasses", "10");
            IPredictiveModel model = modelFactory.Create("KNearestNeighbour", modelParameters);

            ISelectionStrategyFactory   ssFactory    = new SelectionStrategyFactory();
            Dictionary <string, string> ssParameters = new Dictionary <string, string>();

            ssParameters.Add("diversityFunction", DiversityFunctions.COSINE_DISTANCE.ToString());
            ISelectionStrategy selectionStrategy = ssFactory.Create("DiversitySelectionStrategy", ssParameters);

            IStoppingCriterionFactory   scFactory    = new StoppingCriterionFactory();
            Dictionary <string, string> scParameters = new Dictionary <string, string>();

            scParameters.Add("maxLabels", "15");
            IStoppingCriterion stoppingCriterion = scFactory.Create("LabelLimit", scParameters);

            ISeedingStrategyFactory     seedingFactory    = new SeedingStrategyFactory();
            Dictionary <string, string> seedingParameters = new Dictionary <string, string>();

            seedingParameters.Add("randomSeed", "15");
            ISeedingStrategy seedingStrategy = seedingFactory.Create("RandomSeedingStrategy", seedingParameters);

            IJobIterationNotifier notifier   = new JobIterationNotifierFactory().Create();
            IDataFormat           dataFormat = DataFormats.CIFAR10.GetFormat();
        }
Beispiel #3
0
        public static async Task <LabellingJob> RunCreateJobTest()
        {
            ILabellingJobRepository jobRepo       = new LabellingJobRepositoryFactory().Create();
            IJobIterationRepository iterationRepo = new JobIterationRepositoryFactory().Create();

            IDataParser parser     = new DataParserFactory().Create(DataFormats.CIFAR10);
            IDataFormat dataFormat = parser.Format;
            IDataStore  dataStore  = new DataStoreFactory().CreateOrConnect("TestJack", dataFormat);

            IPredictiveModelFactory modelFactory = new PredictiveModelFactory();
            IPredictiveModel        model        = modelFactory.Create("LinearRegression");

            ISelectionStrategyFactory   ssFactory    = new SelectionStrategyFactory();
            Dictionary <string, string> ssParameters = new Dictionary <string, string>();

            ssParameters.Add("randomSeed", "15");
            ISelectionStrategy selectionStrategy = ssFactory.Create("RandomSelectionStrategy", ssParameters);

            IStoppingCriterionFactory   scFactory    = new StoppingCriterionFactory();
            Dictionary <string, string> scParameters = new Dictionary <string, string>();

            scParameters.Add("maxLabels", "15");
            IStoppingCriterion stoppingCriterion = scFactory.Create("LabelLimit", scParameters);

            ISeedingStrategyFactory     seedingFactory    = new SeedingStrategyFactory();
            Dictionary <string, string> seedingParameters = new Dictionary <string, string>();

            seedingParameters.Add("randomSeed", "15");
            ISeedingStrategy seedingStrategy = seedingFactory.Create("RandomSeedingStrategy", seedingParameters);

            IJobIterationNotifier notifier = new JobIterationNotifierFactory().Create();

            int batchSize = 3;
            int seedSize  = 3;

            var job = await ActiveLoop.CreateLabellingJob(
                jobRepo : jobRepo,
                iterationRepo : iterationRepo,
                dataStore : dataStore,
                model : model,
                selectionStrategy : selectionStrategy,
                stoppingCriterion : stoppingCriterion,
                seedingStrategy : seedingStrategy,
                notifier : notifier,
                dataFormat : dataFormat,
                batchSize : batchSize,
                seedSize : seedSize);

            return(job);
        }
Beispiel #4
0
        public static async Task <JobIteration> GetSeedIteration(LabellingJob labellingJob, IJobIterationRepository iterationRepo, ISeedingStrategy seedingStrategy, IDataFormat dataFormat)
        {
            IDataStore   ds        = labellingJob.DataStore;
            JobIteration iteration = new JobIteration()
            {
                JobID = labellingJob.JobID,
                PreviousIterationID = Guid.Empty,
                QueryIDs            = (await seedingStrategy.GetQueryIDs(ds, dataFormat, 3)).ToArray()
            };

            await iterationRepo.Add(iteration);

            return(iteration);
        }