congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
LenskitConfiguration.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.lenskit.LenskitConfiguration
constructor

Best Java code snippets using org.lenskit.LenskitConfiguration.<init> (Showing top 20 results out of 315)

origin: lenskit/lenskit

/**
 * Construct a new delegate with an empty configuration.
 *
 * @param loader The configuration loader
 * @param base   The base URL
 */
public LenskitConfigDSL(ConfigurationLoader loader, URI base) {
  this(loader, new LenskitConfiguration(), base);
}
origin: lenskit/lenskit

/**
 * Convenience method to copy a LensKit configuration.
 * @return An independent copy of this configuration.
 */
public LenskitConfiguration copy() {
  return new LenskitConfiguration(this);
}
origin: lenskit/lenskit

/**
 * Construct a new algorithm instance builder with a name.
 * @param name The algorithm name.
 */
public AlgorithmInstanceBuilder(String name) {
  this.name = name;
  attributes.put("Algorithm", name);
  config = new LenskitConfiguration();
}
origin: lenskit/lenskit

private AlgorithmInstanceBuilder(AlgorithmInstanceBuilder parent) {
  this.parent = parent;
  name = parent.getName();
  config = new LenskitConfiguration();
  attributes = new LinkedHashMap<>();
}
origin: lenskit/lenskit

protected LenskitConfiguration getDaoConfig() {
  LenskitConfiguration config = new LenskitConfiguration();
  config.bind(DataAccessObject.class)
     .toProvider(source);
  return config;
}
origin: lenskit/lenskit

/**
 * Load a LensKit configuration from a Groovy closure.  This is useful for using the Groovy
 * DSL in unit tests.
 *
 * @param block The block to evaluate.  This block will be evaluated with a delegate providing
 *              the LensKit DSL and the {@link groovy.lang.Closure#DELEGATE_FIRST} resolution strategy.
 * @return The LensKit configuration.
 * @see ConfigurationLoader#load(groovy.lang.Closure)
 */
public static LenskitConfiguration load(@DelegatesTo(LenskitConfigDSL.class) Closure<?> block) throws RecommenderConfigurationException {
  Preconditions.checkNotNull(block, "Configuration block");
  LenskitConfiguration config = new LenskitConfiguration();
  configure(config, block);
  return config;
}
origin: lenskit/lenskit

@Nonnull
public LenskitConfiguration getConfiguration() {
  StaticDataSource src = getSource();
  LenskitConfiguration config = new LenskitConfiguration();
  if (src != null) {
    config.bind(DataAccessObject.class).toProvider(src);
  }
  return config;
}
origin: lenskit/lenskit

/**
 * Create a LensKit recommender.
 * @param dao The data access object
 * @return The constructed recommender.
 */
public LenskitRecommender createRecommender(@WillNotClose DataAccessObject dao) throws RecommenderBuildException {
  LenskitConfiguration config = new LenskitConfiguration();
  config.addComponent(dao);
  return createRecommender(config);
}
origin: lenskit/lenskit

  @Test
  public void testConfiguredBaseURI() {
    LenskitConfigDSL dsl = LenskitConfigDSL.forConfig(new LenskitConfiguration());
    dsl.setBaseURI(new File("/tmp").toURI());
    assertThat(new File(dsl.getBaseURI().getPath()),
          equalTo(new File("/tmp").getAbsoluteFile()));
  }
}
origin: lenskit/lenskit

/**
 * Get extra LensKit configuration required by this data set.
 *
 * @return A LensKit configuration with additional configuration data for this data set.
 */
public LenskitConfiguration getExtraConfiguration() {
  LenskitConfiguration config = new LenskitConfiguration();
  PreferenceDomain pd = trainData.getPreferenceDomain();
  if (pd != null) {
    config.bind(PreferenceDomain.class).to(pd);
  }
  config.bind(TestUsers.class, LongSet.class)
     .toProvider(testUserProvider);
  return config;
}
origin: lenskit/lenskit

@Test
public void testInitialBaseURI() {
  LenskitConfigDSL dsl = LenskitConfigDSL.forConfig(new LenskitConfiguration());
  assertThat(new File(dsl.getBaseURI().getPath()),
        equalTo(SystemUtils.getUserDir()));
}
origin: lenskit/lenskit

