Ejemplo n.º 1
0
        public List <KMeansEntity> MapAllData(List <ExternalEntity> entities)
        {
            var arguments = entities.SelectMany(e => e.Data.Select(kvp => kvp.Key)).Distinct().ToList();

            //var argumentsList = new List<string>();
            //foreach(var argumentPair in entities.SelectMany(entity => entity.Data.Where(argumentPair => !argumentsList.Contains(argumentPair.Key))))
            //{
            //    argumentsList.Add(argumentPair.Key);
            //}

            var result = new List <KMeansEntity>();

            foreach (var entity in entities)
            {
                var mappedEntity = new KMeansEntity
                {
                    Label     = entity.Label,
                    Arguments = new List <double>()
                };

                foreach (var argument in arguments)
                {
                    double value;
                    mappedEntity.Arguments.Add(entity.Data.TryGetValue(argument, out value) ? value : 0);
                }

                result.Add(mappedEntity);
            }

            return(result);
        }
Ejemplo n.º 2
0
        private void DrawPoint(KMeansEntity entity, int size = 4)
        {
            var color = GetColor((int)entity.ClusterId);

            using (var graphic = MainCanvas.CreateGraphics())
            {
                var pt = new Point((int)entity.Arguments[0] + center.x, -(int)entity.Arguments[1] + center.y);
                using (Brush b = new SolidBrush(color))
                {
                    graphic.FillEllipse(b, pt.X - size / 2, pt.Y - size / 2, size, size);
                }
            }
        }
Ejemplo n.º 3
0
        public void RegisterInitialData(List <KMeansEntity> data)
        {
            this.data = new List <KMeansEntity>();
            foreach (var point in data)
            {
                var registeredPoint = new KMeansEntity
                {
                    ClusterId = point.ClusterId
                };

                this.data.Add(registeredPoint);
            }
        }