Exemple #1
0
        public void Start()
        {
            Random rand = new Random();

            // On commence par sélectionner un "point" au hasard pour chaque cluster
            for (int i = 0; i < m_clusters; i++)
            {
                Clusters.Add(new Cluster(
                                 i,
                                 new Vector4(
                                     rand.NextFloat(0.0f, 0.8f),
                                     rand.NextFloat(0.0f, 0.8f),
                                     rand.NextFloat(0.0f, 0.8F),
                                     1.0f),
                                 new Vector3(rand.NextFloat(-1.0f, 1.0f), rand.NextFloat(-1.0f, 1.0f), 0.0f)));

                Centroids.Add(new Entity(Entity));
                MeshRenderer meshrenderer = Centroids[i].AddComponent <MeshRenderer>();
                meshrenderer.material_ = new MaterialDX11();
                meshrenderer.material_.SetMainColor(Clusters[i].Color);
                meshrenderer.model_ = Quad.GetMesh();
                Centroids[i].transform_.SetScale(0.05f, 0.05f, 1.0f);
            }

            m_start = true;
        }
 public void UpdateCentroids()  // обновление списка центроидов - запись центроидов из каждого кластера в Centroids
 {
     Centroids.Clear();
     foreach (var c in Clusters)
     {
         Centroids.Add(c.Centroid);
     }
 }
Exemple #3
0
 public void setCentroid(double[] cents)
 {
     if (cents.Length != Centroids.Dimension)
     {
         throw new System.IndexOutOfRangeException("[KMEANS]: SET CENTROID HAS INVALID DIMENSION");
     }
     Centroids.Add(cents);
 }
Exemple #4
0
 private void GenerateCentroids()
 {
     for (int i = 0; i < this.Clusters; i++)
     {
         var randomVector = GetRandomVector();
         if (this.Centroids.FirstOrDefault(q => q.Data == randomVector) == null)
         {
             Centroids.Add(new Centroid(randomVector, i));
         }
     }
 }
        public void AddCentroid()
        {
            GameObject newRoidObj = _graphController.GenerateCentroid();

            if (verbose)
            {
                Debug.Log("add centroid Cluster.Centroid created");
            }
            Centroids.Add(new Centroid(newRoidObj, this, _columnTypes, Centroids));
            if (verbose)
            {
                Debug.Log("add centroid Cluster.Centroid added to list");
            }
            ClusterCount++;
        }
Exemple #6
0
        public void GenrateCentroids(int _centoridsNumber)
        {
            MaxCentroidShift = 1;
            Centroids.Clear();
            _excludedSampleIndexes.Clear();
            for (int i = 0; i < _centoridsNumber; i++)
            {
                int choosenSampleIndex;

                do
                {
                    choosenSampleIndex = Random.Next(SamplePoints.Count);
                } while (_excludedSampleIndexes.Contains(choosenSampleIndex));

                Centroids.Add(new Centroid(SamplePoints[choosenSampleIndex]));
                _excludedSampleIndexes.Add(choosenSampleIndex);
            }
        }
Exemple #7
0
        public void GenerateCentroids()
        {
            Centroids.Clear();
            List <int> excludedSampleIndexes = new List <int>();

            for (int i = 0; i < HiddenNeuronsNumber; i++)
            {
                int choosenSampleIndex;

                do
                {
                    choosenSampleIndex = Random.Next(SamplePoints.Count);
                } while (excludedSampleIndexes.Contains(choosenSampleIndex));

                Centroids.Add(
                    new Centroid(choosenSampleIndex, SamplePoints[choosenSampleIndex]));
                excludedSampleIndexes.Add(choosenSampleIndex);
            }
        }