DAT 650 Module Four Lab Worksheet (1)

.docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

650

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by DeaconSeaLionMaster750

Report
DAT 650 Module Four Lab Worksheet k-Nearest Neighbor and Euclidean Distance Overview In this lab, you will become familiar with k-nearest neighbor (kNN) and calculating the Euclidean distance between observations. You will be introduced to how the algorithm functions and how to choose the proper k value, calculate distances, and use the algorithm for estimation and prediction. Instructions First, complete the below labs in the uCertify lab environment. Then, replace the bracketed text with the relevant information. Please note: This assignment will be submitted and graded in Brightspace. uCertify Labs 5.2.1 Running kNN 5.3.1 Calculating the Euclidean Distance Lab 5.2.1 Running kNN 1. Follow the lab instructions provided, which utilize RStudio within uCertify. After successfully completing the given code to run kNN in step 5, provide a screenshot of the code and generated output to show successful execution.
2. In addition to the screenshot, write two to three paragraphs that describe the utilized code and provide an example of how kNN could be used in a real-world scenario. The provided code snippet utilizes the k-nearest neighbors (kNN) algorithm, a popular machine learning technique used for classification and regression tasks. In this script, the ‘class’ library is first loaded to access the kNN function. Subsequently, a new data point labeled ‘new’ is defined, along with three existing data points labeled ‘A,’ ‘B,’ and ‘C,’ each representing different classes or categories: “Dark,” “Medium,” and “Light.” These data points are then combined into a matrix named ‘data,’ with the appropriate column and row names assigned to it. The ‘knn’ function is then applied to predict the class label of the new data point (‘new’) based on its nearest neighbors in the ‘data’ matrix. The ‘k’ parameter specifies the number of nearest neighbors to consider, while the ‘cl’ parameter provides the true class labels for the existing data points. By setting ‘prob = TRUE,’ the function returns the probability estimates for each class. In a real-world scenario, kNN could be used in various applications such as recommendation systems, image recognition, and medical diagnosis. For example, in a recommendation system for online shopping, kNN could analyze a user’s past purchase history and compare it with similar users’ preferences to recommend products they might like. In image recognition tasks, kNN could classify images based on their similarity to previously labeled images, aiding in tasks like facial recognition or object detection. Additionally, in medical diagnosis, kNN could analyze patient data such as symptoms and medical history to predict the likelihood of certain diseases or conditions, assisting healthcare professionals in making informed decisions about patient care. Overall, kNN’s simplicity and effectiveness make it a versatile tool in various real-world scenarios where classification or regression tasks are involved. Lab 5.3.1 Calculating the Euclidean Distance 1. Follow the lab instructions provided, which utilizes RStudio within uCertify. After successfully completing the given code to calculate Euclidean distance in step 5, provide a screenshot of the code and generated output to show successful execution.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help