<jupyter_start><jupyter_text>PurposeThe purpose of this notebook is to generate an image for individual users in our recommender. The following API is used to collect images for users:  https://randomuser.me/<jupyter_code>import requests
import sklearn
import numpy as np
import json<jupyter_output><empty_output><jupyter_text>First, let's pull 5000 generated users from the randomuser API<jupyter_code>response = requests.get('https://randomuser.me/api/', params={'results': 5000})
results = response.json()['results']

print('Length of users generated: {}'.format(len(results)))
print('Example of user data:')
results[13]<jupyter_output>Length of users generated: 5000
Example of user data:<jupyter_text>Next, let's assign these random users to users in our recommender model<jupyter_code>no_users = 69797
uidx = np.arange(no_users)
sample_uidx = map(str, np.random.choice(uidx, size=len(results), replace=False))
uidx_to_profile = dict(zip(sample_uidx, results))

# print key-value pair for 1 customer
customer = np.random.choice(list(uidx_to_profile))
uidx_to_profile[customer]<jupyter_output><empty_output><jupyter_text>Store `user_to_profile` as a json file for use on webapp<jupyter_code>with open('../app/objects/user_profiles.json', 'w') as f:
    json.dump(uidx_to_profile, f, sortindent=4)
uidx_to_profile[40812]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11160384331116038, 'fraction_numerical': 0.019216555801921657, 'mean_word_length': 7.624203821656051, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '554221', 'license': 'MIT', 'n_tokens_mistral': 466, 'n_tokens_neox': 442, 'n_words': 116, 'path': 'notebooks/Generate Users for Visualization.ipynb', 'repo_name': 'jscottcronin/recommender_deployed', 'size': '1353'}