Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python. (a) Recall Manhattan and Euclidean distance calculation by passing by function as discussed in Exercise 4.7. Digital camera images can be formatted in

In Python.

image text in transcribed

(a) Recall Manhattan and Euclidean distance calculation by passing by function as discussed in Exercise 4.7. Digital camera images can be formatted in JFIF files with the extension jpg or jpeg. Let's consider photos, each of which can be described over the features such as color in red (0-255), green (0-255) and blue (0-255), the geocode of shooting location in latitude (-90 - 90), longitude (-180 - 180) and altitude in any feet). With those features, we can compute the distances of any pairs. The sample images are computed by the three caller statements (which are in the last three line) below. nPoints = [(115, 115, 115,-25, 110, 10), (125, 15, 115,-25, 70, 20), (115, 55, 115, 25, -110, 30), (15, 115, 115,-25, 70, 40), (115, 55, 125,-25, 110,50), (115, 115, 115, -25, -110, 60), (115, 115, 55, 25, 70, 70), (115, 115, 15, -25, 110, 80). (55, 125, 115, 25, 70, 90), (15, 115, 115,-25, -110, 100)] dist(manhattanDist, nPoints) dist(euclideanDist, nPoints) distinDim Dist, nPoints) Note that the function dist() takes yet another function, nDimDist() as argument. Practice this high order functional programming skill as illustrated in the textbook. The sample output for 5 images, for simplicity, is: ABCDE A = (115, 115, 115,-25, 110, 10) 0.00 108.63 234.31 111.80 72.80 B = (125, 15, 115,-25, 70, 20) 108.63 0.00 191.57 150.00 65.57 C = (115, 55, 115, 25, -110, 30) 234.31 191.57 0.00 220.45 226.72 D = (15, 115, 115, -25, 70, 40) 111.80 150.00 220.45 0.00 124.10 E = (115, 55, 125,-25, 110, 50) 72.80 65.57 226.72 124.10 0.00 Recall HW3. First eliminate the stop words from the word list for each document. (b) Write a Python code to find a pair of the nearest similar documents. Hint: use Jaccard similarity of document pairs. (C) Improve your code developed above. Explain how the code is improved and how much. A sample run for (a): 0.062 ['doc4', 'doc6'] 0.075 ['doc1', 'doc6'] 0.096 ['doc1', 'doc2'] 0.105 ['doc4', 'doc5'] 0.107 ['doc2', 'doc6'] 0.108 ['doc2', 'doc5'] 0.112 ['doc1', 'doc5'] 0.116 ['doc3', 'doc4'] 0.118 ['doc2', 'doc3'] 0.119 ['doc3', 'doc6'] 0.122 ['doc1', 'doc3'] 0.134 ['doc2', 'doc4'] 0.137 ['doc1', 'doc4'] 0.161 ['doc5', 'doc6'] 0.163 ['doc3', 'doc5']

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago