python - 如何获取列表中的最大值然后在 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
解决方案
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
推荐阅读
- spring-boot - 引起:org.springframework.expression.spel.SpelEvaluationException:EL1007E:在 null 上找不到属性或字段“XXX”
- haskell - 无法让这个微不足道的 haskel 程序运行
- docker - Docker/SAM 本地 aws sdk 的请求因 (InvalidSignatureException) 而失败
- css - 离子范围的最小和最大旋钮的离散颜色
- facebook-messenger - 识别 Facebook Messenger Lite 用户
- python - 无法摆脱 BeautifulSoup 引起的导航问题
- android - 当 notifydatasetchanged 在 ui 线程上运行时,Android 'FragmentManager 已经在执行事务'
- r - 更改 Linux 上的默认 R 库目录
- regex - 在 Powershell 中使用正则表达式获取具有日期文件类型的子项
- javascript - onClick 功能在移动设备上不起作用