Esempio n. 1
0
        private double CalcSumOfLocalReachabilityDensity(LocalOutlierFactorPoint person)
        {
            double sum = 0;

            foreach (var neighbour in person.DistanceToNeighbours)
            {
                sum += resultList[neighbour.Item1].LocalReachabilityDensity;
            }

            return(sum);
        }
Esempio n. 2
0
        private double CalcSumOfReachDistK(LocalOutlierFactorPoint person)
        {
            double sum = 0;

            double KDistNeighbour;


            foreach (var neighbour in person.DistanceToNeighbours)
            {
                KDistNeighbour = resultList[neighbour.Item1].KDistance;

                sum += Math.Max(KDistNeighbour, neighbour.Item2);
            }

            return(sum);
        }
Esempio n. 3
0
        private void DistanceToKthNeighbour()
        {
            int lengthDim1 = distanceMatrix.Rows;
            int lengthDim2 = distanceMatrix.Columns;

            for (int row = 0; row < lengthDim1; row++)
            {
                LocalOutlierFactorPoint person = new LocalOutlierFactorPoint();
                for (int col = 0; col < lengthDim2; col++)
                {
                    if (row != col)
                    {
                        person.DistanceToNeighbours.Add(Tuple.Create(col, distanceMatrix[row, col]));
                    }
                }

                person.DistanceToNeighbours.Sort((x, y) => x.Item2.CompareTo(y.Item2));
                int neighboursToTake = kNeighbours;

                if (person.DistanceToNeighbours[neighboursToTake - 1].Item2 == person.DistanceToNeighbours[neighboursToTake].Item2 ||
                    person.DistanceToNeighbours[neighboursToTake - 2].Item2 == person.DistanceToNeighbours[neighboursToTake - 1].Item2)
                {
                    do
                    {
                        neighboursToTake++;
                    } while ((neighboursToTake < (lengthDim1 - 1)) &&
                             (person.DistanceToNeighbours[neighboursToTake - 1].Item2 ==
                              person.DistanceToNeighbours[neighboursToTake].Item2));
                    neighboursToTake++;
                }

                person.DistanceToNeighbours = person.DistanceToNeighbours.Take(neighboursToTake).ToList();

                person.KDistance = person.DistanceToNeighbours[person.DistanceToNeighbours.Count - 1].Item2;
                person.ID        = row;

                resultList.Add(person);
            }
        }