/// <summary> /// Transfer a number of instances from the unlabelled to the labelled set for the given resident. /// </summary> /// <param name="resident">The index of the resident.</param> /// <param name="num">The number to transfer.</param> public void Transfer(int resident, int num) { if (num == 0) { return; } var rng = new Random(); for (int tt = 0; tt < 2; ++tt) { for (int nn = 0; nn < num; ++nn) { var uinds = Unlabelled.OrderBy(x => rng.Next()); foreach (var ind in uinds) { if (dataSet.Labels[0][ind] == (tt == 0 ? false : true)) { Unlabelled.Remove(ind); Labelled.Add(ind); break; } } } } }
public override void GetArgMaxVOI(MicrosoftResearch.Infer.Distributions.Bernoulli[] activityPosteriors, Marginals priors, out int argMax, out double maxVal) { CalculateProbabilities(priors); var evidences = new Dictionary <int, double>(); var sortedUnlabelled = Unlabelled .OrderBy(_ => rng.NextDouble()) .OrderBy(uu => Math.Abs(hypothesisActivityPosteriors[uu].GetMean() - 0.5)) .Take(10) ; foreach (var index in sortedUnlabelled) { var evidence = ExpectedEvidence(index, priors); evidences.Add(index, evidence); } var ordered = evidences.OrderBy(ee => ee.Value); argMax = ordered.First().Key; maxVal = ordered.First().Value; }