package ca.pfv.spmf.test;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import ca.pfv.spmf.algorithms.frequentpatterns.two_phase.AlgoHUINIVMine;
import ca.pfv.spmf.algorithms.frequentpatterns.two_phase.ItemsetsTP;
import ca.pfv.spmf.algorithms.frequentpatterns.two_phase.UtilityTransactionDatabaseTP;
/**
* Example of how to use the HUINIVMine Algorithm in source code.
* @author Philippe Fournier-Viger, 2010
*/
public class MainTestHUINIVMine_saveToFile {
public static void main(String [] arg) throws IOException{
String input = fileToPath("DB_NegativeUtility.txt");
String output = ".//output.txt";
int min_utility = 30; //
// Loading the database into memory
UtilityTransactionDatabaseTP database = new UtilityTransactionDatabaseTP();
database.loadFile(input);
// Applying the Two-Phase algorithm
AlgoHUINIVMine algo = new AlgoHUINIVMine();
ItemsetsTP highUtilityItemsets = algo.runAlgorithm(database, min_utility);
highUtilityItemsets.saveResultsToFile(output, database.getTransactions().size());
algo.printStats();
}
public static String fileToPath(String filename) throws UnsupportedEncodingException{
URL url = MainTestHUINIVMine_saveToFile.class.getResource(filename);
return java.net.URLDecoder.decode(url.getPath(),"UTF-8");
}
}