How to create the data set below in python?
Data Set:
A: 0 - 20% of readings
B: 20% - 40% of readings
C: 40% - 60% of readings
D: 60% - 80% of readings
E: 80% - 100% of readings
Data:
values = [68,68,69,68,69,70,71,75,72,73,72,72,73,72,72,73,70,71,73,72,72,71,69,68
69,68,69,68,69,68,68,68,68,69,68,69,70,71,75,72,69,68,68,68,69,68,69,70
71,75,72,69,68,69,68,69,68,69,68,68,60,60,61,60,61,65,69,69,72,73,72,72
73,72,72,73,70,71,73,75,78,80,82,84,87,84,84,83,82,79,78,76,74,73,72,72
72,71,75,72,69,68,68,68,69,68,69,70,71,75,72,69,68,69,68,69,68,69,68,68]
Example:
A = [68,68,69,68,69,70,71,75,72,73]
That represents 20% of the whole
Note: I know that it is possible to calculate manually using percentage accounts based on the total, but I would like to use some library to get more performance
Mathematical resolution
@staticmethod
def while_generator(start, n):
i = start
while i <= n:
yield i
i += 1
@staticmethod
def Kmodeling():
X,Y = data() # Create X and Y
total = len(Y)
a1 = int((total / 100) * 20)
a2 = int((total / 100) * 40)
a3 = int((total / 100) * 60)
a4 = int((total / 100) * 80)
A = [Y[i] for i in while_generator(0, a1)]
B = [Y[i] for i in while_generator(a1,a2)]
C = [Y[i] for i in while_generator(a2,a3)]
D = [Y[i] for i in while_generator(a3,a4)]
E = [Y[i] for i in while_generator(a4,(total - 1))]
print("""Total of elements: {0}\n
Conjunto A = {2} - Size {1}
Conjunto B = {4} - Size {3}
Conjunto C = {6} - Size {5}
Conjunto D = {8} - Size {7}
Conjunto E = {10} - Size {9}
""".format(
total,len(A),A,len(B),B,len(C),C,len(D),D,len(E),E
))
Output:
Total of elements: 120
Conjunto A = [68, 68, 69, 68, 69, 70, 71, 75, 72, 73, 72, 72, 73, 72, 72, 73, 70, 71, 73, 72, 72, 71, 69, 68, 69]
Conjunto B = [69, 68, 69, 68, 69, 68, 68, 68, 68, 69, 68, 69, 70, 71, 75, 72, 69, 68, 68, 68, 69, 68, 69, 70, 71]
Conjunto C = [71, 75, 72, 69, 68, 69, 68, 69, 68, 69, 68, 68, 60, 60, 61, 60, 61, 65, 69, 69, 72, 73, 72, 72, 73]
Conjunto D = [73, 72, 72, 73, 70, 71, 73, 75, 78, 80, 82, 84, 87, 84, 84, 83, 82, 79, 78, 76, 74, 73, 72, 72, 72]
Conjunto E = [72, 71, 75, 72, 69, 68, 68, 68, 69, 68, 69, 70, 71, 75, 72, 69, 68, 69, 68, 69, 68, 69, 68, 68]
Print: