Description
GitHub Classroom
Lab 5 – Search and sort
Finding love with Python
Today you are an entrepreneur, you just opened your online dating platform
Your role is to find the ideal partner to our two clients
Pamela George
Our database
Our database
Let’s assume, you have already collected data from male and female that you saved as CSV files (comma-separated values)
1. Open the database
A function to read the database is already implemented
candidates_list = read_database(‘list_males.csv’) candidates_list = candidates_list[1:]
Just to remove the header The database is stored in a nested list
[[‘Douglas’, 39, 183, 67],
[‘Austin’, 29, 169, 45],
[‘Lee’, 31, 173, 48], candidates_list[2]
[‘Cody’, 27, 169, 45],
[‘Bryan’, 37, 180, 65],
[‘Luis’, 33, 176, 52],
[‘Carlos’, 35, 178, 60],
[‘Alan’, 38, 183, 67],
[‘Mario’, 42, 188, 70],
[‘Juan’, 32, 174, 52]]
2. The clients
The goal of this lab is to find a good match to our two clients We will define a good match by “a partner with similar features “
Close age, close height and close income
Peter has a closer profile than Henry then he is a better match for Pamela
3. Euclidean distance
TO DO:
Implement a function to compute the Euclidean distance between a client (Pamela or George) and one person in the dataset
4. Compute the distance between the client and the candidates
TO DO:
Compute all the distances between Pamela (or George) and all the candidates in the database (male or female)
You will implement this in
ComputeAllDistances()
This function will return the list of distances between one client (Pamela or George) and a database.
5. Find the best match
TO DO:
Complete the function FindMin() that returns the minimum value in a list and its corresponding index
Using the index returned by your function, display the name and characteristic of the best match for our client
By the way, you just implemented a naïve nearest neighbor search
6. Bonus
• What can you say about the complexity of this search strategy?
• How would you return the top 5 best match? (try to implement
it)
• Can we return all the results given a range over each criterion (no need to implement)
! Terminology alert !
A unit test is a type of software testing technique that focuses on testing individual components or functions of a program in isolation to ensure they perform as expected. This helps developers identify and fix errors early in the development process.
Note that you now have:
YourHomework.py
AND
YourHomework_test.py This file contains the unit tests
Only work on the origin *.py file I am providing you!
Do not do that!!
Work only here
• Does it change the way I push my work on Github? • Not at all, push and commit as before, follow Lab0 very carefully
• Why do we do unit test?
• What unit test does for me?
• It will directly tell you if you are code is right or wrong such that you can correct a function that you have not coded properly!
Let’s push a code on GitHub to see what is happening!!
Two possibilities 1.Your code is working as intended
You have this little green check that means that all your code is working as intended
You will directly see which tests has been successful or failing
Let’s push a code on GitHub to see what is happening!!
Two possibilities
2.Your code is NOT working as intended
You will directly see which tests has been
successful or failing
AND
OR
How to run unit test locally In 5 clicks only!
How to run unit test locally
How to run unit test locally
How to run unit test locally
Now you are ready to go if you want to test your code locally
Feedback via pull request
You now have a branch feedback in your repository, we will use it to send you feedback directly (you will receive an email each time we
are trying to reach you out via this mean)
Reviews
There are no reviews yet.