def reset(self, params, rep):
     if params['name'].startswith("content"):
         cfg = Config()
         # if the index was not built yet
         # app_axi = AppAptXapianIndex(cfg.axi,"results/arnaldo/AppAxi")
         cfg.axi = "data/AppAxi"
         cfg.index_mode = "old"
         cfg.weight = params['weight']
         self.rec = Recommender(cfg)
         self.rec.set_strategy(params['strategy'])
         self.repo_size = self.rec.items_repository.get_doccount()
         self.user = LocalSystem()
         self.user.app_pkg_profile(self.rec.items_repository)
         self.sample_size = int(
             len(self.user.pkg_profile) * params['sample'])
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import sys
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")
Example #3
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"
Example #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"