In [1]:
import pickle
import os, sys
sys.path.insert(0, os.path.abspath('parser'))
sys.path.insert(0, os.path.abspath('preprocessor'))
from message import *
from tfidf_builder import *
from data_preparation import *

In [2]:
classifier = pickle.load(open("validation/best_classifier.p", "rb"))
tfidf_builder = pickle.load(open("preprocessor/tfidf_builder.p", "rb"))

In [164]:
user_messages_dict = pickle.load(open("parser/test_inputs_dict.p", "rb"))
user_class_dict = pickle.load(open("parser/test_outputs_dict.p", "rb"))
positively_predicted_users = pickle.load(open("testing/positively_predicted_users.p", "rb"))

mini_user_messages_dict = {}
mini_user_class_dict = {}

positive_user_found = False
negative_user_found = False

'''
negative_user = "e29be37c2febc43a0d21a1f8efa351af"
mini_user_messages_dict[negative_user] = user_messages_dict[negative_user]
mini_user_class_dict[negative_user] = user_class_dict[negative_user]
negative_user_found = True
'''

for user in user_messages_dict:
    if positive_user_found and negative_user_found:
        break
    if len(user_messages_dict[user]) < 10:
        continue
        
    if not positive_user_found and user_class_dict[user] == 1 and user in positively_predicted_users:
        mini_user_messages_dict[user] = user_messages_dict[user]
        mini_user_class_dict[user] = user_class_dict[user]
        positive_user = user
        positive_user_found = True
    if not negative_user_found and user_class_dict[user] == 0 and user not in positively_predicted_users:
        mini_user_messages_dict[user] = user_messages_dict[user]
        mini_user_class_dict[user] = user_class_dict[user]
        negative_user = user
        negative_user_found = True

del user_messages_dict
del user_class_dict
del positively_predicted_users

In [165]:
print(len(mini_user_messages_dict), len(mini_user_class_dict))


2 2

In [169]:
print("Positive user messages:", len(mini_user_messages_dict[positive_user]))
for message in mini_user_messages_dict[positive_user]:
    print("\t" + message._text)
print("\nNegative user messages:", len(mini_user_messages_dict[negative_user]))
for message in mini_user_messages_dict[negative_user]:
    print("\t" + message._text)


