当前位置:网站首页>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
边栏推荐
- cocos3——8. Implementation Guide for beginners
- Laravel php artisan 自动生成Model+Migrate+Controller 命令大全
- Jerry's ble exiting Bluetooth mode card machine [chapter]
- 2022 information security engineer examination outline
- 从 1.5 开始搭建一个微服务框架——日志追踪 traceId
- Opencv environment, and open a local PC camera.
- How to replace the backbone of the model
- 23.(arcgis api for js篇)arcgis api for js椭圆采集(SketchViewModel)
- HDU 4337 King Arthur's Knights 它输出一个哈密顿电路
- Lost in the lock world of MySQL
猜你喜欢

变量、流程控制与游标(MySQL)

从 1.5 开始搭建一个微服务框架——日志追踪 traceId

Graphical tools package yolov5 and generate executable files exe

首届“量子计算+金融科技应用”研讨会在京成功举办

Appx代码签名指南

Flink Task退出流程与Failover机制

树莓派设置静态ip

源代码保密的意义和措施

Function reentry, function overloading and function rewriting are understood by yourself

HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
随机推荐
硬件之OC、OD、推挽解释
Install torch 0.4.1
Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
杰理之发射端在接收端关机之后假死机【篇】
opencv环境的搭建,并打开一个本地PC摄像头。
Jerry's ble exiting Bluetooth mode card machine [chapter]
Matlab Error (Matrix dimensions must agree)
CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
Stored procedures and functions (MySQL)
杰理之开 BLE 退出蓝牙模式卡机问题【篇】
New benchmark! Intelligent social governance
Decoration design enterprise website management system source code (including mobile source code)
【达梦数据库】添加自动收集统计信息的任务
Household appliance industry under the "retail is king": what is the industry consensus?
Simple bubble sort
从0开始创建小程序
Variables, process control and cursors (MySQL)
【安全的办公和生产力应用程序】上海道宁为您提供ONLYOFFICE下载、试用、教程
Appx code signing Guide
cocos3——8.实现初学者指南