In [57]:
import cvxopt
import math
import matplotlib.pyplot as plt
import numpy as np
import numpy.linalg as npalg
import pandas as pd
import prettyplotlib as ppl
import random
from scipy.stats import gaussian_kde
import seaborn as sns
import statsmodels.formula.api as sm
from sklearn import svm
%matplotlib inline
In [3]:
df = pd.io.json.read_json('data/train.json')
In [7]:
df[:3]
Out[7]:
giver_username_if_known
number_of_downvotes_of_request_at_retrieval
number_of_upvotes_of_request_at_retrieval
post_was_edited
request_id
request_number_of_comments_at_retrieval
request_text
request_text_edit_aware
request_title
requester_account_age_in_days_at_request
requester_account_age_in_days_at_retrieval
requester_days_since_first_post_on_raop_at_request
requester_days_since_first_post_on_raop_at_retrieval
requester_number_of_comments_at_request
requester_number_of_comments_at_retrieval
requester_number_of_comments_in_raop_at_request
requester_number_of_comments_in_raop_at_retrieval
requester_number_of_posts_at_request
requester_number_of_posts_at_retrieval
requester_number_of_posts_on_raop_at_request
0
N/A
0
1
0
t3_l25d7
0
Hi I am in need of food for my 4 children we a...
Hi I am in need of food for my 4 children we a...
Request Colorado Springs Help Us Please
0.0000
792.420405
0
792.420405
0
0
0
0
0
1
0
...
1
N/A
2
5
0
t3_rcb83
0
I spent the last money I had on gas today. Im ...
I spent the last money I had on gas today. Im ...
[Request] California, No cash and I could use ...
501.1111
1122.279838
0
621.127072
0
1000
0
0
15
26
0
...
2
N/A
0
3
0
t3_lpu5j
0
My girlfriend decided it would be a good idea ...
My girlfriend decided it would be a good idea ...
[Request] Hungry couple in Dundee, Scotland wo...
0.0000
771.616181
0
771.616181
0
0
0
0
0
1
0
...
3 rows × 32 columns
In [5]:
print '\n'.join(sorted(df.columns))
giver_username_if_known
number_of_downvotes_of_request_at_retrieval
number_of_upvotes_of_request_at_retrieval
post_was_edited
request_id
request_number_of_comments_at_retrieval
request_text
request_text_edit_aware
request_title
requester_account_age_in_days_at_request
requester_account_age_in_days_at_retrieval
requester_days_since_first_post_on_raop_at_request
requester_days_since_first_post_on_raop_at_retrieval
requester_number_of_comments_at_request
requester_number_of_comments_at_retrieval
requester_number_of_comments_in_raop_at_request
requester_number_of_comments_in_raop_at_retrieval
requester_number_of_posts_at_request
requester_number_of_posts_at_retrieval
requester_number_of_posts_on_raop_at_request
requester_number_of_posts_on_raop_at_retrieval
requester_number_of_subreddits_at_request
requester_received_pizza
requester_subreddits_at_request
requester_upvotes_minus_downvotes_at_request
requester_upvotes_minus_downvotes_at_retrieval
requester_upvotes_plus_downvotes_at_request
requester_upvotes_plus_downvotes_at_retrieval
requester_user_flair
requester_username
unix_timestamp_of_request
unix_timestamp_of_request_utc
In [10]:
df['requester_received_pizza'].value_counts()
Out[10]:
False 3046
True 994
dtype: int64
In [17]:
plt.hist(df['number_of_upvotes_of_request_at_retrieval'].apply(lambda n: math.log(n+1)))
Out[17]:
(array([ 12, 1164, 1155, 1122, 384, 142, 40, 17, 1, 3]),
array([ 0. , 0.58464388, 1.16928776, 1.75393163, 2.33857551,
2.92321939, 3.50786327, 4.09250714, 4.67715102, 5.2617949 ,
5.84643878]),
<a list of 10 Patch objects>)
In [78]:
for colname in ('request_text', 'request_text_edit_aware'):
df['%s_length' % colname] = df[colname].apply(lambda t: len(t))
df= df[df['request_text_length'] > 0]
df['%s_length_log10' % colname] = df[colname].apply(lambda t: math.log10(len(t)))
In [79]:
plt.hist(df['request_text_edit_aware_length_log10'])
Out[79]:
(array([ 5, 2, 7, 48, 121, 521, 1551, 1311, 332, 38]),
array([ 0. , 0.36493349, 0.72986697, 1.09480046, 1.45973394,
1.82466743, 2.18960092, 2.5545344 , 2.91946789, 3.28440137,
3.64933486]),
<a list of 10 Patch objects>)
In [81]:
pizza = df[df['requester_received_pizza']]
nopizza = df[df['requester_received_pizza'] == False]
In [82]:
for frame in (pizza, nopizza):
density = gaussian_kde(frame['request_text_edit_aware_length_log10'])
density._compute_covariance()
xs = np.linspace(0, max(df['request_text_edit_aware_length_log10']), 200)
plt.plot(xs, density(xs))
plt.legend(['pizza', 'nopizza'])
Out[82]:
<matplotlib.legend.Legend at 0x10b2f7090>
In [85]:
i = 10
for row in df.iterrows():
row = row[1]
if row['request_text_edit_aware'] != row['request_text']:
print row['request_text_edit_aware']
print ' ****'
print row['request_text']
print '------'*5
i -= 1
if i == 0:
break
Austin, Texas
My two roommates and I are hungry as hell. We were all sort of counting on the deposit from our last apartment to help us out, but they claimed there was damages, so we did not receive anything. So, we're sort of struggling. Is anyone able to help us out for dinner tonight? We'd really appreciate it!
****
Austin, Texas
My two roommates and I are hungry as hell. We were all sort of counting on the deposit from our last apartment to help us out, but they claimed there was damages, so we did not receive anything. So, we're sort of struggling. Is anyone able to help us out for dinner tonight? We'd really appreciate it!
EDIT: Received a Dominos gift card from jetboyterp! THANK YOU!
------------------------------
I'm a college grad living in NYC. Interning to keep my feet in the business, freelancing and dog walking when I'm not interning. The money I made this month is just enough to keep a roof over my head and my heat kept on. I have no food, having eaten down what's left of my pantry over the course of the month. I've had nothing to eat but condiments for the last two days. I woke up this morning with a splitting headache and cramps in my feet. Anything you could give is appreciated! If this doesn't work, I'm going to try begging for food (not money) on the train. I really don't want it to come to that...
*
****
I'm a college grad living in NYC. Interning to keep my feet in the business, freelancing and dog walking when I'm not interning. The money I made this month is just enough to keep a roof over my head and my heat kept on. I have no food, having eaten down what's left of my pantry over the course of the month. I've had nothing to eat but condiments for the last two days. I woke up this morning with a splitting headache and cramps in my feet. Anything you could give is appreciated! If this doesn't work, I'm going to try begging for food (not money) on the train. I really don't want it to come to that...
**EDIT:** Thank you so much to @SallyMacLennane for gifting me with food today. It was amazing and I will have left overs to last me through the weekend! THANK YOU to everyone who upvoted and @m2mu for the soup kitchen advice! Many best wishes this Thanksgiving!!
------------------------------
Hungry as heck, I'm just looking for a good pepperoni pizza delivery, by Dominos or Pizza Hut, or whatever delivers home. First post, tell me if I'm doing something wrong. Thanks, and Happy Holidays!
****
Hungry as heck, I'm just looking for a good pepperoni pizza delivery, by Dominos or Pizza Hut, or whatever delivers home. First post, tell me if I'm doing something wrong. Thanks, and Happy Holidays!
EDIT: Would need the pizza TONIGHT, no later. Thanks again!
------------------------------
Don't know where to start. My brother tried to commit suicide last Tuesday by ODing on the antidepressants he was just given by his psychologist.
I live about 300 miles away from home with my girlfriend currently. I only have intermittent part time work and just visited last weekend, so I'm too broke to go home again right away.
It hurts so bad thinking of him locked up in the facility, though my family can visit him 1 hour a day, and I call every day right after they're through to check up on him. Sounds like they've got him diagnosed but we have no idea when he's getting out.
This is half just to vent, I guess. Nothing is fun right now. I'm completely disinterested in my hobbies.
I know it's unreasonable, but I feel guilty when I'm having fun because I know he can't.
I wish someone could send him a pizza.
****
Don't know where to start. My brother tried to commit suicide last Tuesday by ODing on the antidepressants he was just given by his psychologist.
I live about 300 miles away from home with my girlfriend currently. I only have intermittent part time work and just visited last weekend, so I'm too broke to go home again right away.
It hurts so bad thinking of him locked up in the facility, though my family can visit him 1 hour a day, and I call every day right after they're through to check up on him. Sounds like they've got him diagnosed but we have no idea when he's getting out.
This is half just to vent, I guess. Nothing is fun right now. I'm completely disinterested in my hobbies.
I know it's unreasonable, but I feel guilty when I'm having fun because I know he can't.
I wish someone could send him a pizza.
EDIT: If anyone's been in a facility for this before and wouldn't mind telling me what it was like, feel free to PM me.Thanks
EDIT2: I wasn't quite clear, I wanted to give him the pizza when he gets out. I'm happy to provide verification as well (I assume he'll work with me a bit in giving you guys like a hospital slip of some sort).
EDIT3: Verification for anyone who's interested, and wants to see the admission slip: http://imgur.com/fCkEnHK,eLaTaLI
He's coming home today or tomorrow.
Thanks everyone for the support.
------------------------------
I'm sure there are needier people on this subreddit, but I had to borrow 30 bucks to pay the rest of my share of rent yesterday and now I'm broke until next friday. Pizza for me and my housemate that lent me the 30 bucks would be much appreciated for dinner. Thanks in advance, it's subreddits like this that make Reddit such an awesome place.
****
I'm sure there are needier people on this subreddit, but I had to borrow 30 bucks to pay the rest of my share of rent yesterday and now I'm broke until next friday. Pizza for me and my housemate that lent me the 30 bucks would be much appreciated for dinner. Thanks in advance, it's subreddits like this that make Reddit such an awesome place.
EDIT:CayucosKid got me covered, 2 pizzas, breadsticks, and a 2 liter of coke to boot! I'll be eating good for days! Thanks again. (=
------------------------------
I'll send a photo of my driver's license with a "hey <username>" next to it. Just thought a pizza could help with a forever aloneness! Thanks so much to the person who can help me, or just to give me someone to talk to as I take one step closer to death o.0
I live in Virginia -
****
I'll send a photo of my driver's license with a "hey <username>" next to it. Just thought a pizza could help with a forever aloneness! Thanks so much to the person who can help me, or just to give me someone to talk to as I take one step closer to death o.0
I live in Virginia - edit
Edit: Thanks for the birthday wishes you guys! Even if i dont get a pizza I really appreciate the support.
------------------------------
Hello, I've been a longtime lurker on reddit and finally made an account a few weeks back.. since then my life has absolutely been turned upside down.
After this semester [full time] at university I lost my job. I had barely paid off this semester via payment plan when I received the VOICEMAIL informing me I was no longer needed at work.
The issues created by not having money for my bills and gas caused major problems with my parents, who had been letting me live at home this last semester on the condition I would finish my degree and sustain myself financially regarding everything but the roof over my head. Needless to say, they do not really have the means to support another person and I left because of this strain.
I have been couch crashing this last week at a friends' with literally nothing to offer him (or his awesome, understanding roommates who I really just met) in return for their hospitality. A PIZZA!! =) to share with these great people would not only be the first whole meal I have had for a while, but it would go a long way towards making me feel a bit better about myself for actually contributing to this house a bit. The other folks here are all struggling students, and looking in the pantry all I'm seeing is ramen and potatoes (lol).
Thanks for putting up with this wall of text, I felt obligated to give the whole story! Not sure of what evidence is necessary but needless to say if you ask for it I will provide. I hope I did this right (got a confirmation code as well if needed) but here goes heh. Take care!
****
Hello, I've been a longtime lurker on reddit and finally made an account a few weeks back.. since then my life has absolutely been turned upside down.
After this semester [full time] at university I lost my job. I had barely paid off this semester via payment plan when I received the VOICEMAIL informing me I was no longer needed at work.
The issues created by not having money for my bills and gas caused major problems with my parents, who had been letting me live at home this last semester on the condition I would finish my degree and sustain myself financially regarding everything but the roof over my head. Needless to say, they do not really have the means to support another person and I left because of this strain.
I have been couch crashing this last week at a friends' with literally nothing to offer him (or his awesome, understanding roommates who I really just met) in return for their hospitality. A PIZZA!! =) to share with these great people would not only be the first whole meal I have had for a while, but it would go a long way towards making me feel a bit better about myself for actually contributing to this house a bit. The other folks here are all struggling students, and looking in the pantry all I'm seeing is ramen and potatoes (lol).
Thanks for putting up with this wall of text, I felt obligated to give the whole story! Not sure of what evidence is necessary but needless to say if you ask for it I will provide. I hope I did this right (got a confirmation code as well if needed) but here goes heh. Take care!
EDIT! we are in Albuquerque, NM, USA 87114. Thanks chupanibre25 =)
------------------------------
Hi,
Its the end of the month, hubby and i would love to have a pizza on Friday or tonight :) It's been a while since we had the pleasure of cheeses and bacon.
I am new to this so hopefully I did this request right.
****
Hi,
Its the end of the month, hubby and i would love to have a pizza on Friday or tonight :) It's been a while since we had the pleasure of cheeses and bacon.
I am new to this so hopefully I did this request right.
Edit: Just got my egift card for a pizza with Papa Johns from Masterboat seriously thank you so much! We really apperciate it!!!!
2nd Edit: [Imgur](http://i.imgur.com/87uIp.jpg)
Here is a photo of our yummy pizza. It was super awesome and the bacon was the best part. Thanks again masterboat!
------------------------------
Just found out I got a job I just interviewed for but I don't get paid for another 2 weeks. My wife and I have been on brown rice and dry cereal for a while now. Anyone willing to get us a medium or large pepperoni pizza would be appreciated. Once I get my first check I will kindly repay the favor.
****
Just found out I got a job I just interviewed for but I don't get paid for another 2 weeks. My wife and I have been on brown rice and dry cereal for a while now. Anyone willing to get us a medium or large pepperoni pizza would be appreciated. Once I get my first check I will kindly repay the favor.
Edit: Pizza already received and currently being enjoyed. Many thanks godbless this fucking site. I love you guys.
------------------------------
Not picky at all; anything is greatly appreciated.
****
Not picky at all; anything is greatly appreciated.
Edit:Doesn't look like its gonna happen but thanks anyway
------------------------------
In [87]:
# Create training and test set
# Make feature matrix
# Train on training set
# Predict on test set
# Score test set
In [ ]:
Content source: everett-wetchler/kaggle-pizza
Similar notebooks: