Ejemplo n.º 1
0
        public int CompareTo(object obj)
        {
            ItemsetBasic other = (ItemsetBasic)obj;

            for (int loop = 0; (loop < Count) && (loop < other.Count); loop++)
            {
                int val, otherVal;
                val      = GetItem(loop);
                otherVal = other.GetItem(loop);

                if (val > otherVal)
                {
                    return(1);
                }

                if (val < otherVal)
                {
                    return(-1);
                }
            }

            if (other.Count > Count)
            {
                return(-1);
            }

            if (other.Count < Count)
            {
                return(1);
            }

            return(0);
        }
Ejemplo n.º 2
0
        public void WriteResults(string dataFileName, Dataset dataset)
        {
            // Get columns
            int[] columns = new int[_itemset.Count];
            for (int i = 0; i < _itemset.Count; i++)
            {
                columns[i] = _itemset.GetItem(i);
            }

            // Get rows
            Utils.FastSparseBitArray rowsBits = _itemset.GetTransactions();
            int[] rows    = new int[_itemset.support];
            int   rowsPos = 0;

            for (int i = 0; i < dataset.RowCount; i++)
            {
                if (rowsBits.Get(i) == true)
                {
                    rows[rowsPos] = i;
                    rowsPos++;
                }
            }

            Dataset      subMatrix = dataset.GetSubMatrix(columns, rows);
            StreamWriter sw        = null;

            try
            {
                sw = new StreamWriter(dataFileName, false);
                subMatrix.SaveFile(sw);
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }