// /// <summary> // /// Gets the value of information. // /// </summary> // /// <value>The value of information.</value> // public double[] GetValueOfInformation() // { // double jall = JAll(); // return Unlabelled.Select(index => VOI(jall, index)).ToArray(); // } /// <summary> /// Gets the argument maxising the Value of information. /// </summary> /// <param name="activityPosteriors">Activity posteriors.</param> /// <param name="priors">Priors.</param> /// <param name="argMax">Argument max.</param> /// <param name="maxVal">Max value.</param> public override void GetArgMaxVOI(Bernoulli[] activityPosteriors, Marginals priors, out int argMax, out double maxVal) { hypothesisActivityPosteriors = activityPosteriors.Select(ia => new Bernoulli(ia)).ToArray(); double jall = JAll(); var unlabelled = Unlabelled.ToArray(); argMax = -1; maxVal = Reversed ? double.PositiveInfinity : double.NegativeInfinity; var signs = new double[unlabelled.Length]; var vois = new double[unlabelled.Length]; for (int i = 0; i < unlabelled.Length; i++) { var index = unlabelled[i]; vois[i] = VOI(jall, index, activityPosteriors, priors); signs[i] = Math.Sign(vois[i]) / 2.0 + 0.5; //Console.Write( "." ); //Console.WriteLine( "y_true: {0}", labels[0][ind] ); //Console.WriteLine( "y_hat: {0}", probs[ind] ); //Console.WriteLine( "VOJ_{0}: {1}", ind, voi ); //Console.WriteLine(); if (Reversed) { if (vois[i] < maxVal || argMax < 0) { maxVal = vois[i]; argMax = index; } } else { if (vois[i] > maxVal || argMax < 0) { maxVal = vois[i]; argMax = index; } } } //Console.WriteLine(); //Console.WriteLine( "\n+ivity: {0}", signs.Average() ); }
/// <summary> /// Gets the argument maxising the Value of information. /// </summary> /// <param name="activityPosteriors">Activity posteriors.</param> /// <param name="priors">Priors.</param> /// <param name="argMax">Argument max.</param> /// <param name="maxVal">Max value.</param> public override void GetArgMaxVOI(Bernoulli[] activityPosteriors, Marginals priors, out int argMax, out double maxVal) { argMax = Unlabelled.ToArray()[random.Next(Unlabelled.Count)]; maxVal = 0.0; }