Пример #1
0
 def setUpClass(self):
     cfg = Config()
     cfg.popcon_index = "test_data/.sample_pxi"
     cfg.popcon_dir = "test_data/popcon_dir"
     cfg.clusters_dir = "test_data/clusters_dir"
     cfg.popcon = 0
     self.rec = Recommender()
Пример #2
0
 def setUpClass(self):
     cfg = Config()
     cfg.popcon_index = "test_data/.sample_pxi"
     cfg.popcon_dir = "test_data/popcon_dir"
     cfg.clusters_dir = "test_data/clusters_dir"
     cfg.popcon = 0
     self.rec = Recommender()
import os
import logging

sys.path.insert(0, '../')

from apprecommender.config import Config
from apprecommender.data import PopconXapianIndex

if __name__ == '__main__':

    cfg = Config()
    cfg.index_mode = "recluster"
    logging.info("Starting clustering experiments")
    logging.info("Medoids: %d\t Max popcon:%d" %
                 (cfg.k_medoids, cfg.max_popcon))
    cfg.popcon_dir = os.path.expanduser(
        "~/org/popcon.debian.org/popcon-mail/popcon-entries/")
    cfg.popcon_index = cfg.popcon_index + ("_%dmedoids%dmax" %
                                           (cfg.k_medoids, cfg.max_popcon))
    cfg.clusters_dir = cfg.clusters_dir + ("_%dmedoids%dmax" %
                                           (cfg.k_medoids, cfg.max_popcon))
    pxi = PopconXapianIndex(cfg)
    logging.info("Overall dispersion: %f\n" % pxi.cluster_dispersion)
    # Write clustering log
    output = open(("results/clustering/%dmedoids%dmax" %
                  (cfg.k_medoids, cfg.max_popcon)), 'w')
    output.write("# k_medoids\tmax_popcon\tdispersion\n")
    output.write("%d %f\n" %
                 (cfg.k_medoids, cfg.max_popcon, pxi.cluster_dispersion))
    output.close()
Пример #4
0
    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"
Пример #5
0
    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"