<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Representations and metrics
Question 1
<img src="images/Screen Shot 2016-07-02 at 9.34.11 AM.png">
Screenshot taken from Coursera
<!--TEASER_END-->
Answer
- https
Step1:  Question 2
<img src="images/Screen Shot 2016-07-02 at 9.39.55 AM.png">
Screenshot taken from Coursera
<!--TEASER_END-->
Answer
- Word counts
    - Sentence 1
Step2:  Question 3
<img src="images/Screen Shot 2016-07-02 at 9.39.59 AM.png">
Screenshot taken from Coursera
<!--TEASER_END-->
<ASSISTANT_TASK:>
Python Code:
def calculate_weight(feature):
    weight = (1/(max(feature) - min(feature))) ** 2
    return weight
price = calculate_weight(np.array([500000, 350000, 600000, 400000],  dtype=float))
room = calculate_weight(np.array([3, 2, 4, 2],  dtype=float))
lot = calculate_weight(np.array([1840, 1600, 2000, 1900],  dtype=float))
print price
print room
print lot
Explanation: Representations and metrics
Question 1
<img src="images/Screen Shot 2016-07-02 at 9.34.11 AM.png">
Screenshot taken from Coursera
<!--TEASER_END-->
Answer
- https://www.coursera.org/learn/ml-clustering-and-retrieval/discussions/weeks/2/threads/yoIkdz9XEeaQYwrcKTQWAQ
- The coordinate differences get squared before scaling, so the amount of variations gets squared too
End of explanation
import numpy as np
s1 = np.array([2, 1, 1, 1, 1, 1, 1, 1, 0, 0], dtype=float)
s2 = np.array([0, 2, 1, 1, 0, 0, 0, 1, 2, 1], dtype=float)
print s1
print s2
euclidean_distance = np.sqrt(np.sum((s1 - s2)**2))
euclidean_distance
Explanation: Question 2
<img src="images/Screen Shot 2016-07-02 at 9.39.55 AM.png">
Screenshot taken from Coursera
<!--TEASER_END-->
Answer
- Word counts
    - Sentence 1: [2, 1, 1, 1, 1, 1, 1, 1, 0]
    - Sentence 2: [0, 2, 1, 1, 0, 1, 0, 1, 2]
- Euclidean distance:
End of explanation
import numpy as np
s1 = np.array([2, 1, 1, 1, 1, 1, 1, 1, 0, 0], dtype=float)
s2 = np.array([0, 2, 1, 1, 0, 0, 0, 1, 2, 1], dtype=float)
print s1
print s2
cosine_similarity = np.dot(s1, s2)/(np.sqrt(np.sum(s1**2)) * np.sqrt(np.sum(s2**2)))
cosine_distance = 1 - cosine_similarity
cosine_distance
Explanation: Question 3
<img src="images/Screen Shot 2016-07-02 at 9.39.59 AM.png">
Screenshot taken from Coursera
<!--TEASER_END-->
End of explanation
<END_TASK>