Exemple #1
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();
        }
Exemple #2
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);
        }
Exemple #3
0
        public void Diversity_SS_Is_Awesome()
        {
            ISelectionStrategyFactory   ssFactory    = new SelectionStrategyFactory();
            Dictionary <string, string> ssParameters = new Dictionary <string, string>();

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

            object[][] labelled = new object[][]
            {
                new object[] { 1, 5, 5, 5 }
            };
            object[][] unlabelled = new object[][]
            {
                new object[] { 2, 6, 5, 6 },
                new object[] { 3, 8, 18, 218 }
            };

            var selected = diversity.GenerateQuery(labelled, unlabelled, new TestDataFormat(), 1).Result;

            Assert.AreEqual(selected.Count, 1);
            Assert.AreEqual(selected.First(), 3);
        }