Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! I've been working on this for 14 hours. Python 2.7, can only import NumPy! Link to CSV data: https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data Right now, my program

Please help! I've been working on this for 14 hours. Python 2.7, can only import NumPy!

Link to CSV data: https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data

Right now, my program uploads the csv and stores it as an array using np.genfromtxt(). The training data that is uploaded has (75) total instances of (3) different flower types with (4) dimensions. The program is to 'learn' the classifcation of the flowers based on the dimensions. The test data also has (75) total instances with the same type of dimensionalame data. I have created 4 separate arrays:

1.) training data as floats; 2.) training class name as strings; 3.) test data as floats; 4.) test class name as strings.

The program is to take the dimensions of (1) test instance and calculate the distance between each (75) training distance. Whichever type has the closest distance/match, the program will output the prediction of which flower it is. This program will loop to do this over the whole test data

I keep getting erros because the data are floats and I don't know another way to work around to complete the assignment. I need help!

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Machine learning is an area of computer science whose aim is to create programs which improve their performance with experience. There are many applications for this, including: face recognition, recommendation systems, defect detection, robot navigation, and game playing. For this assignment, you will implement a simple machine lening algorithm called Nearest Neighbor which learns by remembering training examples. It then classifies test examples by choosing the class of the "closest training example. The notion of "closeness" differs depending on applications. You will need to use the Nearest Neighbor algorithm to learn and classify types of Iris plants based on their sepal and petal length and width. There are three Iris types you will need to classify: Iris Setosa Iris Versicolour Iris Virginica The learning will be done by remembering training examples stored in a comma-separated file. The training examples include different measurements which collectively are called features or attributes, and a class labei for different instances. These are: 1. sepal length in cm 2. sepal width in cm 3. petal length in cm 4. petal width in cm 5. class: - Iris Setosa Iris Versicolour ris Virginica To see how well the program "learned", you will then load a file containing testing examples, which will include the same type of information, but for different instances. For each test instance, you will apply the Nearest Neighbor algorithm to classify the instance. This algorithm works by choosing a class label of the "closest" training example, where "closest means shortest distance. The distance is computed using the following formula: where x.y are two instances (i.e. a training or a testing example), slx. sly are their sepal lengths, Sw, sWy are their sepal widths, pl.ply are their petal lengths, and pw.pwy are their petal widths. After you finish classifying each testing instance, you will then need to compare it to the "true" label that is specified for each example and compute the accurocy. Accuracy is measured as the number of correctly classified instances divided by the number of total testing instances. Machine learning is an area of computer science whose aim is to create programs which improve their performance with experience. There are many applications for this, including: face recognition, recommendation systems, defect detection, robot navigation, and game playing. For this assignment, you will implement a simple machine lening algorithm called Nearest Neighbor which learns by remembering training examples. It then classifies test examples by choosing the class of the "closest training example. The notion of "closeness" differs depending on applications. You will need to use the Nearest Neighbor algorithm to learn and classify types of Iris plants based on their sepal and petal length and width. There are three Iris types you will need to classify: Iris Setosa Iris Versicolour Iris Virginica The learning will be done by remembering training examples stored in a comma-separated file. The training examples include different measurements which collectively are called features or attributes, and a class labei for different instances. These are: 1. sepal length in cm 2. sepal width in cm 3. petal length in cm 4. petal width in cm 5. class: - Iris Setosa Iris Versicolour ris Virginica To see how well the program "learned", you will then load a file containing testing examples, which will include the same type of information, but for different instances. For each test instance, you will apply the Nearest Neighbor algorithm to classify the instance. This algorithm works by choosing a class label of the "closest" training example, where "closest means shortest distance. The distance is computed using the following formula: where x.y are two instances (i.e. a training or a testing example), slx. sly are their sepal lengths, Sw, sWy are their sepal widths, pl.ply are their petal lengths, and pw.pwy are their petal widths. After you finish classifying each testing instance, you will then need to compare it to the "true" label that is specified for each example and compute the accurocy. Accuracy is measured as the number of correctly classified instances divided by the number of total testing instances

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

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions

Question

Explain the forces that influence how people handle conflict

Answered: 1 week ago