Exemple #1
0
        private CentroidVector transform2CentroidVector(DocumentVector documentVector)
        {
            CentroidVector centroid = new CentroidVector();

            foreach (double weight in documentVector.getWeightVector())
            {
                centroid.addWeight(weight);
            }

            return(centroid);
        }
Exemple #2
0
        private List <CentroidVector> randomCentroidVectorList2(List <DocumentVector> vectors)
        {
            List <CentroidVector> centroids = new List <CentroidVector>();
            Random randomSeed = new Random(1);

            for (int index = 0; index < k; index++)
            {
                int            randomIndex    = randomSeed.Next(vectors.Count);
                DocumentVector documentVector = vectors[randomIndex];
                CentroidVector centroid       = new CentroidVector();
                foreach (double weight in documentVector.getWeightVector())
                {
                    centroid.addWeight(weight);
                }
                centroids.Add(centroid);
            }

            return(centroids);
        }
Exemple #3
0
        private List <CentroidVector> randomCentroidVectorList(List <DocumentVector> vectors)
        {
            if (vectors.Count < k)
            {
                Console.WriteLine("Sorry, no more vector to random.");
                return(null);
            }

            List <CentroidVector> centroids = new List <CentroidVector>();
            List <int>            indexs    = CommonUtils.randomSetByFloyd(0, vectors.Count, k);

            foreach (int index in indexs)
            {
                DocumentVector documentVector = vectors[index];
                CentroidVector centroid       = new CentroidVector();
                foreach (double weight in documentVector.getWeightVector())
                {
                    centroid.addWeight(weight);
                }
                centroids.Add(centroid);
            }

            return(centroids);
        }