当前位置:网站首页>Sorting operation partition, argpartition, sort, argsort in numpy
Sorting operation partition, argpartition, sort, argsort in numpy
2022-07-07 03:23:00 【The mountain of ignorance, the valley of despair, the slope of 】
Reference resources :
Explain in detail :https://blog.csdn.net/m0_37192554/article/details/107459712
Usually used to full sorting np.sort, The complexity is between and . If the array to be sorted is particularly large , The time cost is not small . But generally, the sorting of extremely large arrays does not need to be full , Maybe you just need to take Top K. At this point, you can use partial sorting , such as numpy.partition and numpy.argpartition.
partition The function functions as follows : Given a array, Rearrange the elements to make the k The element of bit happens to be the first k The element of bit . All Biti k Bit elements small elements are placed in front of it , All Biti k The elements with large bit elements are placed behind it . in other words , This article k Bit elements divide the entire array into two parts , The front is smaller than it , The back is bigger than it . But the elements inside each part are not sorted .
kth It can also be negative
Represents an array a pass the civil examinations 2 Large elements are elements 8 In the sorting completion array b The last of 2 In a position , Index b[-2] It's about
Of course , What's the use of this ? One of the uses is if we have a very large array , If we want to find the biggest one 10 Number , What shall I do? , We can use sort function , Then take it out after sorting , But this method is time-consuming when the array is too large , So we can use partition function ,partition Sort the array only once , find k The number of positions is enough , And yes k The order of position left and right doesn't care , Less work means faster efficiency
边栏推荐
- HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
- Sub pixel corner detection opencv cornersubpix
- Another million qubits! Israel optical quantum start-up company completed $15million financing
- SQL中删除数据
- DOMContentLoaded和window.onload
- Variables, process control and cursors (MySQL)
- How does C language (string) delete a specified character in a string?
- 20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
- The latest 2022 review of "small sample deep learning image recognition"
- 上个厕所的功夫,就把定时任务的三种调度策略说得明明白白
猜你喜欢
19.(arcgis api for js篇)arcgis api for js线采集(SketchViewModel)
如何替换模型的骨干网络(backbone)
Laravel php artisan 自动生成Model+Migrate+Controller 命令大全
How to replace the backbone of the model
25.(arcgis api for js篇)arcgis api for js线修改线编辑(SketchViewModel)
函数重入、函数重载、函数重写自己理解
图形化工具打包YOLOv5,生成可执行文件EXE
Decoration design enterprise website management system source code (including mobile source code)
Flink Task退出流程与Failover机制
上个厕所的功夫,就把定时任务的三种调度策略说得明明白白
随机推荐
Development of wireless communication technology, cv5200 long-distance WiFi module, UAV WiFi image transmission application
Jerry's RTC clock development [chapter]
又一百万量子比特!以色列光量子初创公司完成1500万美元融资
Install torch 0.4.1
DOMContentLoaded和window.onload
[dream database] add the task of automatically collecting statistical information
树莓派设置静态ip
函数重入、函数重载、函数重写自己理解
unrecognized selector sent to instance 0x10b34e810
杰理之开 BLE 退出蓝牙模式卡机问题【篇】
Jerry's FM mode mono or stereo selection setting [chapter]
校招行测笔试-数量关系
制作(转换)ico图标
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
Domcontentloaded and window onload
硬件之OC、OD、推挽解释
Household appliance industry under the "retail is king": what is the industry consensus?
房费制——登录优化
腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
22.(arcgis api for js篇)arcgis api for js圆采集(SketchViewModel)