Convert Figma logo to code with AI

guoguibing logolibrec

LibRec: A Leading Java Library for Recommender Systems, see

3,234
1,029
3,234
81

Top Related Projects

Best Practices on Recommendation Systems

39,274

Apache Spark - A unified analytics engine for large-scale data processing

Fast Python Collaborative Filtering for Implicit Feedback Datasets

A Python scikit for building and analyzing recommender systems

Quick Overview

LibRec is an open-source Java library for recommender systems research and development. It provides a comprehensive set of algorithms, evaluation metrics, and data structures for building and testing various types of recommender systems, including collaborative filtering, content-based, and hybrid approaches.

Pros

  • Comprehensive Algorithms: LibRec implements a wide range of state-of-the-art recommendation algorithms, including matrix factorization, neighborhood-based, and deep learning-based methods.
  • Modular Design: The library has a modular design, allowing for easy integration of new algorithms, data structures, and evaluation metrics.
  • Efficient and Scalable: LibRec is designed to be efficient and scalable, with support for large-scale datasets and parallel processing.
  • Active Development: The project is actively maintained and regularly updated, with contributions from a community of researchers and developers.

Cons

  • Java-based: LibRec is written in Java, which may not be the preferred language for all users or projects.
  • Limited Documentation: While the project has good documentation, it could be more comprehensive and user-friendly, especially for newcomers to the field of recommender systems.
  • Limited GUI: LibRec is primarily a command-line tool, and it lacks a graphical user interface (GUI) for easier configuration and visualization of results.
  • Steep Learning Curve: Developing and using recommender systems can be a complex task, and LibRec may have a steeper learning curve for users who are new to the field.

Code Examples

Here are a few code examples demonstrating the usage of LibRec:

  1. Loading a Dataset:
DataModel dataModel = new TextDataModel(new File("path/to/dataset.txt"));
dataModel.buildDataModel();
  1. Configuring and Running a Recommendation Algorithm:
RecommenderContext context = new RecommenderContext(dataModel);
context.setAlgorithm(new UserKNNRecommender());
context.getAlgorithm().train(context);
List<RecommendedItem> recommendations = context.getAlgorithm().recommend(userId, 10);
  1. Evaluating Recommendation Performance:
Measure measure = new MAEMeasure();
double mae = measure.evaluate(context);
System.out.println("MAE: " + mae);
  1. Saving and Loading a Trained Model:
context.getAlgorithm().saveModel("path/to/model.bin");
RecommenderContext loadedContext = new RecommenderContext(dataModel);
loadedContext.setAlgorithm(new UserKNNRecommender());
loadedContext.getAlgorithm().loadModel("path/to/model.bin");

Getting Started

To get started with LibRec, follow these steps:

  1. Install Java: LibRec requires Java 8 or higher to be installed on your system.

  2. Download LibRec: You can download the latest version of LibRec from the project's GitHub repository: https://github.com/guoguibing/librec.

  3. Set up the Project: Extract the downloaded archive and navigate to the project directory. You can either use the provided command-line interface or integrate LibRec into your own Java project.

  4. Configure the Dataset: LibRec supports various data formats, including text files, CSV, and database connections. Prepare your dataset and update the configuration file accordingly.

  5. Choose a Recommendation Algorithm: LibRec provides a wide range of recommendation algorithms. Select the one that best suits your use case and update the configuration file.

  6. Run the Recommendation Task: Use the provided command-line interface or integrate the recommendation logic into your Java application.

  7. Evaluate the Results: LibRec offers several evaluation metrics to assess the performance of your recommendation model. Review the output and iterate on your approach as needed.

For more detailed instructions and configuration options, please refer to the LibRec documentation: https://github.com/guoguibing/librec/wiki.

Competitor Comparisons

Best Practices on Recommendation Systems

Pros of recommenders

  • More comprehensive, covering a wider range of recommendation algorithms and techniques
  • Better documentation and examples, making it easier for users to get started
  • Active development with frequent updates and contributions from Microsoft

Cons of recommenders

  • Steeper learning curve due to its broader scope and complexity
  • Heavier dependencies, potentially making it more challenging to integrate into existing projects

Code comparison

recommenders:

from recommenders.models.deeprec.models.xdeepfm import XDeepFMModel

model = XDeepFMModel(
    feature_dim=feature_dim,
    field_dim=field_dim,
    cin_layer_units=[128, 128],
    dnn_hidden_units=[128, 128, 64],
)

librec:

