jeudi 24 septembre 2020

IndexError: arrays used as indices must be of integer (or boolean) type python3

here is my code.

for i in output:
    if output[i] >= 0.80 and output[i] < 1 :
        output[i] = "very positive"
    elif output[i] >= 0.60 and output[i] < 0.80 :
        output[i] = "positive"
    elif output[i] >= 0.40 and output[i] < 0.60 :
        output[i] = "notr"
    elif output[i] >= 0.20 and output[i] < 0.40 :
        output[i] = "negative"
    elif output[i] >= 0 and output[i] < 0.20 :
        output[i] = "very negative"

and here is error.

IndexError                                Traceback (most recent call last)
<ipython-input-81-84cbeed85d45> in <module>
      1 for i in output:
----> 2     if output[i] >= 0.80 and output[i] < 1 :
      3         output[i] = "very positive"
      4     elif output[i] >= 0.60 and output[i] < 0.80 :
      5         output[i] = "positive"

IndexError: arrays used as indices must be of integer (or boolean) type

Output variable consists of values ​​between 0 and 1.

please help guys.

Aucun commentaire:

Enregistrer un commentaire