private LenskitConfiguration makeDataConfig(Context ctx) {
  LenskitConfiguration config = new LenskitConfiguration();
  config.bind(DataAccessObject.class).toProvider(new DAOProvider());
  String dspec = ctx.options.getString("domain");
  if (dspec != null) {
    PreferenceDomain domain = PreferenceDomain.fromString(dspec);
    config.bind(PreferenceDomain.class).to(domain);
  }
  return config;
}
origin: lenskit/lenskit

@Before
public void createRatingSource() {
  EntityFactory efac = new EntityFactory();
  List<Rating> rs = new ArrayList<>();
  rs.add(efac.rating(1, 5, 2));
  rs.add(efac.rating(1, 7, 4));
  rs.add(efac.rating(8, 4, 5));
  rs.add(efac.rating(8, 5, 4));
  source = new StaticDataSource();
  source.addSource(rs);
  dao = source.get();
  config = new LenskitConfiguration();
  config.bind(ItemScorer.class).to(BiasItemScorer.class);
}
origin: lenskit/lenskit

  @Test
  public void testInject() throws RecommenderBuildException {
    LenskitConfiguration config = new LenskitConfiguration();
    config.addComponent(EntityCollectionDAO.create());
    config.bind(ItemScorer.class).to(ConstantItemScorer.class);
    config.set(ConstantItemScorer.Value.class).to(Math.PI);

    try (LenskitRecommender rec = LenskitRecommenderEngine.build(config).createRecommender()) {
      ItemScorer scorer = rec.getItemScorer();
      assertThat(scorer, notNullValue());
      assertThat(scorer, instanceOf(ConstantItemScorer.class));

      Map<Long, Double> v = scorer.score(42, LongUtils.packedSet(1, 2, 3, 5, 7));
      assertThat(v.keySet(), hasSize(5));
      assertThat(v.keySet(), containsInAnyOrder(1L, 2L, 3L, 5L, 7L));
      assertThat(v.values(), everyItem(equalTo(Math.PI)));
    }
  }
}
origin: lenskit/lenskit

  @SuppressWarnings("deprecation")
  @Before
  public void setup() throws RecommenderBuildException {
    List<Rating> rs = new ArrayList<>();
    rs.add(Rating.create(1, 5, 2));
    rs.add(Rating.create(1, 7, 4));
    rs.add(Rating.create(8, 4, 5));
    rs.add(Rating.create(8, 5, 4));
    StaticDataSource source = StaticDataSource.fromList(rs);

    LenskitConfiguration config = new LenskitConfiguration();
    config.bind(DataAccessObject.class).toProvider(source);
    config.bind(ItemScorer.class).to(ItemItemScorer.class);
    config.bind(ItemBasedItemScorer.class).to(ItemItemItemBasedItemScorer.class);
    // this is the default
//        factory.setComponent(UserVectorNormalizer.class, VectorNormalizer.class,
//                             IdentityVectorNormalizer.class);

    engine = LenskitRecommenderEngine.build(config);
  }

origin: lenskit/lenskit

@SuppressWarnings("deprecation")
@Before
public void setup() throws RecommenderBuildException {
  List<Rating> rs = new ArrayList<>();
  rs.add(Rating.create(1, 5, 2));
  rs.add(Rating.create(1, 7, 4));
  rs.add(Rating.create(8, 4, 5));
  rs.add(Rating.create(8, 5, 4));
  StaticDataSource source = StaticDataSource.fromList(rs);
  DataAccessObject dao = source.get();
  LenskitConfiguration config = new LenskitConfiguration();
  config.bind(DataAccessObject.class).to(dao);
  config.bind(ItemScorer.class).to(UserUserItemScorer.class);
  config.bind(NeighborFinder.class).to(LiveNeighborFinder.class);
  engine = LenskitRecommenderEngine.build(config);
}
origin: lenskit/lenskit

  @SuppressWarnings("deprecation")
  @Before
  public void setup() throws RecommenderBuildException {
    List<Rating> rs = new ArrayList<>();
    rs.add(Rating.create(1, 5, 2));
    rs.add(Rating.create(1, 7, 4));
    rs.add(Rating.create(8, 4, 5));
    rs.add(Rating.create(8, 5, 4));
    StaticDataSource source = StaticDataSource.fromList(rs);
    dao = source.get();

    LenskitConfiguration config = new LenskitConfiguration();
    config.bind(ItemItemModel.class).toProvider(NormalizingItemItemModelProvider.class);
    config.bind(ItemScorer.class).to(ItemItemScorer.class);
    config.bind(ItemBasedItemScorer.class).to(ItemItemItemBasedItemScorer.class);
    // this is the default
//        factory.setComponent(UserVectorNormalizer.class, VectorNormalizer.class,
//                             IdentityVectorNormalizer.class);

    engine = LenskitRecommenderEngine.build(config, dao);
  }

