Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display the result of app profile recommendation for android as a dictionary and find category with highest average. #73

Open
Shivam23Thaman opened this issue Mar 13, 2019 · 1 comment

Comments

@Shivam23Thaman
Copy link

Here's my code `diff_categories = freq_table(android_final, 1)
for category in diff_categories:
total = 0
len_category = 0
for app in android_final:
apps_category = app[1]
if apps_category == category:
n_installs = app[5]
n_installs = n_installs.replace('+','')
n_installs = n_installs.replace(',','')

        total += float(n_installs)
        len_category += 1
avg_category = total / len_category
print(category, " : ", avg_category)



        `
@mahadinfo
Copy link

Here's my code you can try:

category_android = freq_table(android_final, 1)

avg_installs_category = {} # Initialized an empty dictionary
for category in category_android:
    total = 0
    len_category = 0
    for row in android_final:
        app_cat = row[1]
        if app_cat == category:
            no_installs = row[5]
            no_installs = no_installs.replace(',', '')
            no_installs = no_installs.replace('+', '')
            total += float(no_installs)
            len_category += 1
            
    avg_installs = total / len_category
#     print(category, ':', avg_installs)
    
    if category in avg_installs_category:
        avg_installs_category[category] += avg_installs
    else:
        avg_installs_category[category] = avg_installs

# print(avg_installs_category)

avg_installs_cat_tup = [] # Initialized an empty tuple
for key in avg_installs_category:
    val_key = avg_installs_category[key], key
    avg_installs_cat_tup.append(val_key)
    
print(sorted(avg_installs_cat_tup, reverse=True))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants