Esempio n. 1
0
class QueryCutterTestCase(unittest.TestCase):
    def setUp(self):
        self.qc = QueryCutter("101-150", 25) 
    def testCutResult(self):
        onefold, nfolds = self.qc.generate_range_pairs() 
        self.assertEqual(cmp(onefold, ['101-125', '126-150']) , 0)
        self.assertEqual(cmp(nfolds, ['126-150', '101-125']) , 0)
Esempio n. 2
0
#from termcolor import colored

if (len(sys.argv) != 5):
    print "Help:the format is: python nFoldcrossValid.py collectionPath strategy " +\
            "queryIdRange idgap" 

collection = sys.argv[1]
allresults = collection 
docNums = ["5", "10", "20", "30", "50"]
betas = [u"0.*"]
strategy = sys.argv[2]
cutter = QueryCutter(sys.argv[3], int(sys.argv[4]))
#parities = ["Odd", "Even"]
#parities = ["451-475","476-500"]
CVIdPairs = {}
oneFold, nFold = cutter.generate_range_pairs()
for i in range(len(oneFold)):
    if nFold[i] == "151-195":
        nFold[i] = "151-195,201-200"
    CVIdPairs[nFold[i].replace(",", "")] = oneFold[i]




cmds =[]
for docNum in docNums:
    for beta in betas:
        for parity in CVIdPairs.keys():
		#DPH_QEAdap_RocDFRPow=1.5FromTop_10_20_TFIDF0.2
		if strategy == "Roc":
		    cmd  = u"./listMAP.py " + allresults +u"/|grep Q" + parity +u"DPH_QEAdap_RocDFRPow=1.5FromTop_" + docNum + u"_20_TFIDF|cut -d: -f3|sort"