Beispiel #1
0
        public void Radius_PointsWithDifferentXY_SameRadius()
        {
            var c1 = new OutlierCoreMicroCluster <EuclideanPoint>(_singletonClusterZero, _simFunc);
            var c2 = new OutlierCoreMicroCluster <EuclideanPoint>(_singletonCluster500, _simFunc);

            Assert.That(c1.Radius(_currentTime), Is.EqualTo(c2.Radius(_currentTime)));
        }
Beispiel #2
0
        public void Weight_SameTime_SameWeight()
        {
            var pcmc = new OutlierCoreMicroCluster <EuclideanPoint>(_fullCluster, _simFunc);
            var w1   = pcmc.Weight(_currentTime);
            var w2   = pcmc.Weight(_currentTime);

            Assert.That(w1, Is.EqualTo(w2));
        }
Beispiel #3
0
        public void Radius_SameTime_SameRadius()
        {
            var pcmc = new OutlierCoreMicroCluster <EuclideanPoint>(_fullCluster, _simFunc);
            var r1   = pcmc.Radius(_currentTime);
            var r2   = pcmc.Radius(_currentTime);

            Assert.That(r1, Is.EqualTo(r2));
        }
Beispiel #4
0
        /// <summary>
        /// Merges a new point p into the cluster map maintained by the DenStream object.
        /// </summary>
        /// <param name="p">The point to insert</param>
        /// <param name="similarityFunction">Function to determine the distance between two points.</param>
        private void Merge(T p, Func <T, T, float> similarityFunction)
        {
            var successfulInsert = false;
            var t = p.TimeStamp;

            if (_pcmcs.Count() != 0)
            {
                // Find the closest PCMCs
                var clustersWithDistance = _pcmcs
                                           .Select(pcmc => (pcmc, similarityFunction(p, pcmc.Center(t))))
                                           .ToList();

                clustersWithDistance.Sort((x, y) => x.Item2.CompareTo(y.Item2));
                var(cluster, _) = clustersWithDistance.First();

                // Try to insert considering the new radius
                successfulInsert = TryInsert(p, cluster,
                                             newCluster => newCluster.Radius(t) <= EPSILON);
            }

            if (!successfulInsert && _ocmcs.Count() != 0)
            {
                // Find the closest OCMC
                var clustersWithDistance = _ocmcs
                                           .Select(pcmc => (pcmc, similarityFunction(p, pcmc.Center(t))))
                                           .ToList();

                clustersWithDistance.Sort((x, y) => x.Item2.CompareTo(y.Item2));
                var(cluster, _) = clustersWithDistance.First();

                // Try to insert considering the new radius
                successfulInsert = TryInsert(p, cluster,
                                             newCluster => newCluster.Radius(t) <= EPSILON);

                if (successfulInsert)
                {
                    // Check the weight
                    if ((cluster.Weight(t) > BETA * MU) && cluster.Radius(t) <= EPSILON)
                    {
                        // Convert this OCMC into a new PCMC
                        _ocmcs.Remove(cluster);
                        _pcmcs.Add(new PotentialCoreMicroCluster <T>(
                                       cluster.Points,
                                       similarityFunction));
                    }
                }
            }

            if (!successfulInsert)
            {
                var cluster = new OutlierCoreMicroCluster <T>(
                    new[] { p },
                    similarityFunction);

                // Create a new OCMC
                _ocmcs.Add(cluster);
            }
        }
Beispiel #5
0
        public void Weight_TimePassed_SmallerWeight()
        {
            var pcmc = new OutlierCoreMicroCluster <EuclideanPoint>(_fullCluster, _simFunc);
            var w1   = pcmc.Weight(_currentTime);

            _currentTime++;
            var w2 = pcmc.Weight(_currentTime);

            Assert.That(w1, Is.GreaterThan(w2));
        }