Package: replay-rec
RePlay is an advanced framework designed to facilitate the development and evaluation of recommendation systems. It provides a robust set of tools covering the entire lifecycle of a recommendation system pipeline:🚀 Features:Data Preprocessing and Splitting:Streamlines the data preparation process for recommendation systems, ensuring optimal data structure and format for efficient processing.Wide Range of Recommendation Models:Enables building of recommendation models from State-of-the-Art to commonly-used baselines and evaluate their performance and quality.Hyperparameter Optimization:Offers tools for fine-tuning model parameters to achieve the best possible performance, reducing the complexity of the optimization process.Comprehensive Evaluation Metrics:Incorporates a wide range of evaluation metrics to assess the accuracy and effectiveness of recommendation models.Model Ensemble and Hybridization:Supports combining predictions from multiple models and creating two-level (ensemble) models to enhance the quality of recommendations.Seamless Mode Transition:Facilitates easy transition from offline experimentation to online production environments, ensuring scalability and flexibility.💻 Hardware and Environment Compatibility:Diverse Hardware Support:Compatible with various hardware configurations including CPU, GPU, Multi-GPU.Cluster Computing Integration:Integrating with PySpark for distributed computing, enabling scalability for large-scale recommendation systems.📖 Documentation is availablehere.Table of ContentsInstallationQuickstartResourcesContributing to RePlay🔧 InstallationInstallation viapippackage manager is recommended by default:pipinstallreplay-recIn this case it will be installed thecorepackage withoutPySparkandPyTorchdependencies.
Alsoexperimentalsubmodule will not be installed.To installexperimentalsubmodule please specify the version withrc0suffix.
For example:pipinstallreplay-rec==XX.YY.ZZrc0ExtrasIn addition to the core package, several extras are also provided, including:[spark]: Install PySpark functionality[torch]: Install PyTorch and Lightning functionality[all]:[spark][torch]Example:# Install core package with PySpark dependencypipinstallreplay-rec[spark]# Install package with experimental submodule and PySpark dependencypipinstallreplay-rec[spark]==XX.YY.ZZrc0To build RePlay from sources please use theinstruction.If you encounter an error during RePlay installation, check thetroubleshootingguide.📈 Quickstartfromrs_datasetsimportMovieLensfromreplay.dataimportDataset,FeatureHint,FeatureInfo,FeatureSchema,FeatureTypefromreplay.data.dataset_utilsimportDatasetLabelEncoderfromreplay.metricsimportHitRate,NDCG,Experimentfromreplay.modelsimportItemKNNfromreplay.utilsimportconvert2sparkfromreplay.utils.session_handlerimportStatefromreplay.splittersimportRatioSplitterspark=State().sessionml_1m=MovieLens("1m")K=10# data preprocessinginteractions=convert2spark(ml_1m.ratings)# data splittingsplitter=RatioSplitter(test_size=0.3,divide_column="user_id",query_column="user_id",item_column="item_id",timestamp_column="timestamp",drop_cold_items=True,drop_cold_users=True,)train,test=splitter.split(interactions)# dataset creatingfeature_schema=FeatureSchema([FeatureInfo(column="user_id",feature_type=FeatureType.CATEGORICAL,feature_hint=FeatureHint.QUERY_ID,),FeatureInfo(column="item_id",feature_type=FeatureType.CATEGORICAL,feature_hint=FeatureHint.ITEM_ID,),FeatureInfo(column="rating",feature_type=FeatureType.NUMERICAL,feature_hint=FeatureHint.RATING,),FeatureInfo(column="timestamp",feature_type=FeatureType.NUMERICAL,feature_hint=FeatureHint.TIMESTAMP,),])train_dataset=Dataset(feature_schema=feature_schema,interactions=train,)test_dataset=Dataset(feature_schema=feature_schema,interactions=test,)# data encodingencoder=DatasetLabelEncoder()train_dataset=encoder.fit_transform(train_dataset)test_dataset=encoder.transform(test_dataset)# model trainingmodel=ItemKNN()model.fit(train_dataset)# model inferenceencoded_recs=model.predict(dataset=train_dataset,k=K,queries=test_dataset.query_ids,filter_seen_items=True,)recs=encoder.query_and_item_id_encoder.inverse_transform(encoded_recs)# model evaluationmetrics=Experiment([NDCG(K),HitRate(K)],test,query_column="user_id",item_column="item_id",rating_column="rating",)metrics.add_result("ItemKNN",recs)print(metrics.results)📑  ResourcesUsage examples01_replay_basics.ipynb- get started with RePlay.02_models_comparison.ipynb- reproducible models comparison onMovieLens-1M dataset.03_features_preprocessing_and_lightFM.ipynb- LightFM example with pyspark for feature preprocessing.04_splitters.ipynb- An example of using RePlay data splitters.05_feature_generators.ipynb- Feature generation with RePlay.06_item2item_recommendations.ipynb- Item to Item recommendations example.07_filters.ipynb- An example of using filters.08_recommending_for_categories.ipynb- An example of recommendation for product categories.09_sasrec_example.ipynb- An example of using transformers to generate recommendations.Videos and papersVideo guides:Replay for offline recommendations, AI Journey 2021Research papers:Turning Dross Into Gold Loss: is BERT4Rec really better than SASRec?Anton Klenitskiy, Alexey Vasilev. In The 17th ACM Conference on Recommender Systems (RecSys '23)The Long Tail of Context: Does it Exist and Matter?. Konstantin Bauman, Alexey Vasilev, Alexander Tuzhilin. In Workshop on Context-Aware Recommender Systems (CARS) (RecSys '22)Multiobjective Evaluation of Reinforcement Learning Based Recommender Systems. Alexey Grishanov, Anastasia Ianina, Konstantin Vorontsov. In The 16th ACM Conference on Recommender Systems (RecSys '22)Quality Metrics in Recommender Systems: Do We Calculate Metrics Consistently?Yan-Martin Tamm, Rinchin Damdinov, Alexey Vasilev. In The 15th ACM Conference on Recommender Systems (RecSys '21)💡 Contributing to RePlayWe welcome community contributions. For details please check ourcontributing guidelines.