Examples of GenericPreference


Examples of com.opera.core.systems.preferences.OperaGenericPreferences.GenericPreference

    assertEquals("127.0.0.1", preferences.get("Developer Tools", "Proxy Host").getValue());
  }

  @Test
  public void testSetWithPreference() {
    preferences.set(new GenericPreference("Developer Tools", "Proxy Host", "1.2.3.4"));
    assertEquals("1.2.3.4", preferences.get("Developer Tools", "Proxy Host").getValue());
  }
View Full Code Here

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

    List<Preference> trainingPrefs = null;
    List<Preference> testPrefs = null;
    PreferenceArray prefs = dataModel.getPreferencesFromUser(userID);
    int size = prefs.length();
    for (int i = 0; i < size; i++) {
      Preference newPref = new GenericPreference(userID, prefs.getItemID(i), prefs.getValue(i));
      if (random.nextDouble() < trainingPercentage) {
        if (trainingPrefs == null) {
          trainingPrefs = new ArrayList<Preference>(3);
        }
        trainingPrefs.add(newPref);
View Full Code Here

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

    FastByIDMap<PreferenceArray> result = new FastByIDMap<PreferenceArray>();
    for (int i = 0; i < userIDs.length; i++) {
      List<Preference> prefsList = new ArrayList<Preference>();
      for (int j = 0; j < prefValues[i].length; j++) {
        if (prefValues[i][j] != null) {
          prefsList.add(new GenericPreference(userIDs[i], j, prefValues[i][j].floatValue()));
        }
      }
      if (!prefsList.isEmpty()) {
        result.put(userIDs[i], new GenericUserPreferenceArray(prefsList));
      }
View Full Code Here

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

    FastByIDMap<PreferenceArray> data = new FastByIDMap<PreferenceArray>(NUM_USERS);
    for (int i = 0; i < NUM_USERS; i++) {
      int numPrefs = random.nextInt(NUM_PREFS) + 1;
      PreferenceArray prefs = new GenericUserPreferenceArray(numPrefs);
      for (int j = 0; j < numPrefs; j++) {
        prefs.set(j, new GenericPreference(i, random.nextInt(NUM_ITEMS), random.nextFloat()));
      }
      data.put(i, prefs);
    }
    return new GenericDataModel(data);
  }
View Full Code Here

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

public final class ZScoreTest extends TransformTestCase {

  public void testOnePref() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{1.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 0, 1.0f)), EPSILON);
  }
View Full Code Here

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

  }

  public void testAllSame() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{1.0,1.0,1.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 0, 1.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 1, 1.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 2, 1.0f)), EPSILON);
  }
View Full Code Here

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

  }

  public void testStdev() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{-1.0,-2.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.707107, zScore.getTransformedValue(new GenericPreference(1, 0, -1.0f)), EPSILON);
    assertEquals(-0.707107, zScore.getTransformedValue(new GenericPreference(1, 1, -2.0f)), EPSILON);
  }
View Full Code Here

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

  }

  public void testExample() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{5.0, 7.0, 9.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(-1.0, zScore.getTransformedValue(new GenericPreference(1, 0, 5.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 1, 7.0f)), EPSILON);
    assertEquals(1.0, zScore.getTransformedValue(new GenericPreference(1, 2, 9.0f)), EPSILON);
  }
View Full Code Here

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

    Collection<Preference> prefs = new ArrayList<Preference>(count);
    for (int itemID = 1; itemID < jokePrefs.length; itemID++) { // yes skip first one, just a count
      String jokePref = jokePrefs[itemID];
      if (!"99".equals(jokePref)) {
        float jokePrefValue = Float.parseFloat(jokePref);
        prefs.add(new GenericPreference(userBeingRead, itemID, jokePrefValue));
      }
    }
    data.put(userBeingRead, prefs);
    userBeingRead++;
  }
View Full Code Here

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

      for (String line : new FileLineIterable(movieFile, true)) {
        int firstComma = line.indexOf(',');
        Integer userID = Integer.valueOf(line.substring(0, firstComma));
        int secondComma = line.indexOf(',', firstComma + 1);
        float rating = Float.parseFloat(line.substring(firstComma + 1, secondComma));
        prefs.add(new GenericPreference(userID, itemID, rating));
      }
    } catch (IOException ioe) {
      throw new TasteException(ioe);
    }
    return new GenericItemPreferenceArray(prefs);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.