## org.apache.mahout.cf.taste.impl.similarity.precompute
Class MultithreadedBatchItemSimilarities

    java.lang.Object
      org.apache.mahout.cf.taste.similarity.precompute.BatchItemSimilarities
          org.apache.mahout.cf.taste.impl.similarity.precompute.MultithreadedBatchItemSimilarities

    public class MultithreadedBatchItemSimilarities

extends BatchItemSimilarities

Precompute item similarities in parallel on a single machine. The recommender given to this class must use a DataModel that holds the interactions in memory (such as `GenericDataModel` or `FileDataModel`) as fast random access to the data is required

Constructor Summary
`MultithreadedBatchItemSimilarities(ItemBasedRecommender recommender, int similarItemsPerItem)`
`MultithreadedBatchItemSimilarities(ItemBasedRecommender recommender, int similarItemsPerItem, int batchSize)`

Method Summary
`int` `computeItemSimilarities(int degreeOfParallelism, int maxDurationInHours, SimilarItemsWriter writer)`

Methods inherited from class org.apache.mahout.cf.taste.similarity.precompute.BatchItemSimilarities
`getRecommender, getSimilarItemsPerItem`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MultithreadedBatchItemSimilarities

    public MultithreadedBatchItemSimilarities(ItemBasedRecommender recommender,
                                              int similarItemsPerItem)

Parameters:
  `recommender` - recommender to use
  `similarItemsPerItem` - number of similar items to compute per item

### MultithreadedBatchItemSimilarities

    public MultithreadedBatchItemSimilarities(ItemBasedRecommender recommender,
                                              int similarItemsPerItem,
                                              int batchSize)

Parameters:
  `recommender` - recommender to use
  `similarItemsPerItem` - number of similar items to compute per item
  `batchSize` - size of item batches sent to worker threads

Method Detail

### computeItemSimilarities

    public int computeItemSimilarities(int degreeOfParallelism,
                                       int maxDurationInHours,
                                       SimilarItemsWriter writer)
                                throws IOException

  Specified by:
    `computeItemSimilarities` in class `BatchItemSimilarities`
  Parameters:
    `degreeOfParallelism` - number of threads to use for the computation
    `maxDurationInHours` - maximum duration of the computation
    `writer` - `SimilarItemsWriter` used to persist the results
  Returns:
    the number of similarities precomputed
  Throws:
    `IOException`

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.