Esempio n. 1
0
def recipient_is(name, TRAIN=0.9):
    #: TRAIN = percent of the data to have in training set
    train = {}
    test = {}
    person = Contact.get(name=name)
    recipient = set(SMS.select().where(contact=person).where(from_me=False))
    not_recipient = set(SMS.select().where(contact__ne=person).where(from_me=False))

    train[person.name], test[person.name] = split_set(recipient, TRAIN)
    train["not_" + person.name], test["not_" + person.name] = split_set(not_recipient, TRAIN)

    return train, test
Esempio n. 2
0
def split_me_not_me(TRAIN_SIZE=0.9):
    train, test = {}, {}

    not_me = SMS.select().where(from_me=False)
    me = SMS.select().where(from_me=True)

    not_me = set(not_me)
    me = set(me)

    train['me'], test['me'] = split_set(me, TRAIN_SIZE)
    train['not_me'], test['not_me'] = split_set(not_me, TRAIN_SIZE)

    return train, test
Esempio n. 3
0
def split_me_not_me(TRAIN_SIZE=0.9):
    train, test = {}, {}

    not_me = SMS.select().where(from_me=False)
    me = SMS.select().where(from_me=True)

    not_me = set(not_me)
    me = set(me)

    train["me"], test["me"] = split_set(me, TRAIN_SIZE)
    train["not_me"], test["not_me"] = split_set(not_me, TRAIN_SIZE)

    return train, test
Esempio n. 4
0
def recipient_is(name, TRAIN=0.9):
    #: TRAIN = percent of the data to have in training set
    train = {}
    test = {}
    person = Contact.get(name=name)
    recipient = set(SMS.select().where(contact=person).where(from_me=False))
    not_recipient = set(
        SMS.select().where(contact__ne=person).where(from_me=False))

    train[person.name], test[person.name] = split_set(recipient, TRAIN)
    train['not_' + person.name], test['not_' + person.name] = \
            split_set(not_recipient, TRAIN)

    return train, test
Esempio n. 5
0
def people_with_many_texts(n, TRAIN=0.9):
    # TRAIN = percent of data to have in training set
    contacts = peewee.RawQuery(
        Contact, '''SELECT * from sms, contact
    where from_me=0 and contact.id=contact_id GROUP BY contact_id
    HAVING count(*) >= ?;''', n)

    data = {}
    for c in contacts:
        data[c.name] = set(SMS.select().where(contact=c))

    train = {}
    test = {}

    for c in data:
        train[c], test[c] = split_set(data[c], TRAIN)

    print 'There are %d people with >= %d texts.' % (len(data), n)

    return train, test
Esempio n. 6
0
def index(password):
    print >> sys.stderr, "within index"
    try:
        if password == PASSWORD:
            print >> sys.stderr, "within try"
            sellerList = Seller.select()
            smsList = SMS.select()
            numberList = Number.select()
            l = List.select()
            marketList = Market.select()
            lrList = ListRelationship.select()
            outboxList = Outbox.select()
            return render_template("index.html", title = 'TABLES', sellerList = sellerList, smsList = smsList, l = l, marketList = marketList)
            #return 'hello world'
        else:
            print >> sys.stderr, "wrong password"
    except:
        print >> sys.stderr, "within except"
        print >> sys.stderr, str(sys.exc_info()[0]) # These write the nature of the error
        print >> sys.stderr, str(sys.exc_info()[1])
        statement = 'An exception has Occured'+ str(sys.exc_type) + '[' + str(sys.exc_value) + ']'
        return statement
Esempio n. 7
0
def people_with_many_texts(n, TRAIN=0.9):
    # TRAIN = percent of data to have in training set
    contacts = peewee.RawQuery(
        Contact,
        """SELECT * from sms, contact
    where from_me=0 and contact.id=contact_id GROUP BY contact_id
    HAVING count(*) >= ?;""",
        n,
    )

    data = {}
    for c in contacts:
        data[c.name] = set(SMS.select().where(contact=c))

    train = {}
    test = {}

    for c in data:
        train[c], test[c] = split_set(data[c], TRAIN)

    print "There are %d people with >= %d texts." % (len(data), n)

    return train, test