Answered step by step
Verified Expert Solution
Question
1 Approved Answer
No input/output test cases provided by the professor. We have to convert into code Implement in Python a function border_reps (data, k) which outputs a
No input/output test cases provided by the professor. We have to convert into code
Implement in Python a function border_reps (data, k) which outputs a k-list of border representatives of data. It is a list Bx of k objects of data which satisfies the following properties: 1. The 1-list Bi of border representatives of data contains only the centroid of data. 2. A k-list B of border representatives equals (T1.....11-1,T), where (11.---.1-1)=B-1, and is an element of data that is not in BR-1, and has the largest sum of distances to -1 and 1-2- Assume data is a list of tuples or lists of fixed length. A k-list of border repre- sentatives can be computed by the following algorithm: - compute the centroid c of data - set reps to [c] - remove c from data - for k-1 iterations - set repa distances to the list of pairs (x, eucl_aum) of all objects x in data and their sum of euclidean squared distances to the last two objects in reps - sort reps distances by the second element of its pairs - set new_rep to the last element of reps_distances - append new_rep[0] to reps - remove new rep[0] from data - return reps The function sorted (mylist, key = lambda x: x[1]) returns a copy of list mylist sorted by second element. To compute the euclidean squared distance of two objects use the following Python functions def sq_sum(x): return sum((y ** 2 for y in x)) def aq_norm_diff(x, y): return sq_sun((z[0] - z[1] for z in zip(x, y)))Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started