Package org.apache.mahout.cf.taste.impl.model

Examples of org.apache.mahout.cf.taste.impl.model.GenericItemPreferenceArray


        prefs.add(new GenericPreference(userID, itemID, rating));
      }
    } catch (IOException ioe) {
      throw new TasteException(ioe);
    }
    return new GenericItemPreferenceArray(prefs);
  }
View Full Code Here


  }
 
  @Override
  public PreferenceArray getPreferencesForItem(long itemID) throws TasteException {
    List<Preference> list = doGetPreferencesForItem(itemID);
    return new GenericItemPreferenceArray(list);
  }
View Full Code Here

    itemIDsFromUser456.add(2L);

    List<Preference> prefs = new ArrayList<Preference>();
    prefs.add(new GenericPreference(123L, 1L, 1.0f));
    prefs.add(new GenericPreference(456L, 1L, 1.0f));
    PreferenceArray preferencesForItem1 = new GenericItemPreferenceArray(prefs);

    DataModel dataModel = EasyMock.createMock(DataModel.class);
    EasyMock.expect(dataModel.getItemIDsFromUser(123L)).andReturn(itemIDsFromUser123);
    EasyMock.expect(dataModel.getPreferencesForItem(1L)).andReturn(preferencesForItem1);
    EasyMock.expect(dataModel.getItemIDsFromUser(123L)).andReturn(itemIDsFromUser123);
View Full Code Here

        prefs.add(new GenericPreference(userID, itemID, rating));
      }
    } catch (IOException ioe) {
      throw new TasteException(ioe);
    }
    return new GenericItemPreferenceArray(prefs);
  }
View Full Code Here

        prefs.add(new GenericPreference(userID, itemID, rating));
      }
    } catch (IOException ioe) {
      throw new TasteException(ioe);
    }
    return new GenericItemPreferenceArray(prefs);
  }
View Full Code Here

  public PreferenceArray getPreferencesForItem(long itemID) throws TasteException {
    List<Preference> list = doGetPreferencesForItem(itemID);
    if (list.isEmpty()) {
      throw new NoSuchItemException();
    }
    return new GenericItemPreferenceArray(list);
  }
View Full Code Here

  public PreferenceArray getPreferencesForItem(long itemID) throws TasteException {
    List<Preference> list = doGetPreferencesForItem(itemID);
    if (list.isEmpty()) {
      throw new NoSuchItemException(itemID);
    }
    return new GenericItemPreferenceArray(list);
  }
View Full Code Here

    itemIDsFromUser456.add(2L);

    List<Preference> prefs = Lists.newArrayList();
    prefs.add(new GenericPreference(123L, 1L, 1.0f));
    prefs.add(new GenericPreference(456L, 1L, 1.0f));
    PreferenceArray preferencesForItem1 = new GenericItemPreferenceArray(prefs);

    DataModel dataModel = EasyMock.createMock(DataModel.class);
    EasyMock.expect(dataModel.getPreferencesForItem(1L)).andReturn(preferencesForItem1);
    EasyMock.expect(dataModel.getItemIDsFromUser(123L)).andReturn(itemIDsFromUser123);
    EasyMock.expect(dataModel.getItemIDsFromUser(456L)).andReturn(itemIDsFromUser456);
View Full Code Here

      List<HColumn<Long,Float>> userIDColumns = result.getColumns();
      if (userIDColumns.isEmpty()) {
        throw new NoSuchItemException(itemID);
      }
      int size = userIDColumns.size();
      PreferenceArray prefs = new GenericItemPreferenceArray(size);
      prefs.setItemID(0, itemID);
      for (int i = 0; i < size; i++) {
        HColumn<Long,Float> userIDColumn = userIDColumns.get(i);
        prefs.setUserID(i, userIDColumn.getName());
        prefs.setValue(i, userIDColumn.getValue());
      }
      return prefs;
    }
View Full Code Here

    if (result.isEmpty()) {
      throw new NoSuchItemException(itemID);
    }

    SortedMap<byte[], byte[]> families = result.getFamilyMap(USERS_CF);
    PreferenceArray prefs = new GenericItemPreferenceArray(families.size());
    prefs.setItemID(0, itemID);
    int i = 0;
    for (Map.Entry<byte[], byte[]> entry : families.entrySet()) {
      prefs.setUserID(i, Bytes.toLong(entry.getKey()));
      prefs.setValue(i, Bytes.toFloat(entry.getValue()));
      i++;
    }
    return prefs;
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.impl.model.GenericItemPreferenceArray

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.