예제 #1
0
import utils

if __name__ == "__main__":
    inputFile = 'inputQ3'
    inputFile = 'C-small-2-attempt0.in'
    inputFile = 'C-large.in'
    #inputFile = "D-small-attempt0.in"
    #inputFile = "C-small-attempt0.in"
    #inputFile = "A-large.in.txt"
    #inputFile = "inputQ3"
    outputFile = "outputQ3"
    inputData = utils.createReadFile(inputFile)
    outputData = utils.createWriteFile(outputFile)
    cases = inputData.next()
    cases = cases.strip()
    print cases
    for index in range(1, int(cases) + 1):
        print "case ", index
        outputString = "Case #" + str(index) + ": "

        rowData = inputData.next()
        rowData = rowData.strip()
        strs = rowData.split(' ')
        N = int(strs[0])
        K = int(strs[1])
        array = {}
        large = N
        array[large] = 1
        i = 0
        while i < K:
            selectN = large
예제 #2
0
if __name__ == '__main__':
    #movieNum = 3883
    #userNum = 6040
    #movieNum = 75000
    #userNum = 2000
    movieNum = 890000
    userNum = 260000
    separator = '::'
    split = 0.75
    #ratingFileName = 'ml-1m/ratings.dat'
    #ratingFileName = 'EachMovie/eachmovie.dat'
    ratingFileName = 'elect/hk.dat'
    savePrefix = 'electTest/'
    dataset = 'movieLens'
    r = 11
    ratingFile = utils.createReadFile(ratingFileName)
    newRatingFile = reverseID(ratingFile)
    print len(newRatingFile)

    #splitDatasetWithUsers(split, newRatingFile, dataset, savePrefix)
    #splitDatasetWithUsers(split, ratingFile, dataset, savePrefix)
    splitDatasetWithUsers1(r, newRatingFile, dataset, savePrefix)

    #randomGenerateDataSet(ratingFile)

#    timestampArray, ratingDict = parseRatingInfoWithTimestampKey(ratingFile, separator)
#    timestampArray.sort()

#    splitDataWithACertainTime(timestampArray, ratingDict, separator, split)