示例#1
0
	def export_path_html(self, key):
		if len(self.selection)>0:
			explst = self.selection
			print 'export selection;', len(self.selection)
		else:
			explst = self.new_votes
			print 'export votes;', len(self.new_votes)
		query = [p for p in list(explst) if not p in self.trash]
		self.message('\n'.join([
			'Export assemblage of selected images. ({} imgs)'.format(
				len(query[:20])),
			'','This may take a while.']))
		# FIXME: this is limited to 20 images???
		path = index.chain(query=query[:20])
		index.export_html(path, 'selection.html')
		self.redraw=True
示例#2
0
D_op = np.load("var_p_one_30n_50_10.npy")  # read OSI profiles
Q_p = np.load("var_p_Q_30n.npy").item().get(0)  # read accuracy
count = 0
chain1 = []
chain2 = []
chain3 = []
ban1 = []
ban2 = []
ban3 = []
for i in range(var_p):  # get statistics from profiles
    for j in range(rp):
        print("processing #", count, "/", var_p * rp * 2)
        count = count + 1
        d = D_bp.item().get(i * rp + j)
        r.append([p[i], "IBRD", index.del_r(d, n)])
        chain = index.chain(d, n)
        lon.append([p[i], "IBRD", chain[0]])
        short.append([p[i], "IBRD", chain[1]])
        avglen.append([p[i], "IBRD", chain[2]])
        for k in range(n):
            ban.append(cal_banzhaf(d, n, k, beta))
        ban_s = index.banzhaf(ban, n)
        ma.append([p[i], "IBRD", ban_s[0]])
        mi.append([p[i], "IBRD", ban_s[1]])
        avgban.append([p[i], "IBRD", ban_s[2]])
        gini.append([p[i], "IBRD", index.gini(ban, n)])
        acu.append([p[i], "IBRD", index.average_accuracy(d, Q_p, n)])
        ban = []
    for j in range(rp):
        print("processing #", count, "/", var_p * rp * 2)
        count = count + 1
chain3 = []
ban1 = []
ban2 = []
ban3 = []
concon = 0  # count non-converging cases
for i in range(len(A)):  # get statistics from profiles
    name1 = "q in [0.0, 1.0]"
    for j in range(rp):
        print("processing #", count, "/", len(A) * rp * 2)
        count = count + 1
        d = D_bb.item().get(i * rp + j)
        if 30 in d:
            concon = concon + 1
            continue
        r.append([A[i], name1, index.del_r(d, n)])
        chain = index.chain(d, n)
        lon.append([A[i], name1, chain[0]])
        short.append([A[i], name1, chain[1]])
        avglen.append([A[i], name1, chain[2]])
        for k in range(n):
            ban.append(cal_banzhaf(d, n, k, beta))
            # ban.append(random.uniform(0, 1))
        ban_s = index.banzhaf(ban, n)
        ma.append([A[i], name1, ban_s[0]])
        mi.append([A[i], name1, ban_s[1]])
        avgban.append([A[i], name1, ban_s[2]])
        gini.append([A[i], name1, index.gini(ban, n)])
        acu.append([A[i], name1, index.average_accuracy(d, Q_mis, n)])
        ban = []
    con.append([A[i], 1, 50 - concon])
    concon = 0
示例#4
0
import index
from random import randrange as rnd

index.load()

for n in range(6):
	stars = sorted(index.pictures(), key=lambda p:p.rating, reverse=True)[:5+n*2]
	query = []

	print 'Checkpoints:'
	for i in range(3+n):
		p = stars[rnd(len(stars))]
		query.append(p)
		stars.remove(p)
		print '{}. {}'.format(i+1, p.name)

	path = index.chain(query=query)

	print '\nPath:'
	print ' > '.join([p.name for p in path])

	reference = [p for p in query if p in path]
	index.export_html(reference+[None]+path, 'path{}.html'.format(n))