0

I have created an IF statement tree to give sets of data in arrays a label. The multidimensional array is called featureVectors and numberOfSides, standardDeviationsPerimeter, standardDeviationsAngles(not used in this section of code) and largestAngles are all arrays included in the array. I want to pass all the arrays in featureVectors through the IF statement but it doesn't loop past the first one therefore giving every dataset the label 2. I am not very good at loops with multidimensional arrays.This is my code so far:

for shape in range(0, len(sidesDividedByPerimeter)):
    if numberOfSides[0] == 1:
       labels = 0
    elif numberOfSides[0] > 1 and numberOfSides[0] < 3.5:
       labels = 1
    elif numberOfSides[0] > 3.5:
       if standardDeviationsPerimeter[0] < 0.1458:
           if largestAngles[0] < 104.79:
              labels = 2
           elif largestAngles[0] >= 104.79:
              labels = 3
    elif standardDeviationsPerimeter[0] >= 0.1458:
           labels = 4

    print(featureVectors)
    print(labels)
    #featureVectors[shape].append(labels)

This gives me the output:

I just need it to run through each of the arrays instead of stopping at the first. I know its because of my [0]'s but i just dont know what I should do, im only learning python.

1 Answer 1

0

Here shape is the cycling variable that adds with one in each cycling step, but you are not using this variable at all in the cycling body.

I don't quite understand what all your arrays mean, but try to replace all [0] with [shape] and perhaps it will work as you expected.

Sign up to request clarification or add additional context in comments.

1 Comment

if i do that it returns me [2,2,0,0,0], the first 4 values are correct but the 5th should be a 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.