Commit 5ad396a4ec22b4657c0e737bd05ad0dc1c9e165a

Authored by Tássia Camões Araújo
1 parent ad248928
Exists in master and in 1 other branch add_vagrant

Updated scripts to pick a random popcon submission as the target user of recommender.

Showing 2 changed files with 127 additions and 0 deletions   Show diff stats
src/bin/apprec.py 0 → 100755
... ... @@ -0,0 +1,60 @@
  1 +#!/usr/bin/env python
  2 +"""
  3 + AppRecommender - A GNU/Linux application recommender
  4 +"""
  5 +__author__ = "Tassia Camoes Araujo <tassia@gmail.com>"
  6 +__copyright__ = "Copyright (C) 2011 Tassia Camoes Araujo"
  7 +__license__ = """
  8 + This program is free software: you can redistribute it and/or modify
  9 + it under the terms of the GNU General Public License as published by
  10 + the Free Software Foundation, either version 3 of the License, or
  11 + (at your option) any later version.
  12 +
  13 + This program is distributed in the hope that it will be useful,
  14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + GNU General Public License for more details.
  17 +
  18 + You should have received a copy of the GNU General Public License
  19 + along with this program. If not, see <http://www.gnu.org/licenses/>.
  20 +"""
  21 +
  22 +import os
  23 +import sys
  24 +sys.path.insert(0,'../')
  25 +import logging
  26 +import datetime
  27 +import random
  28 +from datetime import timedelta
  29 +
  30 +from config import *
  31 +from data import *
  32 +from evaluation import *
  33 +from dissimilarity import *
  34 +from recommender import *
  35 +from strategy import *
  36 +from user import *
  37 +from error import Error
  38 +
  39 +if __name__ == '__main__':
  40 + try:
  41 + begin_time = datetime.datetime.now()
  42 + logging.debug("Computation started at %s" % begin_time)
  43 + cfg = Config()
  44 + rec = Recommender(cfg)
  45 + user = RandomPopcon(cfg.popcon_dir,os.path.join(cfg.filters,"desktop"))
  46 + #user = LocalSystem()
  47 + user.filter_pkg_profile(os.path.join(cfg.filters,"desktop"))
  48 + user.maximal_pkg_profile()
  49 +
  50 + logging.info("Recommending applications for user %s" % user.user_id)
  51 + logging.info(rec.get_recommendation(user,20))
  52 +
  53 + end_time = datetime.datetime.now()
  54 + logging.debug("Computation completed at %s" % end_time)
  55 + delta = end_time - begin_time
  56 + logging.info("Time elapsed: %d seconds." % delta.seconds)
  57 +
  58 + except Error:
  59 + logging.critical("Aborting proccess. Use '--debug' for more details.")
  60 +
... ...
src/bin/cross_validation.py 0 → 100755
... ... @@ -0,0 +1,67 @@
  1 +#!/usr/bin/env python
  2 +"""
  3 + CrossValidation - python module for classes and methods related to
  4 + recommenders evaluation.
  5 +"""
  6 +__author__ = "Tassia Camoes Araujo <tassia@gmail.com>"
  7 +__copyright__ = "Copyright (C) 2011 Tassia Camoes Araujo"
  8 +__license__ = """
  9 + This program is free software: you can redistribute it and/or modify
  10 + it under the terms of the GNU General Public License as published by
  11 + the Free Software Foundation, either version 3 of the License, or
  12 + (at your option) any later version.
  13 +
  14 + This program is distributed in the hope that it will be useful,
  15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17 + GNU General Public License for more details.
  18 +
  19 + You should have received a copy of the GNU General Public License
  20 + along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 +"""
  22 +
  23 +import os
  24 +import sys
  25 +sys.path.insert(0,'../')
  26 +import logging
  27 +import datetime
  28 +from datetime import timedelta
  29 +
  30 +from config import *
  31 +from data import *
  32 +from evaluation import *
  33 +from dissimilarity import *
  34 +from recommender import *
  35 +from strategy import *
  36 +from user import *
  37 +from error import Error
  38 +
  39 +if __name__ == '__main__':
  40 + try:
  41 + cfg = Config()
  42 + rec = Recommender(cfg)
  43 + user = RandomPopcon(cfg.popcon_dir,os.path.join(cfg.filters,"desktop"))
  44 + user.filter_pkg_profile(os.path.join(cfg.filters,"desktop"))
  45 + user.maximal_pkg_profile()
  46 + begin_time = datetime.datetime.now()
  47 +
  48 + metrics = []
  49 + metrics.append(Precision())
  50 + metrics.append(Recall())
  51 + metrics.append(F1())
  52 + metrics.append(Accuracy())
  53 + metrics.append(SimpleAccuracy())
  54 + validation = CrossValidation(0.9,10,rec,metrics,0.1)
  55 + validation.run(user)
  56 + print validation
  57 +
  58 + end_time = datetime.datetime.now()
  59 + delta = end_time - begin_time
  60 + logging.info("Cross-validation for user %s" % user.user_id)
  61 + logging.info("Recommender strategy: %s" % rec.strategy.description)
  62 + logging.debug("Cross-validation started at %s" % begin_time)
  63 + logging.debug("Cross-validation completed at %s" % end_time)
  64 + logging.info("Time elapsed: %d seconds." % delta.seconds)
  65 +
  66 + except Error:
  67 + logging.critical("Aborting proccess. Use '--debug' for more details.")
... ...