当前位置: 首页>>代码示例>>Java>>正文


Java AlgoCharmMFI类代码示例

本文整理汇总了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);
}
 
开发者ID:mast-group,项目名称:itemset-mining,代码行数:22,代码来源:CondensedFrequentItemsetMining.java

示例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());
    });
}
 
开发者ID:matfax,项目名称:spmf,代码行数:48,代码来源:MainTestCharmMFI_saveToMemory.java


注:本文中的ca.pfv.spmf.algorithms.frequentpatterns.charm.AlgoCharmMFI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。