* </pre>
*/
private void explicitExample(int numThreads) throws Exception {
Double na = Double.NaN;
Matrix preferences = new SparseRowMatrix(4, 4, new Vector[] {
new DenseVector(new double[] { 5.0, 5.0, 2.0, na }),
new DenseVector(new double[] { 2.0, na, 3.0, 5.0 }),
new DenseVector(new double[] { na, 5.0, na, 3.0 }),
new DenseVector(new double[] { 3.0, na, na, 5.0 }) });
writeLines(inputFile, preferencesAsText(preferences));
ParallelALSFactorizationJob alsFactorization = new ParallelALSFactorizationJob();
alsFactorization.setConf(conf);
int numFeatures = 3;
int numIterations = 5;
double lambda = 0.065;
alsFactorization.run(new String[] { "--input", inputFile.getAbsolutePath(), "--output", outputDir.getAbsolutePath(),
"--tempDir", tmpDir.getAbsolutePath(), "--lambda", String.valueOf(lambda),
"--numFeatures", String.valueOf(numFeatures), "--numIterations", String.valueOf(numIterations),
"--numThreadsPerSolver", String.valueOf(numThreads) });
Matrix u = MathHelper.readMatrix(conf, new Path(outputDir.getAbsolutePath(), "U/part-m-00000"),
preferences.numRows(), numFeatures);
Matrix m = MathHelper.readMatrix(conf, new Path(outputDir.getAbsolutePath(), "M/part-m-00000"),
preferences.numCols(), numFeatures);
StringBuilder info = new StringBuilder();
info.append("\nA - users x items\n\n");
info.append(MathHelper.nice(preferences));
info.append("\nU - users x features\n\n");