Can someone help me with my code, Im having a difficult time understanding | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone help me with my code, Im having a difficult time understanding

In the Machine Learning Repository (http://archive.ics.uci.edu/ml) one of their most popular databases is the Iris database. Irises come in three different species: setosa, virginica, and versicolor. Each entry in the data set has five values: sepal length, sepal width, petal length, petal width, and the species name (setosa, versicolor, and virginica). Read in the data and create a dictionary with the key as the species name and the values as the averages of each of the four characteristic values: sepal length, sepal width, petal length, petal width. That is, the size of the dictionary will be three. Write a program to create a list of setosa petal length and a list of virginica petal length. Use function correlation to find the correlation between setosa and virginica petal length. Print the correlation rounded to two digits. My code: import pandas as pd data = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data',header=None) data.columns = ['sepal length', 'sepal width', 'petal length', 'petal width', 'class'] data.head() Output: setola petal length: [1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.4, 1.5, 1.4, 1.5, *goes on and prints all the data for this area*] virginica petal length: [6.0, 5.1, 5.9, 5.6, 5.8, 6.6, 4.5, 6.3, 5.8, 6.1, 5.1, *goes on and prints all the data for this area*] correlation between sets and virginica petal length: 0.10

10th Nov 2020, 8:37 PM
...
... - avatar
2 Answers
+ 5
... , have you done already a try by yourself? If so - please put your code in playground and link it here. Otherwise please do a try by yourself first and link it here. Please also give us a description where you have a problem. Thanks"
10th Nov 2020, 8:51 PM
Lothar
Lothar - avatar
0
Lothar , I did try it by myself, its above, I changed my code and the link to it is here https://code.sololearn.com/cElG9FfTGJqG/#py My problem is trying to understand it.. I know what its asking for I just don't know how to do it? execute it?
10th Nov 2020, 11:20 PM
...
... - avatar