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

Examples of org.apache.mahout.cf.taste.model.DataModel


    assertNotNull(recommended);
    assertEquals(0, recommended.size());
  }

  public void testHowMany() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3, 4, 5},
            new Double[][] {
                    {0.1, 0.2},
                    {0.2, 0.3, 0.3, 0.6},
                    {0.4, 0.4, 0.5, 0.9},
View Full Code Here


    Recommender recommender = new SlopeOneRecommender(dataModel);
    assertEquals(0.3257f, recommender.estimatePreference(1, 2), EPSILON);
  }

  private static Recommender buildRecommender() throws TasteException {
    DataModel dataModel = getDataModel();
    return new SlopeOneRecommender(dataModel);
  }
View Full Code Here

      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
    }
  }

  public void testRescorer() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3},
            new Double[][] {
                    {0.1, 0.2},
                    {0.2, 0.3, 0.3, 0.6},
                    {0.4, 0.4, 0.5, 0.9},
View Full Code Here

    assertEquals(originalRecommended.get(0).getItemID(), rescoredRecommended.get(1).getItemID());
    assertEquals(originalRecommended.get(1).getItemID(), rescoredRecommended.get(0).getItemID());
  }

  public void testEstimatePref() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3, 4},
            new Double[][] {
                    {0.1, 0.3},
                    {0.2, 0.3, 0.3},
                    {0.4, 0.3, 0.5},
View Full Code Here

    assertEquals(0.3, itemCorrelation.itemSimilarity(1, 3));
    assertTrue(Double.isNaN(itemCorrelation.itemSimilarity(3, 4)));
  }

  public void testFromCorrelation() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3},
            new Double[][] {
                    {1.0, 2.0},
                    {2.0, 5.0},
                    {3.0, 6.0},
View Full Code Here

    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    assertEquals(0.9f, recommender.estimatePreference(3, 3));
  }

  public void testBestRating() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3, 4},
            new Double[][] {
                    {0.1, 0.3},
                    {0.2, 0.3, 0.3},
                    {0.4, 0.3, 0.5},
View Full Code Here

/** <p>Tests {@link NearestNUserNeighborhood}.</p> */
public final class NearestNNeighborhoodTest extends TasteTestCase {

  public void testNeighborhood() throws Exception {

    DataModel dataModel = getDataModel();

    long[] neighborhood =
        new NearestNUserNeighborhood(1, new DummySimilarity(dataModel), dataModel).getUserNeighborhood(1);
    assertNotNull(neighborhood);
    assertEquals(1, neighborhood.length);
View Full Code Here

/** <p>Tests {@link ThresholdUserNeighborhood}.</p> */
public final class ThresholdNeighborhoodTest extends TasteTestCase {

  public void testNeighborhood() throws Exception {

    DataModel dataModel = getDataModel();

    long[] neighborhood =
        new ThresholdUserNeighborhood(1.0, new DummySimilarity(dataModel), dataModel).getUserNeighborhood(1);
    assertNotNull(neighborhood);
    assertEquals(0, neighborhood.length);
View Full Code Here

/** Tests {@link MemoryDiffStorage}. */
public class MemoryDiffStorageTest extends TasteTestCase {

  public void testGetDiff() throws Exception {
    DataModel model = getDataModel();
    MemoryDiffStorage storage = new MemoryDiffStorage(model, Weighting.UNWEIGHTED, false, Long.MAX_VALUE);
    RunningAverage average = storage.getDiff(1, 2);
    assertEquals(0.23333333333333334, average.getAverage(), EPSILON);
    assertEquals(3, average.getCount());
  }
View Full Code Here

    assertEquals(0.23333333333333334, average.getAverage(), EPSILON);
    assertEquals(3, average.getCount());
  }

  public void testUpdate() throws Exception {
    DataModel model = getDataModel();
    MemoryDiffStorage storage = new MemoryDiffStorage(model, Weighting.UNWEIGHTED, false, Long.MAX_VALUE);
    storage.updateItemPref(1, 0.5f, false);
    RunningAverage average = storage.getDiff(1, 2);
    assertEquals(0.06666666666666668, average.getAverage(), EPSILON);
    assertEquals(3, average.getCount());
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.model.DataModel

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.