Package: rectools
RecToolsRecTools is an easy-to-use Python library which makes the process of building recommendation systems easier,
faster and more structured than ever before.
It includes built-in toolkits for data processing and metrics calculation,
a variety of recommender models, some wrappers for already existing implementations of popular algorithms
and model selection framework.
The aim is to collect ready-to-use solutions and best practices in one place to make processes
of creating your first MVP and deploying model to production as fast and easy as possible.For more details, see theDocumentationandTutorials.Get startedPrepare data withwgethttps://files.grouplens.org/datasets/movielens/ml-1m.zip
unzipml-1m.zipimportpandasaspdfromimplicit.nearest_neighboursimportTFIDFRecommenderfromrectoolsimportColumnsfromrectools.datasetimportDatasetfromrectools.modelsimportImplicitItemKNNWrapperModel# Read the dataratings=pd.read_csv("ml-1m/ratings.dat",sep="::",engine="python",# Because of 2-chars separatorsheader=None,names=[Columns.User,Columns.Item,Columns.Weight,Columns.Datetime],)# Create datasetdataset=Dataset.construct(ratings)# Fit modelmodel=ImplicitItemKNNWrapperModel(TFIDFRecommender(K=10))model.fit(dataset)# Make recommendationsrecos=model.recommend(users=ratings[Columns.User].unique(),dataset=dataset,k=10,filter_viewed=True,)InstallationRecTools is on PyPI, so you can usepipto install it.pip install rectoolsThe default version doesn't contain all the dependencies, because some of them are needed only for specific models. Available user extensions are the following:lightfm: adds wrapper for LightFM model,torch: adds models based on neural nets,nmslib: adds fast ANN recommenders.Install extension:pip install rectools[extension-name]Install all extensions:pip install rectools[all]Important:If you're usingpoetryand you want to addrectoolsto your project, then you should either installrectoolswithoutlightfmextras or usepoetry==1.4.0and add to yourpoetry.tomlfile the next lines:[experimental]
new-installer = falseRecommender ModelsThe table below lists recommender models that are available in RecTools.ModelTypeDescriptionExtra featuresimplicitALS WrapperMatrix Factorizationrectools.models.ImplicitALSWrapperModel- Alternating Least Squares Matrix Factorizattion algorithm for implicit feedbackSupport for user/item features!Check our boost to metricsimplicitItemKNN WrapperCollaborative Filteringrectools.models.ImplicitItemKNNWrapperModel- Algorithm that calculates item-item similarity matrix using distances between item vectors in user-item interactions matrix-LightFMWrapperMatrix Factorizationrectools.models.LightFMWrapperModel- Hybrid matrix factorization algorithm which utilises user and item features and supports a variety of losses10-25 times faster inference!Check our boost to inferencePureSVDMatrix Factorizationrectools.models.PureSVDModel- Truncated Singular Value Decomposition of user-item interactions matrix-DSSMNeural Networkrectools.models.DSSMModel- Two-tower Neural model that learns user and item embeddings utilising their explicit features and learning on triplet loss-PopularHeuristicrectools.models.PopularModel- Classic baseline which computes popularity of itemsHyperparams (time window, pop computation)Popular in CategoryHeuristicrectools.models.PopularInCategoryModel- Model that computes poularity within category and applies mixing strategy to increase DiversityHyperparams (time window, pop computation, mixing/ratio strategy)RandomHeuristicrectools.models.RandomModel- Simple random algorithm useful to benchmark Novelty, Coverage, etc.-All of the models follow the same interface.No exceptionsNo need for manual creation of sparse matrixes or mapping ids. Preparing data for models is as simple asdataset = Dataset.construct(interactions_df)Fitting any model is as simple asmodel.fit(dataset)For getting recommendationsfilter_viewedanditems_to_recommendoptions are availableFor item-to-item recommendations userecommend_to_itemsmethodFor feeding user/item features to model just specify dataframes when constructingDataset.Check our tutorialContributionTo install all requirements runmake installYou must havepython3andpoetry==1.4.0installed.For autoformatting runmake formatFor linters check runmake lintFor tests runmake testFor coverage runmake coverageTo remove virtual environment runmake cleanRecTools.TeamEmiliy FeldmanIldar SafiloDaniil PotapovIgor BelkovArtem SeninAlexander ButenkoMikhail KhasykovDaria Tikhonovich