You should construct a Python 3 program containing your solution to the following
problem and submit your program electronically on Moodle. The name of the file
containing your code should be your student ID e.g. 12345678.py. No other
method of submission is allowed. Your program will be automatically run on
Moodle for sample test cases provided in the project sheet if you click the “check”
link. However, your submission will be tested thoroughly for grading purposes
after the due date. Remember you need to submit the program as a single file and
copy-paste the same program in the provided text box. You have only one attempt
to submit so don’t submit if you are not satisfied with your attempt. All open
submissions at the time of the deadline will be automatically submitted. There is
no way in the system to open the closed submission and reverse your submission.
As we know from earlier project that social media is one of the most attractive
marketing platform nowadays. Therefore, the advertisements need to be more
relevant and interesting to the audience. Many different factors are considered to
adapt the advertisements for each and every user.
In this project, you are requested to write a computer program that can read the
data from a CSV (comma-separated values) file provided to you and return
different interesting analytical results. Your program should follow the following
You need to follow the below instructions of the project input and output.
Your program must define the function main with the following signature:
The input arguments are:
• inputFile is the name of the CSV file containing the information and record
about the location points which need to be analysed for this project. The first
row of the CSV file will contain the many attributes but we are interested in
the following four attributes:
- LocId: A unique ID of a location point.
- Latitude: Latitude of the location point.
- Longitude: Longitude of the location point.
- Category: Location Types which can be many e.g., Parking (P),
Hospital (H), Restaurant (R ), Chemist Shop (C), Super Market (S),
• [locID1,locID2] is an input parameter that accepts a list of two strings
which represent two location IDs.
• radius is the numeric input parameter that defines a circular boundary
around the location IDs provided in queryLocId.
Based on the inputs mentioned above, firstly you need to define two circular
regions of radius radius with center at locID1 and locID2 which we label as
C1 and C2 respectively. Figure 1 presents the scenario for understanding.
The function is required to return the following outputs in the order provided
- Return a list containing two dictionaries (let’s call them D1 and D2), where
the keys in the dictionaries are the location categories, and their values
contain the number of locations for respective category in region C1 and C2
- Return the cosine similarity of the regions C1 and C2 based on the category-
wise number of locations identified inside each region. The formula to
calculate cosine similarity is provided at the end of this project sheet.
- Return a dictionary of category based on the common location IDs existing
in the regions C1 and C2.
- Return a list of two dictionaries: one for each input location ID (i.e., locID1
and locID1), where the key of each dictionary item will be location
category and the value will be a tuple containing the Location ID of the
respective category which is closest to the respective input location ID and
its distance from the same input location ID. The formulate to calculate
distance is provided at the end of this project sheet.