Question: Question 2: In the next cell, load the School1.csvSchool2.csv data, which contain 1000 trait values for 2 schools. school1 = pd.read_csv(school1.csv) school2 = pd.read_csv(school2.csv) Compute
Question 2: In the next cell, load the School1.csv\School2.csv data, which contain 1000 trait values for 2 schools.
school1 = pd.read_csv("school1.csv") school2 = pd.read_csv("school2.csv") Compute the dissimilarity (according to the above method) between School1 and School2. Call your answer dissimilarity. Use a single line of code to compute the dissimilarity answer.
dissimilarity = sum([abs(number) for number in (np.array(school1["Trait value"])-np.array(school2["Trait value"]))]) #Use only a single line of code
dissimilarity
14060.558701067917
Question 3. Suppose you've already decided on a weight for each trait. You saved the weights in a weights.csv file. Load them into a table called weights in the cell below.
weights = pd.read_csv("weights.csv") weights
| Weight | |
|---|---|
| 0 | 0.001 |
| 1 | 0.200 |
| 2 | 0.050 |
| 3 | 0.050 |
| 4 | 0.200 |
| ... | ... |
| 995 | 0.050 |
| 996 | 0.050 |
| 997 | 0.050 |
| 998 | 0.050 |
| 999 | 0.200 |
1000 rows 1 columns
Question 4. Now use the revised method to compute a revised dissimilarity between School 1 and School 2.
Hint: Using array arithmetic, your answer should be almost as short as in question 1.
revised_dissimilarity = ... #Use only a single line of code
revised_dissimilarity
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
