def load(self): config = Config() short_options = 'hdvo:d:v:s:z:idvo:tdvo:b:n:cdvo' long_options = ['help', 'debug', 'verbose', 'strategy=', 'profile_size=', 'init', 'train', 'because', 'nrecommendation', 'contribute'] try: opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) self.options = opts except getopt.GetoptError as error: config.set_logger() logging.error('Bad syntax: {}'.format(str(error))) self.usage() sys.exit() for o, p in opts: if o in ('-h', '--help'): self.usage() sys.exit() elif o in ('-d', '--debug'): config.debug = 1 elif o in ('-v', '--verbose'): config.verbose = 1 elif o in ('-s', '--strategy'): config.strategy = p elif o in ('-z', '--profile_size'): config.profile_size = int(p) elif o in ('-i', '--init'): continue elif o in ('-t', '--train'): continue elif o in ('-b', '--because'): config.because = True elif o in ('-n', '--num-recommendations'): config.num_recommendations = int(p) elif o in ('-c', '--contribute'): continue else: assert False, "unhandled option"
c_100[size] = set() p_10_summary[size] = [] f05_100_summary[size] = [] with open(log_file + "-%s%.3d" % (option_str, size), 'w') as f: f.write("# sample %s\n" % sample_str) f.write("# strategy %s-%s%.3d\n\n" % (cfg.strategy, option_str, size)) f.write("# p_10\tf05_100\n\n") # main loop per user for submission_file in population_sample: user = PopconSystem(submission_file) user.filter_pkg_profile(cfg.pkgs_filter) user.maximal_pkg_profile() for size in sizes: cfg.profile_size = size cfg.k_neighbors = size rec = Recommender(cfg) repo_size = rec.items_repository.get_doccount() p_10 = [] f05_100 = [] for n in range(iterations): # Fill sample profile profile_len = len(user.pkg_profile) item_score = {} for pkg in user.pkg_profile: item_score[pkg] = user.item_score[pkg] sample = {} sample_size = int(profile_len * 0.9) for i in range(sample_size): key = random.choice(item_score.keys())
def load(self): config = Config() short_options = "hdvo:f:b:a:e:p:m:u:l:c:x:w:s:z:r:n:idvo:tdvo" long_options = ["help", "debug", "verbose", "output=", "filtersdir=", "pkgsfilter=", "axi=", "dde=", "popconindex=", "popcondir=", "indexmode=", "clustersdir=", "kmedoids=", "maxpopcon=", "weight=", "strategy=", "profile_size=", "profiling=", "neighbors=", "init", "train"] try: opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) self.options = opts except getopt.GetoptError as error: config.set_logger() logging.error("Bad syntax: %s" % str(error)) self.usage() sys.exit() for o, p in opts: if o in ("-h", "--help"): self.usage() sys.exit() elif o in ("-d", "--debug"): config.debug = 1 elif o in ("-v", "--verbose"): config.verbose = 1 elif o in ("-o", "--output"): config.output = p elif o in ("-f", "--filtersdir"): config.filters_dir = p elif o in ("-b", "--pkgsfilter"): config.pkgs_filter = p elif o in ("-a", "--axi"): config.axi = p elif o in ("-e", "--dde"): config.dde_url = p elif o in ("-p", "--popconindex"): config.popcon_index = p elif o in ("-m", "--popcondir"): config.popcon_dir = p elif o in ("-u", "--index_mode"): config.index_mode = p elif o in ("-l", "--clustersdir"): config.clusters_dir = p elif o in ("-c", "--kmedoids"): config.k_medoids = int(p) elif o in ("-x", "--max_popcon"): config.max_popcon = int(p) elif o in ("-w", "--weight"): config.weight = p elif o in ("-s", "--strategy"): config.strategy = p elif o in ("-z", "--profile_size"): config.profile_size = int(p) elif o in ("-z", "--profiling"): config.profiling = p elif o in ("-n", "--neighbors"): config.k_neighbors = int(p) elif o in ("-i", "--init"): continue elif o in ("-t", "--train"): continue else: assert False, "unhandled option"
def load(self): config = Config() short_options = "hdvo:f:b:a:e:p:m:u:l:c:x:w:s:z:r:n:idvo:tdvo" long_options = [ "help", "debug", "verbose", "output=", "filtersdir=", "pkgsfilter=", "axi=", "dde=", "popconindex=", "popcondir=", "indexmode=", "clustersdir=", "kmedoids=", "maxpopcon=", "weight=", "strategy=", "profile_size=", "profiling=", "neighbors=", "init", "train" ] try: opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) self.options = opts except getopt.GetoptError as error: config.set_logger() logging.error("Bad syntax: %s" % str(error)) self.usage() sys.exit() for o, p in opts: if o in ("-h", "--help"): self.usage() sys.exit() elif o in ("-d", "--debug"): config.debug = 1 elif o in ("-v", "--verbose"): config.verbose = 1 elif o in ("-o", "--output"): config.output = p elif o in ("-f", "--filtersdir"): config.filters_dir = p elif o in ("-b", "--pkgsfilter"): config.pkgs_filter = p elif o in ("-a", "--axi"): config.axi = p elif o in ("-e", "--dde"): config.dde_url = p elif o in ("-p", "--popconindex"): config.popcon_index = p elif o in ("-m", "--popcondir"): config.popcon_dir = p elif o in ("-u", "--index_mode"): config.index_mode = p elif o in ("-l", "--clustersdir"): config.clusters_dir = p elif o in ("-c", "--kmedoids"): config.k_medoids = int(p) elif o in ("-x", "--max_popcon"): config.max_popcon = int(p) elif o in ("-w", "--weight"): config.weight = p elif o in ("-s", "--strategy"): config.strategy = p elif o in ("-z", "--profile_size"): config.profile_size = int(p) elif o in ("-z", "--profiling"): config.profiling = p elif o in ("-n", "--neighbors"): config.k_neighbors = int(p) elif o in ("-i", "--init"): continue elif o in ("-t", "--train"): continue else: assert False, "unhandled option"