Machine Learning-Split to Achieve Gain
This code works for the 2 first problems and not for the others....could someone please give me a hint as why it is not working? Thanks in advance S = [int(x) for x in input().split()] A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] Sp =[] for n in S: if n == 1: Sp.append(n) posS = sum(Sp)/len(S) giniS = float(2*posS*(1-posS)) Ap =[] for n in A: if n == 1: Ap.append(n) posA = sum(Ap)/(len(A)) giniA = float(2*posA*(1-posA)) Bp =[] for n in B: if n == 1: Bp.append(n) posB = sum(Bp)/len(A) giniB = float(2*posB*(1-posB)) Info_gain = giniS - ((sum(A)/sum(S))*giniA) - ((sum(B)/sum(S))*giniB) print(float(round(Info_gain, 5)))