class_docstr: NegativeSampler class for NCF. Samples a subset of negative items from a given population of items.
class_docstr_tok: ["NegativeSampler","class","for","NCF",".","Samples","a","subset","of","negative","items","from","a","given","population","of","items","."]
docstr: Constructor
  
  Args:
      user (str or int): User to be sampled for.
      n_samples (int): Number of required samples.
      user_positive_item_pool (set): Set of items with which user has previously interacted.
      item_pool (set): Set of all items in population.
      sample_with_replacement (bool): If true, sample negative examples with replacement,
          otherwise without replacement.
      print_warnings (bool): If true, prints warnings if sampling without replacement and
          there are not enough items to sample from to satisfy n_neg or n_neg_test.
      training (bool): Set to true if sampling for the training set or false if for the test set.
docstr_tok: ["Constructor","Args",":","user","(","str","or","int",")",":","User","to","be","sampled","for",".","n_samples","(","int",")",":","Number","of","required","samples",".","user_positive_item_pool","(","set",")",":","Set","of","items","with","which","user","has","previously","interacted",".","item_pool","(","set",")",":","Set","of","all","items","in","population",".","sample_with_replacement","(","bool",")",":","If","true",",","sample","negative","examples","with","replacement",",","otherwise","without","replacement",".","print_warnings","(","bool",")",":","If","true",",","prints","warnings","if","sampling","without","replacement","and","there","are","not","enough","items","to","sample","from","to","satisfy","n_neg","or","n_neg_test",".","training","(","bool",")",":","Set","to","true","if","sampling","for","the","training","set","or","false","if","for","the","test","set","."]
code: def __init__(
      self,
      user,
      n_samples,
      user_positive_item_pool,
      item_pool,
      sample_with_replacement,
      print_warnings=True,
      training=True,
  ):
      """Constructor
  
      Args:
          user (str or int): User to be sampled for.
          n_samples (int): Number of required samples.
          user_positive_item_pool (set): Set of items with which user has previously interacted.
          item_pool (set): Set of all items in population.
          sample_with_replacement (bool): If true, sample negative examples with replacement,
              otherwise without replacement.
          print_warnings (bool): If true, prints warnings if sampling without replacement and
              there are not enough items to sample from to satisfy n_neg or n_neg_test.
          training (bool): Set to true if sampling for the training set or false if for the test set.
      """
      self.user = user
      self.n_samples = n_samples
      self.user_positive_item_pool = user_positive_item_pool
      self.item_pool = item_pool
      self.sample_with_replacement = sample_with_replacement
      self.print_warnings = print_warnings
      self.training = training
  
      self.user_negative_item_pool = self._get_user_negatives_pool()
      self.population_size = len(self.user_negative_item_pool)
      self._sample = (
          self._sample_negatives_with_replacement
          if self.sample_with_replacement
          else self._sample_negatives_without_replacement
      )
      if not self.sample_with_replacement:
          self._check_sample_size()
  
imports: import os
  from collections import OrderedDict
  import random
  import numpy
  import pandas
  import csv
  import logging
  from tqdm import tqdm
  from recommenders.utils.constants import DEFAULT_ITEM_COL, DEFAULT_USER_COL, DEFAULT_RATING_COL
label_desc: Use image node_id 1 to create a new NegativeSampler object  with example: obj = NegativeSampler(user, n_samples, user_positive_item_pool, item_pool, sample_with_replacement, print_warnings, training)