Exemplo n.º 1
0
 def run(): 
     dataArgs = argparse.Namespace()
     dataArgs.maxIter = 3 
     #Set iterStartDate to None for all iterations 
     #dataArgs.iterStartTimeStamp = None 
     dataArgs.iterStartTimeStamp = time.mktime(datetime(2005,1,1).timetuple())
     generator = MovieLensDataset(maxIter=dataArgs.maxIter, iterStartTimeStamp=dataArgs.iterStartTimeStamp)        
     
     defaultAlgoArgs = argparse.Namespace()
     defaultAlgoArgs.ks = numpy.array(2**numpy.arange(6, 7, 0.5), numpy.int)
     defaultAlgoArgs.svdAlgs = ["rsvd"]   
     defaultAlgoArgs.runSoftImpute = True
     
     dataParser = argparse.ArgumentParser(description="", add_help=False)
     dataParser.add_argument("-h", "--help", action="store_true", help="show this help message and exit")
     devNull, remainingArgs = dataParser.parse_known_args(namespace=dataArgs)
     
     dataArgs.extendedDirName = ""
     dataArgs.extendedDirName += "MovieLensDataset"
     
     recommendExpHelper = RecommendExpHelper(generator.getTrainIteratorFunc, generator.getTestIteratorFunc, remainingArgs, defaultAlgoArgs, dataArgs.extendedDirName)
     recommendExpHelper.printAlgoArgs()
     #    os.makedirs(resultsDir, exist_ok=True) # for python 3.2
     try:
         os.makedirs(recommendExpHelper.resultsDir)
     except OSError as err:
         if err.errno != errno.EEXIST:
             raise
     
     recommendExpHelper.runExperiment()
Exemplo n.º 2
0
    helpParser  = argparse.ArgumentParser(description="", add_help=False, parents=[dataParser, RecommendExpHelper.newAlgoParser(defaultAlgoArgs)])
    helpParser.print_help()
    exit()

dataArgs.extendedDirName = ""
dataArgs.extendedDirName += "ContactsDataset"

# print args #
logging.info("Running on ContactsDataset")
logging.info("Data params:")
keys = list(vars(dataArgs).keys())
keys.sort()
for key in keys:
    logging.info("    " + str(key) + ": " + str(dataArgs.__getattribute__(key)))

# data
generator = ContactsDataset(maxIter=dataArgs.maxIter, iterStartTimeStamp=dataArgs.iterStartTimeStamp)

# run
logging.info("Creating the exp-runner")
recommendExpHelper = RecommendExpHelper(generator.getTrainIteratorFunc, generator.getTestIteratorFunc, remainingArgs, defaultAlgoArgs, dataArgs.extendedDirName)
recommendExpHelper.printAlgoArgs()
#    os.makedirs(resultsDir, exist_ok=True) # for python 3.2
try:
    os.makedirs(recommendExpHelper.resultsDir)
except OSError as err:
    if err.errno != errno.EEXIST:
        raise

recommendExpHelper.runExperiment()