0
The idea is to create a matrix of confusion. yhat_tr has a hundred values(float), positive and negative. d_tr is a column inside an excel file with the same amount of items as yhat_tr. d_tr values are distributed for each idem, but with values 1 and -1.
#TP - TruePositive, FP: FalsePositive, TN: TrueNegative, FN: FalseNegative
TP, FP, TN, FN = 0,0,0,0
for i in yhat_tr:
for a in d_tr:
if i > 0 and a > 0:
TP += 1
elif i > 0 and a < 0:
FP += 1
elif i < 0 and a < 0:
TN += 1
else:
FN += 1
print (FP)
The attempt is for each item of the column y_hat-tr, if the value of yhat_tr is greater than 0 and also its value in d_tr is greater than 0, it adds 1 in the value of TP. Otherwise sum in the other variables like the above rule.
There’s a string where you say there’s only a float...
– bfavaretto
YES!!! You found the issue. d_tr is bringing the header together with the data. When I replace it with another data source the code works. Thanks! Now I just have to figure out how to import without this column caption.
– Douglas
So that’s what the error message is saying, you can’t compare str with int.
– bfavaretto