示例#1
0
 private static int CompareFuzzySets(FuzzySet fSet1, FuzzySet fSet2)
 {
     if (fSet1.FX < fSet2.FX)
     {
         return(1);
     }
     else if (fSet1.FX == fSet2.FX)
     {
         return(0);
     }
     else
     {
         return(-1);
     }
 }
示例#2
0
        private List <FuzzySet> GetDescendants(FuzzySet parent)
        {
            List <FuzzySet> descendants = new List <FuzzySet>();

            if (parent.LeftChild != null)
            {
                descendants.Add(parent.LeftChild);
                descendants.AddRange(GetDescendants(parent.LeftChild));
            }

            if (parent.RightChild != null)
            {
                descendants.Add(parent.RightChild);
                descendants.AddRange(GetDescendants(parent.RightChild));
            }
            return(descendants);
        }
示例#3
0
        public FuzzySet(List <WaveletPacket> packetList, double r, FuzzySet parent = null)
        {
            List <int> dataLength = packetList.Select(packet => packet.Coefficients.Length).Distinct().ToList();

            if (dataLength.Count != 1)
            {
                throw new ArgumentException("Training packet lengths must match to perform fuzzy c-means");
            }

            Parent             = parent;
            Sibling            = null;
            R                  = r;
            DecompositionLevel = packetList[0].DecompositionLevel;
            SubspaceIndex      = packetList[0].SubspaceIndex;

            // if there are any children then build the child nodes
            if (packetList[0].LeftChild != null)
            {
                List <WaveletPacket> leftChildren  = packetList.Select(packet => packet.LeftChild).ToList();
                List <WaveletPacket> rightChildren = packetList.Select(packet => packet.RightChild).ToList();
                LeftChild          = new FuzzySet(leftChildren, r, this);
                RightChild         = new FuzzySet(rightChildren, r, this);
                LeftChild.Sibling  = RightChild;
                RightChild.Sibling = LeftChild;
            }

            // calculate standard deviations for each feature in this subspace
            List <double> standardDeviations = GetStandardDeviations(packetList);

            // calculate the mean for each user (class)
            Dictionary <String, List <double> > means = GetMeans(packetList);

            // determine features to exclude (store index list of excluded features)
            List <int> exclusionCriterion = ExcludionCriterion(packetList, means, standardDeviations);

            // using list of excluded feature calculate the fuzzy c-means clustering membership allocation
            FX = CalculateFuzzyMembershipCriterion(packetList, means, standardDeviations, exclusionCriterion);
        }
示例#4
0
        private List <FuzzySet> GetFuzzySetList(FuzzySet parent = null)
        {
            if (parent == null)
            {
                parent = this;
            }

            List <FuzzySet> fsList = new List <FuzzySet>
            {
                parent
            };

            if (parent.LeftChild != null)
            {
                fsList.AddRange(GetFuzzySetList(parent.LeftChild));
            }

            if (parent.RightChild != null)
            {
                fsList.AddRange(GetFuzzySetList(parent.RightChild));
            }
            return(fsList);
        }
示例#5
0
        public List <FuzzySet> GetOptimalFuzzySetList()
        {
            List <FuzzySet> fsList = GetFuzzySetList();

            // sort fsList in descending order according to fuzzy membership criterion
            fsList.Sort(CompareFuzzySets);

            List <FuzzySet> optimalDecomposition = new List <FuzzySet>();

            while (fsList.Count > 0)
            {
                // move the first subspace into the optimal decomposition
                FuzzySet next = fsList.First();
                optimalDecomposition.Add(next);
                fsList.RemoveAt(0);

                // remove all remaining ancestors or decendents of this subspace
                List <FuzzySet> ancestors   = next.GetAncestors(next.Parent);
                List <FuzzySet> descendants = next.GetDescendants(next);
                fsList.RemoveAll(fs => ancestors.Contains(fs));
                fsList.RemoveAll(fs => descendants.Contains(fs));
            }
            return(optimalDecomposition);
        }