Example #1
0
        public override string ToString()
        {
            string str = "";

            foreach (SortedList lengthResult in _results.Values)
            {
                MineResult first = (MineResult)lengthResult.GetByIndex(0);
                str += "**********************\n";
                str += "Length " + first.Length + "\n";
                foreach (MineResult mineResult in lengthResult.Values)
                {
                    str += mineResult.ToString() + "\n";
                }
            }

            return(str);
        }
Example #2
0
        public void WriteResults(Dataset dataset)
        {
            string       targetFileName = Path.Combine(_targetDirectory, "mining-results.txt");
            StreamWriter sr             = null;

            try
            {
                if (Directory.Exists(_targetDirectory) == false)
                {
                    Directory.CreateDirectory(_targetDirectory);
                }

                sr = new StreamWriter(targetFileName, false);

                foreach (SortedList lengthResult in _results.Values)
                {
                    MineResult first         = (MineResult)lengthResult.GetByIndex(0);
                    int        patternLength = first.Length;
                    sr.WriteLine("**********************");
                    sr.WriteLine("Length " + patternLength);

                    int lengthCount = 0;
                    foreach (MineResult mineResult in lengthResult.Values)
                    {
                        lengthCount++;
                        string dataFileName = string.Format("len-{0}-serial-{1}.txt",
                                                            patternLength,
                                                            lengthCount);
                        dataFileName = Path.Combine(_targetDirectory, dataFileName);

                        sr.WriteLine(mineResult.ToString() + ", Data file: " + dataFileName);

                        mineResult.WriteResults(dataFileName, dataset);
                    }
                }
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }
Example #3
0
        public void Add(ItemsetBasic itemset)
        {
            _totalItemsetsCount++;

            if (_writeAllResults == true)
            {
                _allResultsStream.WriteLine(itemset.ToSimpleString());
            }

            if (_results.ContainsKey(itemset.Count) == false)
            {
                _results.Add(itemset.Count, new SortedList());
            }

            SortedList lengthResult = (SortedList)_results[itemset.Count];

            // If the queue of current length is full - check if the new item
            // should be inseted
            if (lengthResult.Count >= _maxSavedItems)
            {
                MineResult mineResult = (MineResult)lengthResult.GetByIndex(0);
                if (itemset.support <= mineResult.Support)
                {
                    return;
                }
            }

            MineResult result = new MineResult(itemset);
            double     key    = (double)itemset.support;

            while (lengthResult.ContainsKey(key))
            {
                key += 0.00001;
            }
            lengthResult.Add(key, result);

            while (lengthResult.Count > _maxSavedItems)
            {
                lengthResult.RemoveAt(0);
            }
        }
Example #4
0
        public int CompareTo(object o)
        {
            MineResult other = (MineResult)o;

            if (this.Length < other.Length)
            {
                return(-1);
            }
            else if (this.Length > other.Length)
            {
                return(1);
            }
            else if (this.Support < other.Support)
            {
                return(-1);
            }
            else if (this.Support > other.Support)
            {
                return(1);
            }

            return(0);
        }