public DualCompare(Dataset ds, int support) { int maxItem = ds.GetColumnCount(); //dualStruct = new SortedList(); dualStruct = new ISimpleItemset[maxItem, maxItem]; for (int loopA = 0; loopA < maxItem; loopA++) { for (int loopB = 0; loopB < maxItem; loopB++) { if (loopA != loopB) { Utils.FastSparseBitArray bitArray = ds.BuildBitVector(loopA, loopB); int countElements = bitArray.CountElements(); if (countElements >= support) { ISimpleItemset itemset; //if (ds.RowCount <= 64) // itemset = new ShortSimpleItemset(); //else itemset = new SimpleItemset(); //itemset.AddItem(loopA); //itemset.AddItem(loopB); itemset.SetTransactions(bitArray); //itemset.support = countElements; dualStruct[loopA, loopB] = itemset; } } } } }
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(); } } }