Positive user messages: 167
	hi
	where ya from?
	Aberdeen
	in Maryland
	where is ewton square?
	i mean
	oh
	we aren't too far thaen
	then
	i can't spell tonight
	you have any pics?
	what do you look like?
	oh
	damn you are only 14?
	oh shit
	my fault
	27
	how old did you think i was
	no it aint
	you aren't ready for someone like me
	yes really
	plus i could go to jail
	hmmm---statutory rape
	for one
	youo are sexy though
	anyway
	not liek you would anyway
	you heard me--its not like you would do anything anyway
	but damn you are sexy
	the things i could do to you
	lol
	not with me though
	let me stop
	what are you looking at anyway
	you looking at my cam?
	don't say that--cuz i'd love to slide my cock into that tight pussy of yours
	no its not
	what am i thinkin
	i have been alone too long
	oh i am glad you find that funny
	makes a guy think crazy things
	like fucking a girl that ain't ready for me
	wondering how i can get her in my bed
	hmmm--if you got on a train--...
	i could make you cum all weekend
	j/k
	what and police cum out and bust me...lol
	what you wanna meet?
	hell yea you are hot
	but too young babe
	there would be no way for us to
	and
	you mean to tell me she left you home alone
	i don't believe you
	call me then
	edit
	no uyou won't lol
	nice one
	i didn't say that--i just don't think you will
	tell her you will call her back
	in a minute
	warren
	i am waiting for the call--
	you won't call
	i knew it
	look i gotta get some sleep i hae to get up at 4
	it was nice talking to ya
	whatever
	lol
	damn
	hey
	you aer up early
	you there?
	what are you up too?
	waiting
	u silly
	sure
	if thats what you want
	i got a movie we could watch
	beb
	brb
	i am back
	i will leave real soon now
	you there?
	i dunno
	near b-more
	after
	sometime
	not too sure
	yeah around then
	go shower i will see ya later--oh i have a few good movies
	you like kung fu movies?
	really!
	finally someone that likes kung fu
	you are my new movie buddy
	that is good
	oh--lol
	you don't like kung fu movies?
	great--i will bring a couple of good ones--you like jet li?
	bet--i like his earlier films
	i will bring a couple
	talk to you later
	hey
	my cell number is edit
	if i am late you can call it
	i dunno--if i am not there by 2 --i might be lost--lol
	in a few
	sure you can
	its just me
	lol
	you trust me to come over but not to have a number???
	you being straight up with me?
	no seriously
	since i have moved up here i found that women are full of shit
	they say one thing mean another and do soemthing else from that
	true--but why is your number all top secret
	you know i have your number--i won't call you of course but i do have it
	cause i respect your wishes
	i won't
	but it is hard for me to trust anymore--women lie to me so much
	is that right?
	well, i hope that doesn't scare you
	it is just hard for me to trust in someone--it takes time
	see i know what i will do--
	but i don't know about you
	i know i am trustworthy and dependable--
	i am not saying you aren't
	don't get me wrong
	hey call me back--
	i don't want to talk on here--
	i won't keep you up long
	just for a minute
	i have something i want to say
	won't take a minute
	i hate haveing to type--much quicker that way
	plus maybe i want to hear your voice again
	never mind then
	is that your number?
	hmmmm
	good grief
	i am glad you said that though cause 404 ain't philly
	its Atlanta
	georgia
	where i am from
	well i am going to leave you alone--before i do some other dumb shit
	nice talking to you--you seem very intelligent
	bye
	sleep well
	i'll talk to you tomorrow
	oh what color is your house?
	ya got me thinking about what you said earlier
	that i'd like to slide my cock in you and you said cool--damn what am i saying
	i think i will come early--that way you could just stay in the bed
	chores??--i thought you were sleeping in
	why we are just going to mess everything up--might as well just let me help ya
	lol
	clean up--lol i can c it now--alpha team move--bravo tem flank--freeze!!!
	move move move
	lol
	ok
	just imagining tomorrow
	thats all
	lol
	never mind
	just predicting my future
	me too
	nite

Negative user messages: 33
	zakim, code?
	zakim, i am ??P10
	[off] are we meeting?
	Hi 28d34f2e053dee2c0e9399a7924cd978.
	I thought Roland said he'd be in Germany.
	He sent a mail to the lst.
	right
	He probably forgot that Steven was away.
	Hey...we've had meetings based on less.
	But you're right, no chair and no agenda makes it a little tricky. :) Bye......
	zakim, codes?
	zakim, code?
	zakim, i am ?
	zakim, i am ??
	zakim, i am ??22
	zakim, i am ??p22
	zakim, who is here?
	[off] ah...that explains it. :) Normally typing "zakim, i am ?" is enough, but there are two other unidentified callers. :)
	zakim, ? is 7d22538443af9867c0589ed3136ca02e
	[off] it is now... :)
	I've searched for "http://www.w3.org/2007/03/19-tagmem-minutes.html#action01"
	and "CompactURIReferences-5"
	which are the references in the minutes about raising a TAG issue about CURIEs.
	The minutes have:
	"ACTION: HST to circulate a candidate description to <email/> [recorded in http://www.w3.org/2007/03/19-tagmem-minutes.html#action01]"
	But I can't find a reference to Henry doing this action.
	q+
	http://lists.w3.org/Archives/Public/public-rdf-in-xhtml-tf/2007Sep/0237.html
	The proposal is to use: http://www.w3.org/1999/xhtml/relations instead.
	At the moment we also have: http://www.w3.org/1999/xhtml/datatypes
	s/relations in/relations# in/
	s/datatypes/datatypes\//
	zakim, i am ?

In [166]:
users, inputs, outputs = build_classifier_io(mini_user_messages_dict, mini_user_class_dict, tfidf_builder);


1/2
2/2

In [170]:
print(inputs.shape)


(2, 59378)

In [167]:
prediction = classifier.predict(inputs)

In [168]:
print(prediction, outputs)


[0 1] [0 1]

In [ ]: