class_docstr: Dataset class for NCF
class_docstr_tok: ["Dataset","class","for","NCF"]
docstr: Constructor
  
  Args:
      train_file (str): Path to training dataset file.
      test_file (str): Path to test dataset file for leave-one-out evaluation.
      test_file_full (str): Path to full test dataset file including negative samples.
      overwrite_test_file_full (bool): If true, recreate and overwrite test_file_full.
      n_neg (int): Number of negative samples per positive example for training set.
      n_neg_test (int): Number of negative samples per positive example for test set.
      col_user (str): User column name.
      col_item (str): Item column name.
      col_rating (str): Rating column name.
      binary (bool): If true, set rating > 0 to rating = 1.
      seed (int): Seed.
      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.
docstr_tok: ["Constructor","Args",":","train_file","(","str",")",":","Path","to","training","dataset","file",".","test_file","(","str",")",":","Path","to","test","dataset","file","for","leave-one-out","evaluation",".","test_file_full","(","str",")",":","Path","to","full","test","dataset","file","including","negative","samples",".","overwrite_test_file_full","(","bool",")",":","If","true",",","recreate","and","overwrite","test_file_full",".","n_neg","(","int",")",":","Number","of","negative","samples","per","positive","example","for","training","set",".","n_neg_test","(","int",")",":","Number","of","negative","samples","per","positive","example","for","test","set",".","col_user","(","str",")",":","User","column","name",".","col_item","(","str",")",":","Item","column","name",".","col_rating","(","str",")",":","Rating","column","name",".","binary","(","bool",")",":","If","true",",","set","rating",">","0","to","rating","=","1.","seed","(","int",")",":","Seed",".","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","."]
code: def __init__(
      self,
      train_file,
      test_file=None,
      test_file_full=None,
      overwrite_test_file_full=False,
      n_neg=4,
      n_neg_test=100,
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
      col_rating=DEFAULT_RATING_COL,
      binary=True,
      seed=None,
      sample_with_replacement=False,
      print_warnings=False,
  ):
      """Constructor
  
      Args:
          train_file (str): Path to training dataset file.
          test_file (str): Path to test dataset file for leave-one-out evaluation.
          test_file_full (str): Path to full test dataset file including negative samples.
          overwrite_test_file_full (bool): If true, recreate and overwrite test_file_full.
          n_neg (int): Number of negative samples per positive example for training set.
          n_neg_test (int): Number of negative samples per positive example for test set.
          col_user (str): User column name.
          col_item (str): Item column name.
          col_rating (str): Rating column name.
          binary (bool): If true, set rating > 0 to rating = 1.
          seed (int): Seed.
          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.
      """
      self.train_file = train_file
      self.test_file = test_file
      self.test_file_full = test_file_full
      self.overwrite_test_file_full = overwrite_test_file_full
      self.n_neg = n_neg
      self.n_neg_test = n_neg_test
      self.col_user = col_user
      self.col_item = col_item
      self.col_rating = col_rating
      self.binary = binary
      self.sample_with_replacement = sample_with_replacement
      self.print_warnings = print_warnings
  
      self.col_test_batch = "test_batch"
  
      self.train_datafile = DataFile(
          filename=self.train_file,
          col_user=self.col_user,
          col_item=self.col_item,
          col_rating=self.col_rating,
          binary=self.binary,
      )
  
      self.n_users = len(self.train_datafile.users)
      self.n_items = len(self.train_datafile.items)
      self.user2id = self.train_datafile.user2id
      self.item2id = self.train_datafile.item2id
      self.id2user = self.train_datafile.id2user
      self.id2item = self.train_datafile.id2item
      self.train_len = self.train_datafile.data_len
  
      if self.test_file is not None:
          self.test_datafile = DataFile(
              filename=self.test_file,
              col_user=self.col_user,
              col_item=self.col_item,
              col_rating=self.col_rating,
              binary=self.binary,
          )
          if self.test_file_full is None:
              self.test_file_full = (
                  os.path.splitext(self.test_file)[0] + "_full.csv"
              )
          if self.overwrite_test_file_full or not os.path.isfile(
              self.test_file_full
          ):
              self._create_test_file()
          self.test_full_datafile = DataFile(
              filename=self.test_file_full,
              col_user=self.col_user,
              col_item=self.col_item,
              col_rating=self.col_rating,
              col_test_batch=self.col_test_batch,
              binary=self.binary,
          )
      # set random seed
      random.seed(seed)
  
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 Dataset object from inherited base classes: object with example: obj = Dataset(train_file, test_file, test_file_full, overwrite_test_file_full, n_neg, n_neg_test, col_user, col_item, col_rating, binary, seed, sample_with_replacement, print_warnings)