Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/noverney/randoms
Browse files Browse the repository at this point in the history
  • Loading branch information
snophey committed Oct 29, 2023
2 parents fd68f1f + e374511 commit a5870eb
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 216 deletions.
2 changes: 2 additions & 0 deletions frontend/pages/user.vue
Expand Up @@ -136,5 +136,7 @@ const saveChanges = async () => {
team: department.value,
days: selectedDays.value
});
navigateTo('/')
};
</script>
2 changes: 2 additions & 0 deletions functions/main.py
Expand Up @@ -87,3 +87,5 @@ def add_fake_users(req: https_fn.Request) -> https_fn.Response:
print("Adding fake users")
add_fake_firestore_users(4)
return https_fn.Response("Added 10 fake users")


12 changes: 12 additions & 0 deletions functions/matching_users.py
Expand Up @@ -21,10 +21,22 @@ def check_input(user_ids, preference_matrix):
if len(user_ids) != len(preference_matrix):
raise ValueError(f"user list and matrix length do not match")

def add_noise_to_array(arr, noise_factor):
if not 0 <= noise_factor <= 1:
raise ValueError("Noise factor should be between 0 and 1")
elif noise_factor == 0:
return arr
noise = np.random.uniform(0, noise_factor, arr.shape)
noisy_array = arr + noise
noisy_array = np.clip(noisy_array, 0, 1)
return noisy_array

def get_preference_lists(user_ids, preference_matrix):
check_input(user_ids, preference_matrix)

user_preferences = cosine_similarity(preference_matrix)
user_preferences = add_noise_to_array(user_preferences, 0) # ADJUST NOISE HERE

get_sorted_list = get_sorted_list_func(user_ids, user_preferences)
return [get_sorted_list(user_index) for user_index in range(len(user_ids))]

Expand Down
4 changes: 2 additions & 2 deletions notebooks/playground.ipynb
Expand Up @@ -124,8 +124,8 @@
"Requirement already satisfied: numpy>=1.17.3 in /home/noverney/miniconda3/lib/python3.10/site-packages (from scikit-learn) (1.23.5)\n",
"Collecting faker\n",
" Downloading Faker-19.12.0-py3-none-any.whl (1.7 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: python-dateutil>=2.4 in /home/noverney/miniconda3/lib/python3.10/site-packages (from faker) (2.8.2)\n",
"\u001B[2K \u001B[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001B[0m \u001B[32m1.7/1.7 MB\u001B[0m \u001B[31m3.0 MB/s\u001B[0m eta \u001B[36m0:00:00\u001B[0m00:01\u001B[0m00:01\u001B[0m\n",
"\u001B[?25hRequirement already satisfied: python-dateutil>=2.4 in /home/noverney/miniconda3/lib/python3.10/site-packages (from faker) (2.8.2)\n",
"Requirement already satisfied: six>=1.5 in /home/noverney/miniconda3/lib/python3.10/site-packages (from python-dateutil>=2.4->faker) (1.16.0)\n",
"Installing collected packages: faker\n",
"Successfully installed faker-19.12.0\n"
Expand Down

0 comments on commit a5870eb

Please sign in to comment.