XDeepFMRecommender recommender = new XDeepFMRecommender();
recommender.setNumFactors(10);
recommender.setNumEpochs(100);
recommender.setLearningRate(0.01);
recommender.recommend(testUser);

Summary

recommenders offers a more comprehensive and well-documented solution for recommendation systems, with active development and support from Microsoft. However, it may be more complex and have heavier dependencies compared to librec. librec provides a simpler, Java-based alternative that might be easier to integrate into certain projects, but with potentially fewer features and less frequent updates.

39,274

Apache Spark - A unified analytics engine for large-scale data processing

Pros of Spark

  • Broader scope: Spark is a general-purpose distributed computing system, supporting various data processing tasks beyond just recommender systems
  • Larger community and ecosystem: More extensive support, documentation, and third-party integrations
  • Better scalability: Designed for large-scale data processing across distributed clusters

Cons of Spark

  • Steeper learning curve: More complex to set up and use compared to LibRec's focused approach
  • Resource-intensive: Requires more computational resources, which may be overkill for smaller recommendation tasks

Code Comparison

Spark (PySpark):

from pyspark.ml.recommendation import ALS

als = ALS(userCol="userId", itemCol="movieId", ratingCol="rating")
model = als.fit(ratings)
predictions = model.transform(test)

LibRec:

RecommenderContext context = new RecommenderContext(conf);
RecommenderJob job = new RecommenderJob(context);
job.runJob();

Summary

Spark is a more versatile and scalable solution for big data processing, including recommendation systems, but comes with increased complexity. LibRec is a specialized library for recommender systems, offering a simpler approach for focused recommendation tasks. The choice between them depends on the project's scale, requirements, and available resources.

Fast Python Collaborative Filtering for Implicit Feedback Datasets

Pros of implicit

  • Faster performance due to C++ implementation with Python bindings
  • Focuses specifically on implicit feedback datasets
  • Includes more modern algorithms like BPR and ALS-CG

Cons of implicit

  • Narrower scope, only for implicit feedback recommenders
  • Less extensive documentation compared to LibRec
  • Fewer evaluation metrics and data processing utilities

Code comparison

implicit:

model = implicit.als.AlternatingLeastSquares(factors=50)
model.fit(user_item_matrix)
recommendations = model.recommend(user_id, user_item_matrix[user_id])

LibRec:

RecommenderContext context = new RecommenderContext(conf, rateMatrix);
RecommenderJob job = new RecommenderJob(context);
job.runJob();
List<RecommendedItem> recommendations = job.getRecommender().recommend(userId, 10);

Summary

implicit is a specialized library for implicit feedback recommenders with high performance, while LibRec is a more comprehensive recommendation library with a wider range of algorithms and utilities. implicit may be preferred for projects specifically focused on implicit feedback, while LibRec offers more flexibility for various recommendation scenarios.

A Python scikit for building and analyzing recommender systems

Pros of Surprise

  • Written in Python, making it more accessible for data scientists and researchers
  • Extensive documentation and examples, facilitating easier adoption
  • Supports various evaluation metrics out-of-the-box

Cons of Surprise

  • Limited to memory-based algorithms, not suitable for large-scale production environments
  • Fewer built-in algorithms compared to LibRec
  • Less focus on distributed computing and scalability

Code Comparison

Surprise:

from surprise import SVD
from surprise import Dataset
from surprise import accuracy

data = Dataset.load_builtin('ml-100k')
algo = SVD()
predictions = algo.fit(data.build_full_trainset()).test(data.build_full_trainset().build_testset())
accuracy.rmse(predictions)

LibRec:

Configuration conf = new Configuration();
conf.set("dfs.data.dir", "data");
conf.set("data.input.path", "filmtrust");
conf.set("rec.recommender.class", "svdplusplus");
RecommenderJob job = new RecommenderJob(conf);
job.runJob();

Both libraries offer straightforward ways to load data, train models, and evaluate results. Surprise's Python-based approach may be more intuitive for data scientists, while LibRec's Java implementation could be more suitable for production environments and large-scale applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

