本文整理汇总了Java中ca.pfv.spmf.algorithms.frequentpatterns.charm.AlgoCharmMFI类的典型用法代码示例。如果您正苦于以下问题:Java AlgoCharmMFI类的具体用法?Java AlgoCharmMFI怎么用?Java AlgoCharmMFI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlgoCharmMFI类属于ca.pfv.spmf.algorithms.frequentpatterns.charm包,在下文中一共展示了AlgoCharmMFI类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mineMaximalFrequentItemsetsCharm
import ca.pfv.spmf.algorithms.frequentpatterns.charm.AlgoCharmMFI; //导入依赖的package包/类
/** Run Charm maximal closed FIM algorithm */
public static SortedMap<Itemset, Integer> mineMaximalFrequentItemsetsCharm(final String dataset,
final String saveFile, final double minSupp) throws IOException {
// Remove transaction duplicates and sort items ascending
final File TMPDB = File.createTempFile("fixed-dataset", ".dat");
dbTool.convert(dataset, TMPDB.getAbsolutePath());
final TransactionDatabase database = new TransactionDatabase();
database.loadFile(TMPDB.getAbsolutePath());
final AlgoCharm_Bitset algo_closed = new AlgoCharm_Bitset();
final Itemsets closed_patterns = algo_closed.runAlgorithm(null, database, minSupp, true, 10000);
algo_closed.printStats();
final AlgoCharmMFI algo = new AlgoCharmMFI();
final Itemsets patterns = algo.runAlgorithm(saveFile, closed_patterns);
algo.printStats(database.size());
return toMap(patterns);
}
示例2: main
import ca.pfv.spmf.algorithms.frequentpatterns.charm.AlgoCharmMFI; //导入依赖的package包/类
@Test
public void main() {
NoExceptionAssertion.assertDoesNotThrow(() -> {
// the file paths
String input = "contextPasquier99.txt"; // the database
// minimum support
double minsup = 0.4; // means a minsup of 2 transaction (we used a relative support)
// Loading the binary context
TransactionDatabase database = new TransactionDatabase();
try {
database.loadFile(input);
} catch (IOException e) {
e.printStackTrace();
}
database.printDatabase();
// Applying the Charm algorithm
AlgoCharm_Bitset algo = new AlgoCharm_Bitset();
algo.runAlgorithm(null, database, minsup, false, 100000);
// if you change use "true" in the line above, CHARM will use
// a triangular matrix for counting support of itemsets of size 2.
// For some datasets it should make the algorithm faster.
// Run CHARM MFI
AlgoCharmMFI algo2 = new AlgoCharmMFI();
algo2.runAlgorithm(null, algo.getClosedItemsets());
// Code to browse the itemsets in memory
System.out.println(" ===== MAXIMAL ITEMSETS FOUND ====");
Itemsets itemsets = algo2.getItemsets();
for (List<Itemset> level : itemsets.getLevels()) {
for (Itemset itemset : level) {
for (Integer item : itemset.itemset) {
System.out.print(item);
}
System.out.println(" support " + itemset.getAbsoluteSupport());
}
}
// Print statistics about the algorithm execution
algo2.printStats(database.size());
});
}