Package: ml-recsys-tools
ml-recsys-toolsThis is an updated version of thestale ml-recsys-tools source repoOpen source repo for various tools for recommender systems development work.Main purpose is to provide a single wrapper for various recommender packages to train, tune, evaluate and get data in and recommendations / similarities out.Installation:Pip:PyPi:pip install ml-recsys-toolsGithubmaster:pip install git+https://github.com/artdgn/ml-recsys-tools@master#egg=ml_recsys_toolsBasic usage:# dataset: download and prepare dataframesfromml_recsys_tools.datasets.prep_movielense_dataimportget_and_prep_datarating_csv_path,users_csv_path,movies_csv_path=get_and_prep_data()# read the interactions dataframe and create a data handler object and  split to train and testimportpandasaspdratings_df=pd.read_csv(rating_csv_path)fromml_recsys_tools.data_handlers.interaction_handlers_baseimportObservationsDFobs=ObservationsDF(ratings_df,uid_col='userid',iid_col='itemid')train_obs,test_obs=obs.split_train_test(ratio=0.2)# train and test LightFM recommenderfromml_recsys_tools.recommenders.lightfm_recommenderimportLightFMRecommenderlfm_rec=LightFMRecommender()lfm_rec.fit(train_obs,epochs=10)# print summary evaluation report:print(lfm_rec.eval_on_test_by_ranking(test_obs.df_obs,prefix='lfm ',n_rec=100))# get all recommendations and print a sample (training interactions are filtered out by default)recs=lfm_rec.get_recommendations(lfm_rec.all_users,n_rec=5)print(recs.sample(5))# get all similarities and print a samplesimils=lfm_rec.get_similar_items(lfm_rec.all_items,n_simil=5)print(simils.sample(10))Additional examples in theexamples/folder:Cosine similarityEnsemblesHybrid features for LightFMAdditional recommendersUsing multiple testsetsandEvaluationRecommender models and tools:LightFMpackage based recommender.Implicitpackage based ALS recommender.Evaluation features added for most recommenders:Dataframes for all inputs and outputsadding external features (for LightFM hybrid mode)fast batched methods for:user recommendation samplingsimilar items samplilng with different similarity measuressimilar users samplingevaluation by sampling and rankingdense user x item recommendation and item x item similarityAdditional recommender models:Similarity based:cooccurence (items, users)generic similarity based (can be used with external features)Ensembles:subdivision based (multiple recommenders each on subset of data - e.g. geographical region):geo based: simple grid, equidense grid, geo clusteringLightFM and cooccurrence basedcombination based - combining recommendations from multiple recommenderssimilarity combination based - similarity based recommender on similarities from multiple recommenderscascade ensembleInteraction dataframe and sparse matrix handlers / builders:sampling, data splitting,external features matrix creation (additional item features),
with feature engineering: binning / one*hot encoding (via pandas_sklearn)evaluation and ranking helpershandlers for observations coupled with external features and features with geo coordinatesEvaluation utils:score reports on lightfm metrics (AUC, precision, recall, reciprocal)n-DCG, and n-MRR metrics, n-precision / recallreferences: best possible ranking and chance rankingUtilities:similarity calculation helpers (similarities, dot, top N, top N on sparse)parallelism utilssklearn transformer extenstions (for feature engineering)logging, debug printouts decorators and other instrumentation and inspection toolspandas utils