sum(..) over(..)在计算权重中的应用

SQL SERVER 2005有一新语法:SUM(...) OVER(...)可用于计算各成分的权重:

select customerID, productID, orderDate, orderAmount
from Orders

customerID  productID   orderDate               orderAmount
----------- ----------- ----------------------- ---------------------
1           1           2007-01-01 00:00:00.000 20.00
1           2           2007-01-02 00:00:00.000 30.00
1           2           2007-01-05 00:00:00.000 23.00
1           3           2007-01-04 00:00:00.000 18.00
2           1           2007-01-03 00:00:00.000 74.00
2           1           2007-01-06 00:00:00.000 34.00
2           2           2007-01-08 00:00:00.000 10.00

select customerID,  productID, orderDate, orderAmount,
       orderAmount / sum(orderAmount) OVER (Partition by CustomerID) as Pct
from Orders

customerID  productID   orderDate               orderAmount   Pct
----------- ----------- ----------------------- ------------  -------
1           1           2007-01-01 00:00:00.000 20.00         0.2197
1           2           2007-01-02 00:00:00.000 30.00         0.3296
1           2           2007-01-05 00:00:00.000 23.00         0.2527
1           3           2007-01-04 00:00:00.000 18.00         0.1978
2           1           2007-01-03 00:00:00.000 74.00         0.6271
2           1           2007-01-06 00:00:00.000 34.00         0.2881
2           2           2007-01-08 00:00:00.000 10.00         0.0847

当然,它也可以作用于MIN等聚合函数

### MPDIoU 的定义与背景 在信息技术领域,MPDIoU 并不是一个广泛使用的标准术语。然而,基于其可能的缩写形式以及相关领域的推测,可以将其分解并解释如下: #### 缩写的可能性分析 - **M**:可能是 "Multi" 或 "Model",表示多模型或多方面的概念。 - **P**:可能是 "Precision" 或 "Performance",代表精度或性能指标。 - **D**:可能是 "Detection" 或 "Distance",用于描述检测或距离计算的相关操作。 - **I**:可能是 "Intersection",这是 IoU(Intersection over Union)中的核心部分之一。 - **o**:即 “over”,作为 IoU 计算的一部分。 - **U**:即 "Union",同样来自 IoU。 因此,MPDIoU 可能是指一种扩展版的交并比(IoU),专门应用于多模型检测或多目标跟踪场景下的评估指标[^3]。 #### 技术应用场景 如果假设 MPDIoU 是一个多模型检测的改进型 IoU,则它可能适用于以下场景: 1. 多传感器融合环境下的对象检测和识别。 2. 自动驾驶技术中多个摄像头、雷达数据的综合处理。 3. 图像分割任务中不同区域重叠程度的精确测量。 具体实现上,可以通过调整传统 IoU 公式的权重参数来适应不同的输入源特性,从而提高整体系统的鲁棒性和准确性[^4]。 ```python def calculate_mpdiou(box_a, box_b, model_weights): """ Calculate Modified Precision Detection Intersection Over Union (MPDIoU). Args: box_a (list): Coordinates of bounding box A. box_b (list): Coordinates of bounding box B. model_weights (dict): Weights assigned to each detection model. Returns: float: The calculated MPDIoU value between two boxes considering weights. """ intersection_area = get_intersection_area(box_a, box_b) union_area = get_union_area(box_a, box_b) weighted_score = sum([model_weights[model]*score for model, score in zip(model_weights.keys(), [intersection_area/union_area])]) return weighted_score ``` 上述代码片段展示了一个简化版本的 MPDIoU 实现方式,其中引入了 `model_weights` 参数以反映不同模型贡献度的不同。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值