origin: lenskit/lenskit

@SuppressWarnings({"deprecation", "unchecked"})
private LenskitRecommenderEngine makeEngine() throws RecommenderBuildException {
  LenskitConfiguration config = new LenskitConfiguration();
  config.bind(RatingMatrix.class)
     .to(PackedRatingMatrix.class);
  config.bind(ItemScorer.class)
     .to(FunkSVDItemScorer.class);
  config.bind(BiasModel.class).to(UserItemBiasModel.class);
  config.set(IterationCount.class)
     .to(10);
  config.set(FeatureCount.class)
     .to(20);
  return LenskitRecommenderEngine.build(config, dao);
}
origin: lenskit/lenskit

@Test
public void testComputeUserMeans() {
  EntityFactory efac = new EntityFactory();
  EntityCollectionDAOBuilder daoBuilder = new EntityCollectionDAOBuilder();
  daoBuilder.addEntities(efac.rating(100, 200, 3.0),
              efac.rating(101, 200, 4.0),
              efac.rating(102, 201, 2.5),
              efac.rating(102, 203, 4.5),
              efac.rating(101, 203, 3.5));
  LenskitConfiguration config = new LenskitConfiguration();
  config.addRoot(BiasModel.class);
  config.bind(BiasModel.class).toProvider(UserAverageRatingBiasModelProvider.class);
  LenskitRecommender rec = LenskitRecommender.build(config, daoBuilder.build());
  BiasModel model = rec.get(BiasModel.class);
  assertThat(model.getIntercept(), closeTo(3.5, 1.0e-3));
  assertThat(model.getUserBias(100), closeTo(-0.5, 1.0e-3));
  assertThat(model.getUserBias(101), closeTo(0.25, 1.0e-3));
  assertThat(model.getUserBias(102), closeTo(0.0, 1.0e-3));
}
origin: lenskit/lenskit

@Test
public void testComputeItemMeans() {
  EntityFactory efac = new EntityFactory();
  EntityCollectionDAOBuilder daoBuilder = new EntityCollectionDAOBuilder();
  daoBuilder.addEntities(efac.rating(100, 200, 3.0),
              efac.rating(101, 200, 4.0),
              efac.rating(101, 201, 2.5),
              efac.rating(102, 203, 4.5),
              efac.rating(103, 203, 3.5));
  LenskitConfiguration config = new LenskitConfiguration();
  config.addRoot(BiasModel.class);
  config.bind(BiasModel.class).toProvider(ItemAverageRatingBiasModelProvider.class);
  LenskitRecommender rec = LenskitRecommender.build(config, daoBuilder.build());
  BiasModel model = rec.get(BiasModel.class);
  assertThat(model.getIntercept(), closeTo(3.5, 1.0e-3));
  assertThat(model.getItemBias(200), closeTo(0.0, 1.0e-3));
  assertThat(model.getItemBias(201), closeTo(-1.0, 1.0e-3));
  assertThat(model.getItemBias(203), closeTo(0.5, 1.0e-3));
}
org.lenskitLenskitConfiguration<init>

Javadoc

Create a new LensKit configuration.

Popular methods of LenskitConfiguration

  • bind
  • addRoot
    Add the specified component type as a root component. This forces it (and its dependencies) to be re
  • set
  • addComponent
  • within
  • buildGraph
    Get a mockup of the full recommender graph. This fully resolves the graph so that it can be analyzed
  • getBindings
  • getRoots
  • wrapContext
  • clearRoots
    Clear the set of roots, removing all configured and default roots. This is almost never desired in p

Popular in Java

  • Making http requests using okhttp
  • startActivity (Activity)
  • putExtra (Intent)
  • findViewById (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JComboBox (javax.swing)
  • JFileChooser (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now