class_docstr: Propensity-based Stratified Evaluation Method proposed by Jadidinejad et al. (2021)
  
  Parameters
  ----------
  data: array-like, required
      Raw preference data in the triplet format [(user_id, item_id, rating_value)].
  
  test_size: float, optional, default: 0.2
      The proportion of the test set, 
      if > 1 then it is treated as the size of the test set.
  
  val_size: float, optional, default: 0.0
      The proportion of the validation set,         if > 1 then it is treated as the size of the validation set.
  
  n_strata: int, optional, default: 2
      The number of strata for propensity-based stratification.
  
  rating_threshold: float, optional, default: 1.0
      Threshold used to binarize rating values into positive or negative feedback for
      model evaluation using ranking metrics (rating metrics are not affected).
  
  seed: int, optional, default: None
      Random seed for reproducibility.
  
  exclude_unknowns: bool, optional, default: True
      If `True`, unknown users and items will be ignored during model evaluation.
  
  verbose: bool, optional, default: False
      Output running log.
  
  References
  ----------
  Amir H. Jadidinejad, Craig Macdonald and Iadh Ounis, 
  The Simpson's Paradox in the Offline Evaluation of Recommendation Systems, 
  ACM Transactions on Information Systems (to appear)
  https://arxiv.org/abs/2104.08912
class_docstr_tok: ["Propensity-based","Stratified","Evaluation","Method","proposed","by","Jadidinejad","et","al",".","(","2021",")","Parameters","--","--","--","--","--","data",":","array-like",",","required","Raw","preference","data","in","the","triplet","format","[","(","user_id",",","item_id",",","rating_value",")","]",".","test_size",":","float",",","optional",",","default",":","0.2","The","proportion","of","the","test","set",",","if",">","1","then","it","is","treated","as","the","size","of","the","test","set",".","val_size",":","float",",","optional",",","default",":","0.0","The","proportion","of","the","validation","set",",","if",">","1","then","it","is","treated","as","the","size","of","the","validation","set",".","n_strata",":","int",",","optional",",","default",":","2","The","number","of","strata","for","propensity-based","stratification",".","rating_threshold",":","float",",","optional",",","default",":","1.0","Threshold","used","to","binarize","rating","values","into","positive","or","negative","feedback","for","model","evaluation","using","ranking","metrics","(","rating","metrics","are","not","affected",")",".","seed",":","int",",","optional",",","default",":","None","Random","seed","for","reproducibility",".","exclude_unknowns",":","bool",",","optional",",","default",":","True","If","`","True","`",",","unknown","users","and","items","will","be","ignored","during","model","evaluation",".","verbose",":","bool",",","optional",",","default",":","False","Output","running","log",".","References","--","--","--","--","--","Amir","H.","Jadidinejad",",","Craig","Macdonald","and","Iadh","Ounis",",","The","Simpson","'s","Paradox","in","the","Offline","Evaluation","of","Recommendation","Systems",",","ACM","Transactions","on","Information","Systems","(","to","appear",")","https",":","\/\/arxiv.org\/abs\/2104.08912"]
code: def _eval(self, model, test_set, val_set, user_based, props=None):
      metric_avg_results = OrderedDict()
      metric_user_results = OrderedDict()
  
      avg_results, user_results = rating_eval(
          model=model,
          metrics=self.rating_metrics,
          test_set=test_set,
          user_based=user_based,
      )
      for i, mt in enumerate(self.rating_metrics):
          metric_avg_results[mt.name] = avg_results[i]
          metric_user_results[mt.name] = user_results[i]
  
      avg_results, user_results = ranking_eval(
          model=model,
          metrics=self.ranking_metrics,
          train_set=self.train_set,
          test_set=test_set,
          val_set=val_set,
          rating_threshold=self.rating_threshold,
          exclude_unknowns=self.exclude_unknowns,
          verbose=self.verbose,
          props=props,
      )
      for i, mt in enumerate(self.ranking_metrics):
          metric_avg_results[mt.name] = avg_results[i]
          metric_user_results[mt.name] = user_results[i]
  
      return Result(model.name, metric_avg_results, metric_user_results)
  
file_path: cornac/cornac/eval_methods/propensity_stratified_evaluation.py
imports: import time
  from collections import defaultdict
  from collections import OrderedDict
  import powerlaw
  import numpy
  import tqdm.auto
  from ..utils.common import safe_indexing
  from ..data import Dataset
  from .base_method import BaseMethod, rating_eval
  from .ratio_split import RatioSplit
  from ..experiment.result import Result, PSTResult
label_desc: Use image node_id 2 for calling the PropensityStratifiedEvaluation obj's underlying member method code with example usage: obj._eval(model, test_set, val_set, user_based, props) and returns: Result