首页 > 解决方案 > 如何获取列表中的最大值然后在 PYTHON 中标记它?

问题描述

我用模糊c均值计算后得到了结果

如何获得列表中每个列表的最大值?我如何标记最大值?

我使用集群=3

这里的结果:

[[0.03740738448970282, 0.9201270778103205, 0.04246553769997666], //the max is 0.92012.. then labeled as C2 
[0.04062653809163984, 0.0238461204483894, 0.93552734145997075], //the max is 0.93552.. then labeled as C3
[0.9479964560714227, 0.010597386771375585, 0.0414061571572017], etc..
[0.37614962184288964, 0.44114302923190574, 0.18270734892520468], 
[0.20274562875747867, 0.4228700262497846, 0.37438434499273676], 
[0.8083572028927598, 0.05195626129940783, 0.1396865358078323], 
[0.05128850852899145, 0.02388543639574726, 0.9248260550752613], 
[0.9002477815473989, 0.03596599813260756, 0.06378622031999359], 
[0.22219257479765195, 0.06316371301545853, 0.7146437121868896], 
[0.05107621048105372, 0.9111492746104877, 0.03777451490845857]]

我期待结果:

C2

C3

C1

C2

C2

ETC..

如果 cluster = 4 所以标记将直到 C4

标签: python

解决方案


arr = [[0.03740738448970282, 0.9201270778103205, 0.04246553769997666],.....,[0.05107621048105372, 0.9111492746104877, 0.03777451490845857]]

for i in arr:
    print('C'+str(i.index(max(i))+1))

输出:-

C2
C3
C1
C2 ........ etc

推荐阅读