Moving on to multitag.py, sampling complete I think

This commit is contained in:
charlie-rasberry
2025-11-12 06:21:16 +00:00
parent 2cbdd55243
commit 45ec02fa46
4 changed files with 149 additions and 87 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 11,
"id": "470fe7c6-1614-4daf-879f-e6c399117c7b",
"metadata": {},
"outputs": [],
@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 12,
"id": "b855045e-2dd1-4fa1-ab5a-8ce8b50b02ee",
"metadata": {},
"outputs": [],
@@ -23,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 13,
"id": "e7da1fb6-ede6-46c6-8fbd-fa491d3351c5",
"metadata": {},
"outputs": [
@@ -178,7 +178,7 @@
"4 4.486.10002 en in "
]
},
"execution_count": 24,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -189,7 +189,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 14,
"id": "5c02ec54-4583-4720-88c6-1110b52c3f88",
"metadata": {},
"outputs": [
@@ -213,7 +213,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 15,
"id": "1da5d625-a4ba-49f8-8314-cc9e0f4ef96a",
"metadata": {},
"outputs": [
@@ -240,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 16,
"id": "1c97e396-8f05-4df7-bd0a-1bbecf6911b4",
"metadata": {},
"outputs": [],
@@ -250,7 +250,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 17,
"id": "55324c94-4944-4844-b00e-dc08c8989f7b",
"metadata": {},
"outputs": [
@@ -269,7 +269,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 18,
"id": "c45959fe-3e23-4831-a41a-94c89892247f",
"metadata": {},
"outputs": [
@@ -304,7 +304,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 19,
"id": "bf14e3db-a1b4-4fad-8102-b7ac25feeefa",
"metadata": {},
"outputs": [
@@ -322,7 +322,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 20,
"id": "8ccc07fa-9913-4047-ae17-35d2454eb059",
"metadata": {},
"outputs": [
@@ -335,67 +335,65 @@
"1 STAR REVIEWS:\n",
"==========================================\n",
"\n",
"cant put gift card on dont like app\n",
"(Length: 8.0 words)\n",
"Once drivers confirm the rider its showing with in 2 minutes but they take 25 minutes more and if driver cancel the ride I pay for that in next ride it's redicules\n",
"(Length: 32.0 words)\n",
"\n",
"Zapłaciłem za przejazd, uber pobral środki z mojego konta. Potem byla aktualizacja ceny na niższą i znowu kazał płacić. Teraz aplikacja zablokowała się na ekranie potwierdzenia płatności.\n",
"(Length: 27.0 words)\n",
"they charge very high as they show before the ride\n",
"(Length: 10.0 words)\n",
"\n",
"The app hasn't been able to process any payment. Takes forever to find a ride. I don't even know why this app still exists. Absolutely useless!\n",
"(Length: 26.0 words)\n",
"scam drivers, worst service\n",
"(Length: 4.0 words)\n",
"\n",
"==========================================\n",
"2 STAR REVIEWS:\n",
"==========================================\n",
"\n",
"In spite of receiving payment and acknowledging by email the app shows \n",
"payment due and disallowed booking and service not available to me. 4 days \n",
"have lapsed no solution to my problem. Problem solvi...\n",
"(Length: 37.0 words)\n",
"Drivers always ask is destination and cancel if they dont want to go ? Cant they already see destination before accepting ride ?\n",
"(Length: 23.0 words)\n",
"\n",
"Poor\n",
"(Length: 1.0 words)\n",
"she hole her phone on her hand she driving 80\n",
"(Length: 10.0 words)\n",
"\n",
"I had to reset my password and now I cant get in. Its telling me that my phone number is already in use. I need this fixed\n",
"(Length: 27.0 words)\n",
"I7u.6f هنه\n",
"(Length: 2.0 words)\n",
"\n",
"==========================================\n",
"3 STAR REVIEWS:\n",
"==========================================\n",
"\n",
"Nice\n",
"I think this app is very important to me\n",
"(Length: 9.0 words)\n",
"\n",
"Ok\n",
"(Length: 1.0 words)\n",
"\n",
"Good rides\n",
"(Length: 2.0 words)\n",
"\n",
"Nice\n",
"(Length: 1.0 words)\n",
"The rate will be one while booking and after the ride it changes if asked the reason is due to traffic, but it should be mentioned first only, the destination time is also calculated by uber only alon...\n",
"(Length: 53.0 words)\n",
"\n",
"==========================================\n",
"4 STAR REVIEWS:\n",
"==========================================\n",
"\n",
"Good service\n",
"(Length: 2.0 words)\n",
"Nice\n",
"(Length: 1.0 words)\n",
"\n",
"A mobile number of the car driver should be an icon if Uber book for any other person, then it can be given the number.\n",
"(Length: 25.0 words)\n",
"Good app but sometimes it take long time to get booking even the cabs are nearby and sometimes they even cancel the ride after confirming and making us wait for 30 mins and above\n",
"(Length: 34.0 words)\n",
"\n",
"many times pick up locations is shifted automatically . overall good much better\n",
"(Length: 13.0 words)\n",
"its good and helpful.. Thank you\n",
"(Length: 6.0 words)\n",
"\n",
"==========================================\n",
"5 STAR REVIEWS:\n",
"==========================================\n",
"\n",
"So friendly. Thank you\n",
"(Length: 4.0 words)\n",
"good service\n",
"(Length: 2.0 words)\n",
"\n",
"comfortable journey with effodable price\n",
"(Length: 5.0 words)\n",
"Drivers have been getting us home quickly and effectively.\n",
"(Length: 9.0 words)\n",
"\n",
"Good\n",
"Hbby\n",
"(Length: 1.0 words)\n"
]
}
@@ -419,6 +417,22 @@
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "87a15e76-51c8-4586-acea-ca3176c18757",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "73c4bbb9-3f8e-4b4c-8538-539b140cf610",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -426,6 +440,18 @@
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.0"
}
},
"nbformat": 4,

View File

@@ -1,6 +1,4 @@
# TODO: Fix get_stratified_sample() replace broken x() with actual working logic
# TODO: Add verification comparison between ratings
# TODO: implement sample_with_keywords() add to lists, and implement logic
# TODO: Clean up the logging print statements
@@ -177,10 +175,15 @@ class Sampler:
# Drop helper columns
keyword_sample = keyword_sample.drop(columns=['likely_bug', 'likely_feature'])
print(f"\n Total samples: {len(keyword_sample):,}")
return keyword_sample
def sample_tiny_size(self):
mini_sample = self.data.sample(200) # reading some samples manually
return mini_sample
@@ -211,7 +214,7 @@ def main():
print("2. original_distribution_sample() stratified by the original data distribution")
print("3. get_keyword_boosted_sample() stratified using original distribution but also using a keyword dictionary")
choice = input("\nEnter choice (1-3): ").strip()
choice = input("\nEnter choice (1-4): ").strip()
if choice == '1':
sample = sampler.get_stratified_sample()
@@ -224,6 +227,10 @@ def main():
elif choice == '3':
sample = sampler.sample_with_keywords()
sampler.save_sample(sample, "multitag/data/uber_reviews_sampled.csv")
elif choice == '4':
sample = sampler.sample_tiny_size()
sampler.save_sample(sample,"multitag/data/uber_review_temp.csv")

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 1,
"id": "739e61bf",
"metadata": {},
"outputs": [],
@@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "d9da1b98",
"metadata": {},
"outputs": [
@@ -55,7 +55,7 @@
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>very cordial.. and helped with a quick turnaro...</td>\n",
" <td>very cordial. and helped with a quick turnarou...</td>\n",
" <td>5</td>\n",
" <td>11</td>\n",
" </tr>\n",
@@ -84,13 +84,13 @@
"text/plain": [
" review rating word_count\n",
"0 suddenly, the driver can't have my location an... 1 23\n",
"1 very cordial.. and helped with a quick turnaro... 5 11\n",
"1 very cordial. and helped with a quick turnarou... 5 11\n",
"2 i have enjoyed traveling by uber my drivers ha... 5 23\n",
"3 app is good but main problem is the drivers ca... 1 23\n",
"4 very bad experience no customer service 1 6"
]
},
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
@@ -102,7 +102,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 3,
"id": "91dc1d9a",
"metadata": {},
"outputs": [
@@ -112,7 +112,7 @@
"np.int64(6740)"
]
},
"execution_count": 12,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -123,7 +123,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 4,
"id": "827b6435",
"metadata": {},
"outputs": [
@@ -132,7 +132,7 @@
"output_type": "stream",
"text": [
"Max length review:\n",
"i've been using uber for a few years now and for the most part haven't had any problems the only problem i have ever had that was never resolved or explained to me was when i was refunded cancellation fee because the driver pulled into me and then literally looked in my face and drove away and canceled the ride.buy still charges me.a cancellation fee the problem wasn't being charged the fee because i was reimbursed a few minutes later the problem was that they gave me a $5 uber credit and i don't have a debit card so i use uber gift cards so i had a balance on the gift card of roughly $4.85 and is an uber credit of $5 but for some reason you can't combine them to use on a single gel ride and there is a minimum of i think $6 or $7 for a ride so i was never able to use the money i was reimbursed and the remaing balance on my gift card was not enough for a full ride and that was 4 months ago and still have not been able to get a response as to how i can use the funds remaining mn my uber account or the uber credits i was reimbursed.... another time the driver took between 7-10 minutes to set the destination and begin driving and then when i was trying to help her with the directions because the gps was bringing us rather far out of the way to reach out destination she was very rude with me and then when we were approaching the turn that we needed to make and i warned her that it was coming up shortly and then said a few more times as we got closer to it she drove passed it the reason i was making sure she was aware of this was because we were in a rather busy highway and she would not be able to turn again for quite some time and i was already cutting it close to being late for work due to the delay in starting the trip and her failure to follow the direction i was giving her to get to.our destination so i said pull over into.the gas station and i will walk it'll be faster then driving at this point but she failed to pull into parking lot she just stopped in the middle.lf the highway granted we were in the right lane but she still put us both in a very dangerous situation and we were in a bad section of newark nj at around 10pm which for most people would put them in an uncomfortable position seeing how as the crime rate is extremely high in this area luckily i'm familiar with the residence of the neighborhood because i lived there for a few years in the past and then she notified uber that i was a disgruntled passenger and made her nervous from my reaction and in was warned to not let anything like this happen again... and the final problem.i had with uber was when my mother had ordered me.an uber through her account and during the ride we some.how started to discuss religion and i'm far from a religious person i do not even consider myself a member of any type of religion at all. but my driver was very dedicated to the religion he practiced so he got very upset and decided to call mother and tell her that i didn't not go the full distance of the original route he was hired to drive and that he had dropped me off a few blocks from where j was going to judge in some illegal activities (he knew i had some personal issues i was overcoming recently because i had mention it to him briefly in the beginning of the trip) and that he was not going to charge her the full ride amount because i did. ot cimplete the full distance and this caused my mother to become very upset with me and called me extremely untilni sent her a picture showing that i was in fact where i said i was going and the app showed that he did drop me off at the predetermined destination.. sorry for the long post but out of the probably 100 or so ride i have used with uber those were the only 3 problems i have ever had and they all 3 were actually in the same week\n"
"i've been using uber for a few years now and for the most part haven't had any problems the only problem i have ever had that was never resolved or explained to me was when i was refunded cancellation fee because the driver pulled into me and then literally looked in my face and drove away and canceled the ride.buy still charges me.a cancellation fee the problem wasn't being charged the fee because i was reimbursed a few minutes later the problem was that they gave me a $5 uber credit and i don't have a debit card so i use uber gift cards so i had a balance on the gift card of roughly $4.85 and is an uber credit of $5 but for some reason you can't combine them to use on a single gel ride and there is a minimum of i think $6 or $7 for a ride so i was never able to use the money i was reimbursed and the remaing balance on my gift card was not enough for a full ride and that was 4 months ago and still have not been able to get a response as to how i can use the funds remaining mn my uber account or the uber credits i was reimbursed. another time the driver took between 7-10 minutes to set the destination and begin driving and then when i was trying to help her with the directions because the gps was bringing us rather far out of the way to reach out destination she was very rude with me and then when we were approaching the turn that we needed to make and i warned her that it was coming up shortly and then said a few more times as we got closer to it she drove passed it the reason i was making sure she was aware of this was because we were in a rather busy highway and she would not be able to turn again for quite some time and i was already cutting it close to being late for work due to the delay in starting the trip and her failure to follow the direction i was giving her to get to.our destination so i said pull over into.the gas station and i will walk it'll be faster then driving at this point but she failed to pull into parking lot she just stopped in the middle.lf the highway granted we were in the right lane but she still put us both in a very dangerous situation and we were in a bad section of newark nj at around 10pm which for most people would put them in an uncomfortable position seeing how as the crime rate is extremely high in this area luckily i'm familiar with the residence of the neighborhood because i lived there for a few years in the past and then she notified uber that i was a disgruntled passenger and made her nervous from my reaction and in was warned to not let anything like this happen again. and the final problem.i had with uber was when my mother had ordered me.an uber through her account and during the ride we some.how started to discuss religion and i'm far from a religious person i do not even consider myself a member of any type of religion at all. but my driver was very dedicated to the religion he practiced so he got very upset and decided to call mother and tell her that i didn't not go the full distance of the original route he was hired to drive and that he had dropped me off a few blocks from where j was going to judge in some illegal activities (he knew i had some personal issues i was overcoming recently because i had mention it to him briefly in the beginning of the trip) and that he was not going to charge her the full ride amount because i did. ot cimplete the full distance and this caused my mother to become very upset with me and called me extremely untilni sent her a picture showing that i was in fact where i said i was going and the app showed that he did drop me off at the predetermined destination. sorry for the long post but out of the probably 100 or so ride i have used with uber those were the only 3 problems i have ever had and they all 3 were actually in the same week\n"
]
}
],
@@ -142,17 +142,17 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 5,
"id": "7a811e3d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"np.int64(11226)"
"np.int64(2839)"
]
},
"execution_count": 18,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -165,7 +165,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 6,
"id": "0a550434",
"metadata": {},
"outputs": [],
@@ -175,7 +175,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 7,
"id": "ec7b2ec5",
"metadata": {},
"outputs": [],
@@ -192,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 8,
"id": "d68dac67",
"metadata": {},
"outputs": [],
@@ -202,7 +202,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 9,
"id": "9a8a49b2",
"metadata": {},
"outputs": [
@@ -213,22 +213,26 @@
"\n",
"Language distribution in 10+ word reviews:\n",
"lang\n",
"en 960\n",
"es 11\n",
"id 7\n",
"pt 6\n",
"sv 2\n",
"sw 2\n",
"ar 2\n",
"ro 2\n",
"ta 1\n",
"bn 1\n",
"nl 1\n",
"da 1\n",
"so 1\n",
"ru 1\n",
"en 939\n",
"id 12\n",
"es 10\n",
"pt 9\n",
"ar 7\n",
"ru 5\n",
"fr 3\n",
"af 2\n",
"no 2\n",
"et 1\n",
"af 1\n",
"ca 1\n",
"hi 1\n",
"tr 1\n",
"cs 1\n",
"bn 1\n",
"sv 1\n",
"it 1\n",
"so 1\n",
"ro 1\n",
"da 1\n",
"Name: count, dtype: int64\n"
]
}
@@ -245,6 +249,14 @@
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "fd7576df-ce92-4c30-8466-34274290a934",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -263,7 +275,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.9"
"version": "3.14.0"
}
},
"nbformat": 4,