Assignment no 2(mid term preparation)
Assignment no 2(mid term preparation)
Model Answer
Assiment #2
Dr. Mohamed Abdelhafeez
Question 1: Data Preprocessing
a) Given the following dataset
i. Compute the Euclidian distance de (x1, x3) and de (x2, x4)
math physics
x1 85 0.7
x2 65 0.8
x3 80 0.2
x4 75 0.9
a) Build a dataset matrix of size 3 objects (documents) by 5 attributes (terms) using binary term
frequency.
P
c) Identify the first nearest neighbour of the document D3 using hamming distance
Question 3 Mongo DB
1. What is MongoDB?
A. Relational database
B. Document-oriented database
C. NoSQL database
D. Both B and C
2. In MongoDB, what is a document equivalent to in a SQL database?
Table
Record
Field
Column
3. Which method is used to insert a single document into a MongoDB collection using
PyMongo?
o add_one()
o insert_single()insert_one()
o add_document()
4. What is the purpose of the PyMongo package in Python with respect to MongoDB?
A. Web development
B. Data visualization
C. MongoDB driver for Python
D. Machine learning
5. In MongoDB, what does RUD stand
for?
A. Create, Retrieve, Update, Delete
B. Connect, Read, Update, Delete
C. Collect, Retrieve, Use, Delete
D. Create, Read, Upload, Delete
6. How do you update a document in MongoDB using PyMongo?
A. update_single()
B. modify_one()
C. update_one()
D. change_document()
7. In PyMongo, what does the $set operator do in the context of updating a document?
A. Sets the document to null
B. Adds a new field to the document
C. Updates a specific field in the document
D. Sorts the document in ascending order
8. Which method is used to delete a single document from a MongoDB collection in
PyMongo?
A. delete_one()
B. remove_single()
C. erase_one()
D. discard_one()
9. What is the purpose of the sort() method in MongoDB when using PyMongo?
A. Group documents in a collection
B. Filter documents based on a condition
C. Order the result in ascending or descending order
D. Limit the number of documents returned