Package: irec
Introduction•Install•Quick StartiRec is structured in three main components as usually made by classical frameworks in the RS field. These main components are:•Environment Setting: responsible for loading, preprocessing, and splitting the dataset into train and test sets (when required) to create the task environment for the pipeline;•Recommendation Agent: responsible for implementing the recommendation model required as an interactive algorithm that will interact with the environment;•Experimental Evaluation: responsible for defining how the agent will interact with the environment to simulate the interactive scenario and get the logs required for a complete evaluation.IntroductionFor Python >= 3.8Interactive Recommender Systems FrameworkMain features:Several state-of-the-art reinforcement learning models for the recommendation scenarioNovelty, coverage and much more different type of online metricsIntegration with the most used datasets for evaluating recommendation systemsFlexible configurationModular and reusable designContains multiple evaluation policies currently used in the literature to evaluate reinforcement learning modelsOnline Learning and Reinforcement Learning modelsMetrics and metrics evaluators are awesome to evaluate recommender systems in different waysAlso, we provide a amazing application created using the iRec library, theiRec-cmdline, that can be used to setup a experiment under 5~ minutes with parallel processes, log registry and results views. The main features are:Powerful application to run any reinforcement learning experiment powered by MLflowEntire pipeline of execution is fully parallelizedLog registryResults viewsStatistical testExtensible environmentInstallInstall with pip:pip install irecExamplesiRec-cmdlinecontains a example of a application using iRec and MLflow, where different experiments can be run with easy using existing recommender systems.Check this example of a execution using the example application:dataset=("Netflix 10k" "Good Books" "Yahoo Music 10k");\
models=(Random MostPopular UCB ThompsonSampling EGreedy);\
metrics=(Hits Precision Recall);\
eval_pol=("FixedInteraction");
metric_evaluator="Interaction";\

cd agents &&
python run_agent_best.py --agents "${models[@]}" --dataset_loaders "${dataset[@]}" --evaluation_policy "${eval_pol[@]}" &&

cd ../evaluation &&
python eval_agent_best.py --agents "${models[@]}" --dataset_loaders "${dataset[@]}" --evaluation_policy "${eval_pol[@]}" --metrics "${metrics[@]}" --metric_evaluator "${metric_eval[@]}" &&

python print_latex_table_results.py --agents "${models[@]}" --dataset_loaders "${dataset[@]}" --evaluation_policy "${eval_pol[@]}" --metric_evaluator "${metric_eval[@]}" --metrics "${metrics[@]}"DatasetsOur framework has the ability to use any type of dataset, as long as it is suitable for the recommendation domain and is formatted correctly. Below we list some datasets tested and used in some of our experiments.DatasetDomainSparsityLinkMovieLens 100kMovies93.69%LinkMovieLens 1MMovies95.80%LinkMovieLens 10MMovies98.66%LinkNetflixMovies98.69%LinkCiao DVDMovies99.97%LinkYahoo MusicMusics97.63%LinkLastFMMusics99.84%LinkGood BooksBooks98.88%LinkGood ReadsBooks99.50%LinkAmazon Kindle StoreProducts99.97%LinkClothing FitClothes99.97%LinkModelsTherecommender modelssupported by irec are listed below.YearModelPaperDescription2002ε-GreedyLinkIn general, ε-Greedy models the problem based on an ε diversification parameter to perform random actions.2013Linear ε-GreedyLinkA linear exploitation of the items latent factors defined by a PMF formulation that also explore random items with probability ε.2011Thompson SamplingLinkA basic item-oriented bandit algorithm that follows a Gaussian distribution of items and users to perform the prediction rule based on their samples.2013GLM-UCBLinkIt follows a similar process as Linear UCB based on the PMF formulation, but it also adds a sigmoid form in the exploitation step and makes a time-dependent exploration.2018ICTRLinkIt is an interactive collaborative topic regression model that utilizes the TS bandit algorithm and controls the items dependency by a particle learning strategy.2015PTSLinkIt is a PMF formulation for the original TS based on a Bayesian inference around the items. This method also applies particle filtering to guide the exploration of items over time.2019kNN BanditLinkA simple multi-armed bandit elaboration of neighbor-based collaborative filtering. A variant of the nearest-neighbors scheme, but endowed with a controlled stochastic exploration capability of the users’ neighborhood, by a parameter-free application of Thompson sampling.2017Linear TSLinkAn adaptation of the original Thompson Sampling to measure the latent dimensions by a PMF formulation.2013Linear UCBLinkAn adaptation of the original LinUCB (Lihong Li et al. 2010) to measure the latent dimensions by a PMF formulation.2020NICFLinkIt is an interactive method based on a combination of neural networks and  collaborative filtering that also performs a meta-learning of the user’s preferences.2016COFIBALinkThis method relies on upper-confidence-based tradeoffs between exploration and exploitation, combined with adaptive clustering procedures at both the user and the item sides.2002UCBLinkIt is the original UCB that calculates a confidence interval for each item at each iteration and tries to shrink the confidence bounds.2021Cluster-Bandit (CB)Linkit is a new bandit algorithm based on clusters to face the cold-start problem.2002EntropyLinkThe entropy of an item i is calculated using the relative frequency of the possible ratings. In general, since entropy measures the spread of ratings for an item, this strategy tends to promote rarely rated items, which can be considerably informative.2002log(pop)*entLinkIt combines popularity and entropy to identify potentially relevant items that also have the ability to add more knowledge to the system. As these concepts are not strongly correlated, it is possible to achieve this combination through a linear combination of the popularity ρ of an item i by its entropy ε: score(i) = log(ρi) · εi.-RandomLinkThis method recommends totally random items.-Most PopularLinkIt recommends items with the higher number of ratings received (most-popular) at each iteration.-Best RatedLinkRecommends top-rated items based on their average ratings in each iteration.MetricsTherecommender metricssupported by iRec are listed below.MetricReferenceDescriptionHitsLinkNumber of recommendations made successfully.PrecisionLinkPrecision is defined as the percentage of predictions we get right.RecallLinkRepresents the probability that a relevant item will be selected.EPCLinkRepresents the novelty for each user and it is measured by the expected number of seen relevant recommended items not previously seen.EPDLinkEPD is a distance-based novelty measure, which looks at distances between the items in the user’s profile and the recommended items.ILDLinkIt represents the diversity between the list of items recommended. This diversity is measured by the Pearson correlation of the item’s features vector.Gini CoefficientLinkDiversity is represented as the Gini coefficient – a measure of distributional inequality. It is measured as the inverse of cumulative frequency that each item is recommended.Users CoverageLinkIt represents the percentage of distinct users that are interested in at least k items recommended (k ≥ 1).APIFor writing anything new to the library (e.g., value function, agent, etc) read thedocumentation.ContributingAll contributions are welcome! Just open a pull request.Related ProjectsiRec-cmdline