Package org.apache.mahout.cf.taste.hadoop

Examples of org.apache.mahout.cf.taste.hadoop.ItemPrefWritable


                     OutputCollector<LongWritable,VectorWritable> output,
                     Reporter reporter) throws IOException {
    if (itemPrefs.hasNext()) {
      RandomAccessSparseVector userVector = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
      while (itemPrefs.hasNext()) {
        ItemPrefWritable itemPref = itemPrefs.next();
        int index = ItemIDIndexMapper.idToIndex(itemPref.getItemID());
        userVector.set(index, itemPref.getPrefValue());
      }
     
      if (userVector.getNumNondefaultElements() > MAX_PREFS_CONSIDERED) {
        double cutoff = findTopNPrefsCutoff(MAX_PREFS_CONSIDERED,
          userVector);
View Full Code Here


                     Iterator<ItemPrefWritable> values,
                     OutputCollector<ItemItemWritable,FloatWritable> output,
                     Reporter reporter) throws IOException {
    List<ItemPrefWritable> prefs = new ArrayList<ItemPrefWritable>();
    while (values.hasNext()) {
      prefs.add(new ItemPrefWritable(values.next()));
    }
    Collections.sort(prefs, ByItemIDComparator.getInstance());
    int size = prefs.size();
    for (int i = 0; i < size; i++) {
      ItemPrefWritable first = prefs.get(i);
      long itemAID = first.getItemID();
      float itemAValue = first.getPrefValue();
      for (int j = i + 1; j < size; j++) {
        ItemPrefWritable second = prefs.get(j);
        long itemBID = second.getItemID();
        float itemBValue = second.getPrefValue();
        output.collect(new ItemItemWritable(itemAID, itemBID), new FloatWritable(itemBValue - itemAValue));
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.hadoop.ItemPrefWritable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.