Exemple #1
0
def dumpPickles(id):
    """
    Persist memory intensive data structures, item similarities.
    """
    print 'Pickle id %s' % (id)

    foldername = '../kfold_cluster_' + id + '/'
    print foldername
    cluster = algorithm.createPrefs(folder=foldername)

    for c in range(8):
        prefs = cluster[c]
        itemsim = algorithm.calculateSimilarItems(prefs, n=50)
        dumpname = "../pickle/" + id + "/oitemsim_" + str(c) + ".pickle"
        pickle.dump(itemsim, open(dumpname, "wb"))
def dumpPickles(id):
    """
    Persist memory intensive data structures, item similarities.
    """
    print 'Pickle id %s'%(id)
    
    foldername = '../kfold_cluster_' + id + '/'
    print foldername
    cluster = algorithm.createPrefs(folder=foldername)
    
    for c in range(8):
        prefs = cluster[c]
        itemsim = algorithm.calculateSimilarItems(prefs, n=50)
        dumpname = "../pickle/" +id + "/oitemsim_" + str(c) + ".pickle"
        pickle.dump(itemsim, open(dumpname, "wb"))
Exemple #3
0
    sparsity.caseone_doAverageFilling(mod_prefs, deleted_users)
    sparsity.saveDenseMatrix(mod_prefs,filename='..\\dataset\\cluster_testing10.tab')
    
    genetic_som.MAX_CLUSTERS = 10
    genetic_som.MIN_CLUSTERS = 4
    
    genetic_som.setFilename= '../dataset/cluster_testing10.tab'
    
    genetic_som.genetic(pop=20,max_evals=100,elites=4)

    #persist clusters onto files. UNVERIFIED
    genetic_som.persistClusters(genetic_som.getChromosomeList(genetic_som.final_pop),
                                filename='../dataset/cluster_testing10.tab', folder='cluster',clustername='cluster_testing')
    
    """
    cluster = algorithm.createPrefs(folder='../cluster/')

    #get cluster mean centroids.
    cluster_centroids = getClusterCentroids(cluster)

    for user in deleted_users:
        user_dict, removed_items = getRemovedPrefs(original_prefs[str(user)],
                                                   10)
        b = getBestCluster(user_dict)

        print "User %s Cluster %s" % (user, b)
        print "Prefs after removal of items: "
        print user_dict

        new_prefs = {}
        new_prefs = cluster[int(b)]
    
    genetic_som.MAX_CLUSTERS = 10
    genetic_som.MIN_CLUSTERS = 4
    
    genetic_som.setFilename= '../dataset/three_dense_matrix.tab'
    
    
    genetic_som.genetic(pop=20,max_evals=100,elites=4)

    #persist clusters onto files. UNVERIFIED
    genetic_som.persistClusters(genetic_som.getChromosomeList(genetic_som.final_pop),
                                filename='../dataset/three_dense_matrix.tab', folder='three',clustername='threecluster')
    
    """
    cluster = algorithm.createPrefs(folder='../five/')

    testingPrefs = getTestPrefs(original_prefs, n=5)

    #use the modified prefs here.
    ostart = time.time()
    oitemsim = original.calculateSimilarItems(testingPrefs, n=50)
    ostop = time.time()

    #keep track of cluster prediction details
    colist = []
    calist = []
    coMAE = []
    caMAE = []

    for cid in range(8):
Exemple #5
0
    #    training[str(key + 1)] = original_prefs[str(key+1)]
    """
    sparsity.clustering_doFillUsingCBR(training)
    sparsity.clustering_doAverageFilling(training)

    sparsity.saveDenseMatrix(training,filename='..\\kfold\\kfold_testing_five.tab')

    genetic_som.persistClusters([0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1],
                                filename='..\\kfold\\kfold_testing_five.tab', folder='kfold_cluster_five',clustername='kfold_cluster_testing_five')
    
    
    
    """
    cid = 'four'

    cluster = algorithm.createPrefs(folder='../kfold_cluster_' + cid + '/')

    #get cluster mean centroids.
    cluster_centroids = getClusterCentroids(cluster)

    for user in validation:
        user_dict, removed_items = getRemovedPrefs(validation[user], 10)
        b = getBestCluster(user_dict)

        print "User %s Cluster %s" % (user, b)
        #print "Prefs after removal of items: "
        #print user_dict

        # new prefs for calculation after removing 10 items from validation set of the user.
        new_prefs = {}
        new_prefs = cluster[int(b)]
    
    """
    sparsity.clustering_doFillUsingCBR(training)
    sparsity.clustering_doAverageFilling(training)

    sparsity.saveDenseMatrix(training,filename='..\\kfold\\kfold_testing_five.tab')

    genetic_som.persistClusters([0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1],
                                filename='..\\kfold\\kfold_testing_five.tab', folder='kfold_cluster_five',clustername='kfold_cluster_testing_five')
    
    
    
    """
    cid = 'four'
    
    cluster = algorithm.createPrefs(folder='../kfold_cluster_' + cid +'/')
    
    #get cluster mean centroids.
    cluster_centroids = getClusterCentroids(cluster)


    for user in validation:
        user_dict, removed_items = getRemovedPrefs(validation[user], 10)
        b = getBestCluster(user_dict)
        
        print "User %s Cluster %s"%(user, b)
        #print "Prefs after removal of items: "
        #print user_dict
        
        # new prefs for calculation after removing 10 items from validation set of the user.
        new_prefs = {}
Exemple #7
0
    sparsity.caseone_doAverageFilling(mod_prefs, deleted_users)
    sparsity.saveDenseMatrix(mod_prefs,filename='..\\dataset\\cluster_testing10.tab')
    
    genetic_som.MAX_CLUSTERS = 10
    genetic_som.MIN_CLUSTERS = 4
    
    genetic_som.setFilename= '../dataset/cluster_testing10.tab'
    
    genetic_som.genetic(pop=20,max_evals=100,elites=4)

    #persist clusters onto files. UNVERIFIED
    genetic_som.persistClusters(genetic_som.getChromosomeList(genetic_som.final_pop),
                                filename='../dataset/cluster_testing10.tab', folder='cluster',clustername='cluster_testing')
    
    """
    cluster = algorithm.createPrefs(folder='../cluster/')
    
    #get cluster mean centroids.
    cluster_centroids = getClusterCentroids(cluster)

    for user in deleted_users:
        user_dict, removed_items = getRemovedPrefs(original_prefs[str(user)], 10)
        b = getBestCluster(user_dict)
        
        print "User %s Cluster %s"%(user, b)
        print "Prefs after removal of items: "
        print user_dict
        
        new_prefs = {}
        new_prefs = cluster[int(b)]
        new_prefs[str(user)] = user_dict