当前位置:网站首页>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
边栏推荐
- An error in SQL tuning advisor ora-00600: internal error code, arguments: [kesqsmakebindvalue:obj]
- Centerx: open centernet in the way of socialism with Chinese characteristics
- mos管实现主副电源自动切换电路,并且“零”压降,静态电流20uA
- Appx代码签名指南
- Make (convert) ICO Icon
- Install torch 0.4.1
- [colmap] 3D reconstruction with known camera pose
- Jericho is in non Bluetooth mode. Do not jump back to Bluetooth mode when connecting the mobile phone [chapter]
- 装饰设计企业网站管理系统源码(含手机版源码)
- R数据分析:cox模型如何做预测,高分文章复现
猜你喜欢
When you go to the toilet, you can clearly explain the three Scheduling Strategies of scheduled tasks
Intelligent static presence detection scheme, 5.8G radar sensing technology, human presence inductive radar application
R数据分析:cox模型如何做预测,高分文章复现
Household appliance industry under the "retail is king": what is the industry consensus?
Another million qubits! Israel optical quantum start-up company completed $15million financing
装饰设计企业网站管理系统源码(含手机版源码)
Jerry's broadcast has built-in flash prompt tone to control playback pause [chapter]
19.(arcgis api for js篇)arcgis api for js线采集(SketchViewModel)
Sub pixel corner detection opencv cornersubpix
Stored procedures and functions (MySQL)
随机推荐
【基于 RT-Thread Studio的CPK-RA6M4 开发板环境搭建】
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
Variables, process control and cursors (MySQL)
VHDL实现任意大小矩阵乘法运算
Decoration design enterprise website management system source code (including mobile source code)
opencv环境的搭建,并打开一个本地PC摄像头。
「小样本深度学习图像识别」最新2022综述
注意力机制原理
Flutter3.0了,小程序不止于移动应用跨端运行
Domcontentloaded and window onload
VHDL实现单周期CPU设计
Room rate system - login optimization
Starting from 1.5, build a micro Service Framework -- log tracking traceid
Le tube MOS réalise le circuit de commutation automatique de l'alimentation principale et de l'alimentation auxiliaire, et la chute de tension "zéro", courant statique 20ua
杰理之发射端在接收端关机之后假死机【篇】
Install torch 0.4.1
Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
硬件之OC、OD、推挽解释
Appx代码签名指南
The latest 2022 review of "small sample deep learning image recognition"