예제 #1
0
def get_from(conn, is_group, contact_id, contact_name, your_name, row):
	mfrom, mtext, mdate, mtype, mgroupeventtype, mgroupmember, mmediaitem = row
	if mfrom != contact_id:
		if is_group:
			return contact_name + " - " + your_name, COLORS[0]
		else:
			return your_name, COLORS[0]
	mfrom = contact_name
	if is_group:
		if mgroupmember is not None and mtype != 6:
			mfrom += " - " + get_group_member_name(conn, mgroupmember)
	color = get_color(mfrom)
	return mfrom, color
예제 #2
0
def get_from(conn, is_group, contact_id, contact_name, your_name, row):
    mfrom, mtext, mdate, mtype, mgroupeventtype, mgroupmember, mmediaitem = row
    if mfrom != contact_id:
        if is_group:
            return contact_name + " - " + your_name, COLORS[0]
        else:
            return your_name, COLORS[0]
    mfrom = contact_name
    if is_group:
        if mgroupmember is not None and mtype != 6:
            mfrom += " - " + get_group_member_name(conn, mgroupmember)
    color = get_color(mfrom)
    return mfrom, color
예제 #3
0
def output_contact(conn, contact_conn, backup_extractor, chat_id, your_name):
	reset_colors()
	contact_name = str(chat_id)
	html = open(get_filename(conn, contact_conn, chat_id), 'w', encoding="utf-8")
	html.write(TEMPLATEBEGINNING % ("SMS/iMessage",))
	c = conn.cursor()
	c.execute("SELECT {} FROM message WHERE ROWID in ".format(FIELDS) + \
		      "(SELECT message_id FROM chat_message_join WHERE chat_id=?);", (chat_id,))
	for row in c:
		mid, mtext, mdate, is_from_me, handle_id, has_attachment = row
		if has_attachment:
			mtext = handle_media(conn, backup_extractor, mid, mtext)
		mtext = mtext.replace("\n", "<br>\n")
		mdatetime = get_date(mdate)
		mfrom = your_name if is_from_me else get_contact_name(conn, contact_conn, handle_id)
		color = COLORS[0] if is_from_me else get_color(handle_id)
		html.write((ROWTEMPLATE % (color, mdatetime, mfrom, mtext)))
	html.write(TEMPLATEEND)
	html.close()
예제 #4
0
def output_contact(conn, contact_conn, backup_extractor, chat_id, your_name):
	reset_colors()
	contact_name = str(chat_id)
	html = open(get_filename(conn, contact_conn, chat_id), 'w', encoding="utf-8")
	html.write(TEMPLATEBEGINNING % ("SMS/iMessage",))
	c = conn.cursor()
	c.execute("SELECT {} FROM message WHERE ROWID in ".format(FIELDS) + \
		      "(SELECT message_id FROM chat_message_join WHERE chat_id=?);", (chat_id,))
	for row in c:
		mid, mtext, mdate, is_from_me, handle_id, has_attachment = row
		if mtext is None:
			mtext = ""
		if has_attachment:
			mtext = handle_media(conn, backup_extractor, mid, mtext)
		mtext = mtext.replace("\n", "<br>\n")
		mdatetime = get_date(mdate)
		mfrom = your_name if is_from_me else get_contact_name(conn, contact_conn, handle_id)
		color = COLORS[0] if is_from_me else get_color(handle_id)
		html.write((ROWTEMPLATE % (color, mdatetime, mfrom, mtext)))
	html.write(TEMPLATEEND)
	html.close()
예제 #5
0
axarr[0].set_ylabel('Loss')
axarr[0].set_title('Training Loss')
axarr[1].plot(plotdata["batchsize"], plotdata["error"], 'r--')
axarr[1].set_xlabel('Minibatch number')
axarr[1].set_ylabel('Error')
axarr[1].set_title('Training Error')
f.tight_layout()
plt.show()


# Get test data
features, labels = data_gen(minibatch_size, num_features, num_classes)
print(trainer.test_minibatch({inputs: features, label: labels}))
pred = predict(features, z, inputs)
eq = pred == labels
print("Error (1-acc):", 1.0 - float(sum(eq))/len(eq))

acc_colors = [get_color(label[0], num_classes) for label in labels]
pred_colors = [get_color(y[0], num_classes) for y in pred]
plt.scatter(features[:,0], features[:,1], c=acc_colors, s=55)
plt.scatter(features[:,0], features[:,1], c=pred_colors, marker="x")
plt.show()

# Visualize boundaries
print("Displaying decision boundaries")
plt.scatter(features[:,0], features[:,1], c=acc_colors, s=55)
part, part_y = particles(500, 5, z, inputs, num_features)
part_colors = [get_color(y[0], num_classes) for y in part_y]
plt.scatter(part[:,0], part[:,1], c=part_colors, marker="x", alpha=0.5)
plt.show()