in src/main/java/com/twitter/sbf/simclusters_app/Main.java [49:108]
private static void run() throws IOException {
// Load graph from file
System.out.println("Loading bipartite graph from METIS data");
BipartiteGraph graph = BipartiteGraph.fromFile(config.getMetisFile());
System.out.println("Load graph: done!");
//Variable for specifying the type of initialization for the algorithm
final String evalType;
if (config.getInitFromRandomNeighborhoods()) {
evalType = "randomNeighborhoods";
} else if (config.getInitFromBestNeighborhood()) {
evalType = "bestNeighborhoods";
} else if (config.getInitFromNonoverlappingNeighborhood()) {
evalType = "nonoverlappingNeighborhoods";
} else {
evalType = "random";
}
//Arguments for SimClusters object
int k = config.getK();
AlgorithmConfig paramsForStepTwo = config.getAlgoConfig();
int thresholdForStepThree = config.getThresholdForStepThree();
double thresholdForStepOne = config.getThresholdForStepOne();
boolean retainTopK = config.getRetainTopK();
int topKParameter = config.getTopKParameter();
boolean normalizeColumnsRight = config.getNormalizeColumnsRight();
boolean normalizeRowsLeft = config.getNormalizeRowsLeft();
boolean applyLogTransform = config.getApplyLogTransform();
boolean squareWeights = config.getSquareWeights();
boolean applyStepFour = config.getApplyStepFour();
double thresholdForStepFour = config.getThresholdForStepFour();
PrintWriter log = new PrintWriter(System.out);
//Create SimClusters algorithm object
SimClustersInMemory algo
= new SimClustersInMemory(
graph, k, paramsForStepTwo, thresholdForStepThree, thresholdForStepOne, retainTopK,
topKParameter, log, normalizeColumnsRight, normalizeRowsLeft, squareWeights, evalType,
applyStepFour, thresholdForStepFour, applyLogTransform);
//Run algorithm
long tic = System.currentTimeMillis();
BipartiteSparseRepresentations representations =
algo.runSimClusters();
long toc = System.currentTimeMillis();
System.out.println(String.format(
"Time to learn bipartite sparse representations: %.2f seconds", (toc - tic) / 1000.0
));
// Write output
System.out.println(
"Printing left representations to file " + config.getOutputLeftRepFile()
+ " and right representations to file " + config.getOutputRightRepFile()
);
PrintWriter leftOutput = new PrintWriter(config.getOutputLeftRepFile());
PrintWriter rightOutput = new PrintWriter(config.getOutputRightRepFile());
writeRowsWithScores(representations.leftRepresentations, leftOutput);
writeRowsWithScores(representations.rightRepresentations, rightOutput);
System.out.println("Done writing output!");
}