LibRec (https://guoguibing.github.io/librec/index.html) is a Java library for recommender systems (Java version 1.7 or higher required). It implements a suit of state-of-the-art recommendation algorithms, aiming to resolve two classic recommendation tasks: rating prediction and item ranking.

Join the chat at https://gitter.im/librec/LobbyBuild Status

LibRec Demo

A movie recommender system is designed and available here.

Documentation

Please refer to LibRec Documentation and API Documentation

Authors Words about the NEW Version

It has been a year since the last version was released. In this year, lots of changes have been taken to the LibRec project, and the most significant one is the formulation of the LibRec team. The team pushes forward the development of LibRec with the wisdom of many experts, and the collaboration of experienced and enthusiastic contributors. Without their great efforts and hardworking, it is impossible to reach the state that a single developer may dream of.

LibRec 2.0 is not the end of our teamwork, but just the begining of greater objectives. We aim to continously provide NEXT versions for better experience and performance. There are many directions and goals in plan, and we will do our best to make them happen. It is always exciting to receive any code contributions, suggestions, comments from all our LibRec users.

We hope you enjoy the new version!

PS: Follow us on WeChat to have first-hand and up-to-date information about LibRec.

Features

  • Rich Algorithms: More than 70 recommendation algorithms have been implemented, and more will be done.
  • High Modularity: Six main components including data split, data conversion, similarity, algorithms, evaluators and filters.
  • Great Performance: More efficient implementations than other counterparts while producing comparable accuracy.
  • Flexible Configuration: Low coupling, flexible and either external textual or internal API configuration.
  • Simple Usage: Can get executed in a few lines of codes, and a number of demos are provided for easy start.
  • Easy Expansion: A set of recommendation interfaces for easy expansion to implement new recommenders.

The procedure of LibRec is illustrated as follows.

Download

by maven

<dependency>
    <groupId>net.librec</groupId>
    <artifactId>librec-core</artifactId>
    <version>2.0.0</version>
</dependency>

by packages

Execution

You can run LibRec with configurations from command arguments:

librec rec -exec -D rec.recommender.class=itemcluster -D rec.pgm.number=10 -D rec.iterator.maximum=20

or from a configuration file:

librec rec -exec -conf itemcluster-test.properties

Code Snippet

You can use LibRec as a part of your projects, and use the following codes to run a recommender.

public void main(String[] args) throws Exception {
	
	// recommender configuration
	Configuration conf = new Configuration();
	Resource resource = new Resource("rec/cf/userknn-test.properties");
	conf.addResource(resource);

	// build data model
	DataModel dataModel = new TextDataModel(conf);
	dataModel.buildDataModel();
	
	// set recommendation context
	RecommenderContext context = new RecommenderContext(conf, dataModel);
	RecommenderSimilarity similarity = new PCCSimilarity();
	similarity.buildSimilarityMatrix(dataModel, true);
	context.setSimilarity(similarity);

	// training
	Recommender recommender = new UserKNNRecommender();
	recommender.recommend(context);

	// evaluation
	RecommenderEvaluator evaluator = new MAEEvaluator();
	recommender.evaluate(evaluator);

	// recommendation results
	List recommendedItemList = recommender.getRecommendedList();
	RecommendedFilter filter = new GenericRecommendedFilter();
	recommendedItemList = filter.filter(recommendedItemList);
}

News Report

Acknowledgement

We would like to express our appreciation to the following people for contributing source codes to LibRec, including Prof. Robin Burke, Bin Wu, Diego Monti, Ge Zhou, Li Wenxi, Marco Mera, Ran Locar, Shawn Rutledge, ShuLong Chen, Tao Lian, Takuya Kitazawa, Zhaohua Hong, Tan Jiale, Daniel Velten, Qian Shaofeng, etc. We gratefully thank Mr. Lijun Dai for designing and contributing the logo of LibRec, and also many thanks to Mr. Jianbin Zhang for implementing and sharing a LibRec demo.

We also appreciate many others for reporting bugs and issues, and for providing valuable suggestions and support.

Publications

Please cite the following papers if LibRec is helpful to your research.

  1. G. Guo, J. Zhang, Z. Sun and N. Yorke-Smith, LibRec: A Java Library for Recommender Systems, in Posters, Demos, Late-breaking Results and Workshop Proceedings of the 23rd Conference on User Modelling, Adaptation and Personalization (UMAP), 2015.
  2. G. Guo, J. Zhang and N. Yorke-Smith, TrustSVD: Collaborative Filtering with Both the Explicit and Implicit Influence of User Trust and of Item Ratings, in Proceedings of the 29th AAAI Conference on Artificial Intelligence (AAAI), 2015, 123-129.
  3. Z. Sun, G. Guo and J. Zhang, Exploiting Implicit Item Relationships for Recommender Systems, in Proceedings of the 23rd International Conference on User Modeling, Adaptation and Personalization (UMAP), 2015.

GPL License

LibRec is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. LibRec is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with LibRec. If not, see http://www.gnu.org/licenses/.