readme: ---
  language: en
  tags:
  - Recommendation
  license: apache-2.0
  datasets:
  - surprise
  - numpy
  - keras
  - pandas
  thumbnail: https://github.com/Marcosdib/S2Query/Classification_Architecture_model.png
  ---
  
  ![MCTIimg](https://antigo.mctic.gov.br/mctic/export/sites/institucional/institucional/entidadesVinculadas/conselhos/pag-old/RODAPE_MCTI.png)
  
  
  # MCTI Recommendation Task (uncased) DRAFT
  
  Disclaimer: The Brazilian Ministry of Science, Technology, and Innovation (MCTI) has partially supported this project.
  
  The model [NLP MCTI Recommendation Multi](https://huggingface.co/spaces/unb-lamfo-nlp-mcti/nlp-mcti-lda-recommender) is part of the project [Research Financing Product Portfolio (FPP)](https://huggingface.co/unb-lamfo-nlp-mcti) focuses 
  on the task of Recommendation and explores different machine learning strategies that provide suggestions of items that are likely to be handy for a particular individual. Several methods were faced against each other to compare the error estimatives. 
  Using LDA model, a simulated dataset was created.
  
  ## According to the abstract,
  
  Current model card disposes model's description and it's classes. Also, inteded uses are described along with a "how to use" section, exposing necessary conditions for the data used.
  Further in the card, data and it's limitation and bias were discussed. Tables along the page supports the information and tests that were made.
  How the recommendation is made, datasets used and the benchmarks generated are all set all over the model card.  
  
  ## Model description
  
  The surprise library provides 11 classifier models that try to predict the classification of training data based on several different collaborative-filtering techniques.
  The models provided with a brief explanation in English are mentioned below, for more information please refer to the package [documentation](https://surprise.readthedocs.io/en/stable/prediction_algorithms_package.html).
  
  random_pred.NormalPredictor: Algorithm predicting a random rating based on the distribution of the training set, which is assumed to be normal.
  
  baseline_only.BaselineOnly: Algorithm predicting the baseline estimate for given user and item.
  
  knns.KNNBasic: A basic collaborative filtering algorithm.
  
  knns.KNNWithMeans: A basic collaborative filtering algorithm, taking into account the mean ratings of each user.
  
  knns.KNNWithZScore: A basic collaborative filtering algorithm, taking into account the z-score normalization of each user.
  
  knns.KNNBaseline: A basic collaborative filtering algorithm taking into account a baseline rating.
  
  matrix_factorization.SVD: The famous SVD algorithm, as popularized by Simon Funk during the Netflix Prize.
  
  matrix_factorization.SVDpp: The SVD++ algorithm, an extension of SVD taking into account implicit ratings.
  
  matrix_factorization.NMF: A collaborative filtering algorithm based on Non-negative Matrix Factorization.
  
  slope_one.SlopeOne: A simple yet accurate collaborative filtering algorithm.
  
  co_clustering.CoClustering: A collaborative filtering algorithm based on co-clustering.
  
  It is possible to pass a custom dataframe as an argument to this class. The dataframe in question needs to have 3 columns with the following name: ['userID', 'itemID', 'rating'].
  
  ```python
  class Method:
      def __init__(self,df):
          
          self.df=df
          self.available_methods=[
              'surprise.NormalPredictor',
              'surprise.BaselineOnly',
              'surprise.KNNBasic',
              'surprise.KNNWithMeans',
              'surprise.KNNWithZScore',
              'surprise.KNNBaseline',
              'surprise.SVD',
              'surprise.SVDpp',
              'surprise.NMF',
              'surprise.SlopeOne',
              'surprise.CoClustering',
          ]        
          
      def show_methods(self):
          print('The avaliable methods are:')
          for i,method in enumerate(self.available_methods):
              print(str(i)+': '+method)
  
  
  
      def run(self,the_method):
          self.the_method=the_method
          if(self.the_method[0:8]=='surprise'):
              self.run_surprise()
          elif(self.the_method[0:6]=='Gensim'):
              self.run_gensim()
          elif(self.the_method[0:13]=='Transformers-'):
              self.run_transformers()
          else:
              print('This method is not defined! Try another one.')
  
      def run_surprise(self):
          from surprise import Reader
          from surprise import Dataset
          from surprise.model_selection import train_test_split
          reader = Reader(rating_scale=(1, 5))
          data = Dataset.load_from_df(self.df[['userID', 'itemID', 'rating']], reader)        
          trainset, testset = train_test_split(data, test_size=.30)
          the_method=self.the_method.replace("surprise.", "")
          eval(f"exec('from surprise import {the_method}')")
          the_algorithm=locals()[the_method]()
          the_algorithm.fit(trainset)
          self.predictions=the_algorithm.test(testset)
          list_predictions=[(uid,iid,r_ui,est) for uid,iid,r_ui