private double Compute3thTerm(double[] weights) { double result = 0; for (int i = 0; i < Set.Segmentations.Count; i++) { for (int j = 0; j < Set.Segmentations.Count; j++) { result += weights[i] * weights[j] * rand.Process(Set.Segmentations[i], Set.Segmentations[j]); } } return(result); }
//Evaluo la segmentacion con las medidas RandIndex, VI and NMI y dejo los resultados en el set. Evaluo contra el mejor ground-truth y el promedio contra todos. private void EvaluateMatrixSegmentation(Segmentation segm) { RandIndexSegSim rand = new RandIndexSegSim(); NMISegSim nmi = new NMISegSim(); VISegSim vi = new VISegSim(); //Calcular el rand double min = double.MaxValue; double ave = 0; double aux = 0; for (int i = 0; i < this.Set.GroundTruths.Count; i++) { aux = 1 - rand.Process(segm, this.Set.GroundTruths[i]); if (aux < min) { min = aux; } ave += aux; } ave = ave / this.Set.GroundTruths.Count; this.Set.Best_RandEvaluation = min; this.Set.Ave_RandEvaluation = ave; //Calcular NMI min = double.MaxValue; ave = 0; aux = 0; for (int i = 0; i < this.Set.GroundTruths.Count; i++) { aux = 1 - nmi.Process(segm, this.Set.GroundTruths[i]); if (aux < min) { min = aux; } ave += aux; } ave = ave / this.Set.GroundTruths.Count; this.Set.Best_NMIEvaluation = min; this.Set.Ave_NMIEvaluation = ave; //Calcular VI min = double.MaxValue; ave = 0; aux = 0; for (int i = 0; i < this.Set.GroundTruths.Count; i++) { aux = vi.Process(segm, this.Set.GroundTruths[i]); if (aux < min) { min = aux; } ave += aux; } ave = ave / this.Set.GroundTruths.Count; this.Set.Best_VIEvaluation = min; this.Set.Ave_VIEvaluation = ave; }
//Evaluo la segmentacion con las medidas RandIndex, VI and NMI y dejo los resultados en el set. Evaluo contra el mejor ground-truth y el promedio contra todos. private void EvaluateMatrixSegmentation(Segmentation segm) { RandIndexSegSim rand = new RandIndexSegSim(); NMISegSim nmi = new NMISegSim(); VISegSim vi = new VISegSim(); //Calcular el rand double min = double.MaxValue; double ave = 0; double aux = 0; for (int i = 0; i < this.Set.GroundTruths.Count; i++) { aux = 1 - rand.Process(segm, this.Set.GroundTruths[i]); if (aux < min) min = aux; ave += aux; } ave = ave / this.Set.GroundTruths.Count; this.Set.Best_RandEvaluation = min; this.Set.Ave_RandEvaluation = ave; //Calcular NMI min = double.MaxValue; ave = 0; aux = 0; for (int i = 0; i < this.Set.GroundTruths.Count; i++) { aux = 1- nmi.Process(segm, this.Set.GroundTruths[i]); if (aux < min) min = aux; ave += aux; } ave = ave / this.Set.GroundTruths.Count; this.Set.Best_NMIEvaluation = min; this.Set.Ave_NMIEvaluation = ave; //Calcular VI min = double.MaxValue; ave = 0; aux = 0; for (int i = 0; i < this.Set.GroundTruths.Count; i++) { aux = vi.Process(segm, this.Set.GroundTruths[i]); if (aux < min) min = aux; ave += aux; } ave = ave / this.Set.GroundTruths.Count; this.Set.Best_VIEvaluation = min; this.Set.Ave_VIEvaluation = ave; }