Exemplo n.º 1
0
        public ClusterMember(IdentifiableDataPoint member, double distance)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }
            if (distance < 0)
            {
                throw new ArgumentException("Distance must be a positive integer", "distance");
            }

            Member   = member;
            Distance = distance;
        }
Exemplo n.º 2
0
        public Cluster FindCluster(IdentifiableDataPoint dataPoint)
        {
            foreach (var cluster in Clusters)
            {
                foreach (var clusterMember in cluster.Members)
                {
                    if (clusterMember.Member.Equals(dataPoint))
                    {
                        return(cluster);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        private static DataConversionResult TaskRunner(object arg)
        {
            TaskRunnerArgumentSet options = arg as TaskRunnerArgumentSet;

            DistanceMatrix          distanceMatrix = new DistanceMatrix(options.Data, options.DistanceMetric);
            MultiDimensionalScaling mds            = new MultiDimensionalScaling(distanceMatrix);
            Matrix coordinateMatrix = mds.Calculate();

            List <DrawableDataPoint> drawableDataPoints = new List <DrawableDataPoint>();

            for (int col = 0; col < coordinateMatrix.Columns; col++)
            {
                double x = coordinateMatrix[0, col];
                double y = coordinateMatrix[1, col];
                IdentifiableDataPoint originalDataPoint = options.Data[col];
                drawableDataPoints.Add(new DrawableDataPoint(originalDataPoint, x, y));
            }

            var dataPoints = drawableDataPoints.OrderBy(d => d.Group).ToList();

            return(new DataConversionResult(dataPoints, distanceMatrix));
        }
        public IdentifiableDataPointCollection Generate()
        {
            distanceMetric = new EuclideanMetric();
            dataCollection = new IdentifiableDataPointCollection();

            int id         = 0;
            int dimentions = 5;

            dataCollection = new IdentifiableDataPointCollection();
            for (int i = 0; i < collectionSize; i++)
            {
                dataPoint = new IdentifiableDataPoint(++id, dimentions);
                dataCollection.AddItem(dataPoint);
            }

            for (int i = 0; i < collectionSize; i++)
            {
                if ((i % 10) < 9)
                {
                    dataCollection[i].AddAttribute("Gender", 1d);
                }
                else
                {
                    dataCollection[i].AddAttribute("Gender", 0d);
                }

                if ((i % 10) < 4)
                {
                    dataCollection[i].AddAttribute("Income", 1d);
                }
                else if ((i % 10) > 8)
                {
                    dataCollection[i].AddAttribute("Income", 0.1429);
                }
                else
                {
                    dataCollection[i].AddAttribute("Income", 0.2858d);
                }

                dataCollection[i].AddAttribute("Age", 0.16d);

                if ((i % 10) < 2 || (i % 10) > 3)
                {
                    dataCollection[i].AddAttribute("Purchase", 1d);
                }
                else
                {
                    dataCollection[i].AddAttribute("Purchase", 0.5d);
                }

                if ((i % 10) < 2)
                {
                    dataCollection[i].AddAttribute("Control", 0.5d);
                }
                else if ((i % 10) > 8)
                {
                    dataCollection[i].AddAttribute("Control", 0d);
                }
                else
                {
                    dataCollection[i].AddAttribute("Control", 1d);
                }
            }
            return(dataCollection);
        }