FastIDSet userTagIDs = new FastIDSet(1000);
InputFilesReader.readInputFiles(knownItemIDs, RbyRow, RbyColumn, itemTagIDs, userTagIDs, inputDir);
if (!RbyRow.isEmpty() && !RbyColumn.isEmpty()) {
// Compute latest generation:
MatrixFactorizer als;
Generation latestGeneration;
// Repeat with fewer features if fails to build:
while (true) {
try {
als = runFactorization(theCurrentGeneration, RbyRow, RbyColumn);
latestGeneration = new Generation(knownItemIDs, als.getX(), als.getY(), itemTagIDs, userTagIDs);
break;
} catch (SingularMatrixSolverException smse) {
int currentFeatures = readNumFeatures();
int fewerFeatures = smse.getApparentRank();
if (fewerFeatures <= 1) {
throw smse;
}
log.warn("Could not build model with {} features; setting model.features down to {}",
currentFeatures, fewerFeatures);
System.setProperty("model.features", Integer.toString(fewerFeatures));
}
}
// Save it:
saveModel(latestGeneration, modelFile);
// Merge into potentially live current generation:
loader.loadModel(theCurrentGeneration, als.getX(), als.getY(), knownItemIDs, itemTagIDs, userTagIDs);
}
int numItems = theCurrentGeneration.getNumItems();
int numUsers = theCurrentGeneration.getNumUsers();
if (numUsers == 0 || numItems == 0) {