Example #1
0
 private static double AverageInterDissimilar(double[] currInput, ClusterItem[] cluster, Distance distance)
 {
     double[] d = new double[cluster.Length];
     for (int i = 0; i < d.Length; i++)
     {
         d[i] = distance.Similarity(currInput, cluster[i].InputVector);
     }
     return(d.Average());
 }
Example #2
0
 private static double AverageDissimilar(double[] currInput, ClusterItem[] cluster, Distance distance)
 {
     double[] d = new double[cluster.Length];
     for (int i = 0; i < d.Length; i++)
     {
         d[i] = distance.Similarity(currInput, cluster[i].InputVector);
     }
     return(d.Sum() / (d.Length - 1)); // remove one element => itself
 }
Example #3
0
        public static double WithinClusterVariance(ClusterItem[][] clusters, double[][] centroids, int numSamples, Distance distance)
        {
            double var = 0;

            for (int i = 0; i < clusters.Length; i++)
            {
                for (int j = 0; j < clusters[i].Length; j++)
                {
                    var += distance.Similarity(clusters[i][j].InputVector, centroids[clusters[i][j].Label]);
                }
            }
            var = var / numSamples * 1.0;
            return(var);
        }