Outputs Python data alignment results using labeling

Asked 6 days ago, Updated 6 days ago, 1 views

 print ("ABC placement distance is "", [math.fsum(arr1 + arr2 + arr3)/n]", "average" per picker, [[math.fsum(arr1 + arr2 + arr3)/no]", "move"
 print ("ACB placement distance is "", [math.fsum(arr4 + arr5 + arr6)/n]], "".", "average per picker", [[math.fsum(arr4 + arr5 + arr6)/n/o]", "moving")
 print ("BAC placement distance is "", [math.fsum(arr7 + arr8 + arr9)/n], "".", "average per picker", [[math.fsum(arr7 + arr8 + arr9)/n/o], "moving")
 print ("BCA placement distance is "", [math.fsum(arr10 + arr11 + arr12)/n]], "".", "Average per picker", [math.fsum(arr10 + arr11 + arr12)/n/o]", "Move")
 print ("CAB placement distance is "", [math.fsum(arr13 + arr14 + arr15)/n]], "".", "average per picker", [math.fsum(arr13 + arr14 + arr15) / n/o]", "Move")
 print ("CBA placement distance is "", [math.fsum(arr16 + arr17 + arr18)/n]], "".", "average per picker", [[math.fsum(arr16 + arr17 + arr18) / n/o]", "Move")
 print("ABMIXC placement distance is "", [[math.fsum(arr19 +arr20)/n]], "", "average per picker", [[math.fsum(arr19 +arr20)/no]], "move")
 print("AMIXCB placement distance is "", [[math.fsum(arr21 +arr22)/n]], "", "average per picker", [[math.fsum(arr21 +arr22)/no]], "move")
 print("BAMIXC placement distance is "", [[math.fsum(arr23 +arr24)/n]], "", "average per picker", [[math.fsum(arr23 +arr24)/no]", "move")
 print("CAMIXB placement distance is "", [[math.fsum(arr25 +arr26)/n]], "", "average per picker", [[math.fsum(arr25 +arr26)/no]], "move")

data =[[math.fsum(arr1 + arr2 +arr3)/n],[math.fsum(arr4 + arr5 +arr6)/n],[math.fsum(arr7 + arr8 +arr9)/n],[math.fsum(arr10 + arr11 +arr12)/n],[math.fsum(arr13 + arr14 +arr15)/n],[math.fsum(arr16 + arr17 +arr18)/n],[math.fsum(arr19 +arr20)/n],[math.fsum(arr21 +arr22)/n],[math.fsum(arr23 +arr24)/n],[math.fsum(arr25 +arr26)/n]]
sorted_data = sorted(data)
print("Best Ranking", sorted_data)

This is what I've made, and when I print this, the optimal ranking is [[271.1066865802296], [294.2983617934121], [309.1016981601108], [335.8336838245576], [376.2574681853031], [401.50865680226], [401.508458]18853], and this way

[ABC, BAC, CAB...] I want to change it to this kind of feeling

python

2022-09-20 14:40

1 Answers

import math
import random

random.seed(0)
arr = [[random.random()] for _ in range(27)]
n = 4


dat = [
    ("ABC", math.fsum(arr[1] + arr[2] + arr[3]) / n),
    ("ACB", math.fsum(arr[4] + arr[5] + arr[6]) / n),
    ("BAC", math.fsum(arr[7] + arr[8] + arr[9]) / n),
    ("BCA", math.fsum(arr[10] + arr[11] + arr[12]) / n),
    ("CAB", math.fsum(arr[13] + arr[14] + arr[15]) / n),
    ("CBA", math.fsum(arr[16] + arr[17] + arr[18]) / n),
    ("ABMIXC", math.fsum(arr[19] + arr[20]) / n),
    ("AMIXCB", math.fsum(arr[21] + arr[22]) / n),
    ("BAMIXC", math.fsum(arr[23] + arr[24]) / n),
    ("CAMIXB", math.fsum(arr[25] + arr[26]) / n),
]

for e in dat:
    print(f"{e[0]} Placement distance is {e[1]}")

sorted_dat = sorted(dat, key=lambda e: e[1])
print(sorted_dat)
print([e[1] for e in sorted_dat])
print([e[0] for e in sorted_dat])

ABC placement distance is 0.3593606835160277.
ACB placement distance is 0.42500186196344886.
BAC placement distance is 0.3408229299215786.
BCA placement distance is 0.42365939635310734.
CAB placement distance is 0.406169885548749.
CBA placement distance is 0.6756872420006207.
ABMIXC placement distance is 0.30307837993972886.
AMIXCB placement distance is 0.40716750905703053.
The BAMIXC deployment distance is 0.28903166184203866.
The CAMIXB placement distance is 0.13371826088053737.
[('CAMIXB', 0.13371826088053737), ('BAMIXC', 0.28903166184203866), ('ABMIXC', 0.30307837993972886), ('BAC', 0.3408229299215786), ('ABC', 0.3593606835160277), ('CAB', 0.406169885548749), ('AMIXCB', 0.40716750905703053), ('BCA', 0.42365939635310734), ('ACB', 0.42500186196344886), ('CBA', 0.6756872420006207)]
[0.13371826088053737, 0.28903166184203866, 0.30307837993972886, 0.3408229299215786, 0.3593606835160277, 0.406169885548749, 0.40716750905703053, 0.42365939635310734, 0.42500186196344886, 0.6756872420006207]
['CAMIXB', 'BAMIXC', 'ABMIXC', 'BAC', 'ABC', 'CAB', 'AMIXCB', 'BCA', 'ACB', 'CBA']


2022-09-20 14:40

If you have any answers or tips


© 2022 pinfo. All rights reserved.