Author: ssc
Date: Wed Aug 29 12:23:14 2012
New Revision: 1378518
URL: http://svn.apache.org/viewvc?rev=1378518&view=rev
Log:
allow specifying the number of training threads in ALS factorizer (minor change)
Modified:
mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/svd/ALSWRFactorizer.java
Modified:
mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/svd/ALSWRFactorizer.java
URL:
http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/svd/ALSWRFactorizer.java?rev=1378518&r1=1378517&r2=1378518&view=diff
==============================================================================
---
mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/svd/ALSWRFactorizer.java
(original)
+++
mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/svd/ALSWRFactorizer.java
Wed Aug 29 12:23:14 2012
@@ -65,12 +65,14 @@ public class ALSWRFactorizer extends Abs
/** confidence weighting parameter, only necessary when working with
implicit feedback */
private final double alpha;
+ private final int numTrainingThreads;
+
private static final double DEFAULT_ALPHA = 40;
private static final Logger log =
LoggerFactory.getLogger(ALSWRFactorizer.class);
public ALSWRFactorizer(DataModel dataModel, int numFeatures, double lambda,
int numIterations,
- boolean usesImplicitFeedback, double alpha) throws TasteException {
+ boolean usesImplicitFeedback, double alpha, int numTrainingThreads)
throws TasteException {
super(dataModel);
this.dataModel = dataModel;
this.numFeatures = numFeatures;
@@ -78,6 +80,13 @@ public class ALSWRFactorizer extends Abs
this.numIterations = numIterations;
this.usesImplicitFeedback = usesImplicitFeedback;
this.alpha = alpha;
+ this.numTrainingThreads = numTrainingThreads;
+ }
+
+ public ALSWRFactorizer(DataModel dataModel, int numFeatures, double lambda,
int numIterations,
+ boolean usesImplicitFeedback, double alpha) throws
TasteException {
+ this(dataModel, numFeatures, lambda, numIterations, usesImplicitFeedback,
alpha,
+ Runtime.getRuntime().availableProcessors());
}
public ALSWRFactorizer(DataModel dataModel, int numFeatures, double lambda,
int numIterations) throws TasteException {
@@ -247,7 +256,7 @@ public class ALSWRFactorizer extends Abs
}
protected ExecutorService createQueue() {
- return
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
+ return Executors.newFixedThreadPool(numTrainingThreads);
}
protected static Vector ratingVector(PreferenceArray prefs) {