归一化 均值归一化_归一化折现累积收益

归一化 均值归一化

Do you remember the awkward moment when someone you had a good conversation with forgets your name? In this day and age we have a new standard, an expectation. And when the expectation is not met the feeling is not far off being asked “where do I know you from again?” by some the lady/guy you spent the whole evening with at the pub last week, awkward! — well I don’t actually go to the pub but you get my gist. We are in the era of personalization and personalized content is popping up everywhere — Netflix, Youtube, Amazon, etc. The user demands personalized content, and businesses seek to meet the demands of the users.

你还记得尴尬的时刻,当有人你与你忘记一个名字很好的交谈? 在这个时代,我们有了新的标准,一种期望。 当没有达到期望时,很快就会被问到“我又从哪里认识你?” 上周您在酒吧里和整个晚上在一起的女士/男士中,有些尴尬! -嗯,我实际上并不去酒吧,但您明白了我的要旨。 我们正处于个性化时代,个性化内容随处可见-Netflix,Youtube,Amazon等。用户需要个性化内容,而企业则在努力满足用户的需求。

In the recent years, many businesses have been employing Machine Learning to develop effective recommender systems to assist in personalizing the users experience. As with all things in life, this feat comes with its challenges. Evaluating the impact of a recommender engine is a major challenge in the development stages, or enhancement stages of a recommender engine. Although we may be sure of the positive impact caused by a recommender system, there’s a much required need to quantify this impact in order to effectively communicate to stakeholders or for when we want to enhance our system in the future.

近年来,许多企业一直在使用机器学习来开发有效的推荐系统,以帮助个性化用户体验。 与生活中的所有事物一样,这一壮举也伴随着挑战。 在推荐引擎的开发阶段或增强阶段,评估推荐引擎的影响是一项重大挑战。 尽管我们可以肯定推荐系统会带来的积极影响,但是仍然需要量化这种影响,以便有效地与利益相关者进行交流,或者在将来我们希望增强我们的系统时。

After a long-winded introduction, I hereby present to you… Normalized Discounted Cumulative Gain (NDCG).

在经过漫长的介绍之后,我在此向您介绍…… 归一化累积折扣收益 (NDCG)。

A measure of ranking quality that is often used to measure effectiveness of web search engine algorithms or related applications.

排名质量的度量标准,通常用于度量Web搜索引擎算法或相关应用程序的有效性。

If we are to understand the NDCG metric accordingly we must first understand CG (Cumulative Gain) and DCG (Discounted Cumulative Gain), as well as understanding the two assumptions that we make when we use DCG and its related measures:

如果要相应地理解NDCG度量标准,则必须首先了解CG(累积增益)和DCG(折让累积增益),以及理解我们在使用DCG及其相关度量时做出的两个假设:

  1. Highly relevant documents are more useful when appearing earlier in the search engine results list.

    如果相关性较高的文档出现在搜索引擎结果列表的前面,则将更为有用。
  2. Highly relevant documents are more useful than marginally relevant documents, which are more useful than non-relevant documents

    高度相关的文档比边缘相关的文档更有用,后者比不相关的文档更有用

(Source: Wikipedia)

(来源:维基百科)

累积增益(CG) (Cumulative Gain (CG))

If every recommendation has a graded relevance score associated with it, CG is the sum of graded relevance values of all results in a search result list — see Figure 1 for how we can express this mathematically.

如果每个建议都具有与之相关的分级的相关性得分,则CG是搜索结果列表中所有结果的分级的相关性值的总和-有关如何数学表达的信息,请参见图1。

Image for post
Figure 1: Cumulative Gain mathematical expression
图1:累积增益数学表达式

The Cumulative Gain at a particular rank position p, where the rel_i is the graded relevance of the result at position i. To demonstrate this in Python we must first let the variable setA be the graded relevance scores of a response to a search query, thereby each graded relevance score is associated with a document.

在特定等级位置p处的累积增益,其中rel_i是位置i处结果的分级相关性。 为了在Python中证明这一点,我们必须首先让变量setA为搜索查询响应的分级相关性得分,从而使每个分级相关性得分与文档相关联。

setA = [3, 1, 2, 3, 2, 0]
print(sum(setA))11

The problem with CG is that it does not take into consideration the rank of the result set when determining the usefulness of a result set. In other words, if we was to reorder the graded relevance scores returned in setA we will not get a better insight into the usefulness of the result set since the CG will be unchanged. See the code cell below for an example.

CG的问题在于,在确定结果集的有用性时,它没有考虑结果集的等级。 换句话说,如果我们要对在setA返回的分级相关性分数进行重新排序,则由于CG不变,因此我们将无法更好地了解结果集的用途。 有关示例,请参见下面的代码单元。

setB = sorted(setA, reverse=True)
print(f"setA: {setA}\tCG setA: {cg_a}\nsetB: {setB}\tCG setB: {sum(setB)}")setA: [3, 1, 2, 3, 2, 0] CG setA: 11
setB: [3, 3, 2, 2, 1, 0] CG setB: 11

setB is clearly returning a much more useful set than setA, but the CG measure says that they are returning equally as good results.

显然setB返回的集合比setA有用得多,但是CG度量表明它们返回的结果相同。

折让累计收益 (Discounted Cumulative Gain)

To overcome this we introduce DCG. DCG penalizes highly relevant documents that appear lower in the search by reducing the graded relevance value logarithimically proportional to the position of the result — see Figure 2.

为了克服这个问题,我们引入了DCG。 DCG通过降低与结果位置成对数比例的相关度等级值,对在搜索中显示较低的高度相关的文档进行惩罚-见图2。

Image for post
Figure 2: Discounted Cumulative Gain mathematical expression
图2:折扣累积增益数学表达式

Below we have created a function called discountedCumulativeGain to calculate DCG for setA and setB. If this is an effective measurement, setB should have a higher DCG than setA since its results are more useful.

下面我们创建了一个名为函数discountedCumulativeGain计算DCG为setAsetB 。 如果这是一种有效的测量方法,则setB DCG应当比setA因为其结果更有用。

import numpy as np 
def discountedCumulativeGain(result):
dcg = []
for idx, val in enumerate(result):
numerator = 2**val - 1
# add 2 because python 0-index
denominator = np.log2(idx + 2)
score = numerator/denominator
dcg.append(score)
return sum(dcg)print(f"DCG setA: {discountedCumulativeGain(setA)}\nDCG setB: {discountedCumulativeGain(setB)}")DCG setA: 13.306224081788834
DCG setB: 14.595390756454924

The DCG of setB is higher than setA which aligns with our intuition that setB returned more useful results than setA.

setB的DCG高于setA ,这符合我们的直觉,即setB返回的结果比setA更有用。

归一化折现累积收益 (Normalized Discounted Cumulative Gain)

An issue arises with DCG when we want to compare the search engines performance from one query to the next because search results list can vary in length depending on the query that has been provided. Hence, by normalizing the cumulative gain at each position for a chosen value of p across queries we arrive at NDCG. We perform this by sorting all the relevant documents in the corpus by their relative relevance producing the max possible DCG through position p (a.k.a Ideal Discounted Cumulative Gain) - see Figure 3.

当我们要比较一个查询与下一个查询的搜索引擎性能时,DCG会出现问题,因为搜索结果列表的长度可能会有所不同,具体取决于所提供的查询。 因此,通过将查询中p的选定值的每个位置处的累积增益标准化,我们得出NDCG。 我们通过将语料库中的所有相关文档按照它们的相对相关性进行排序来执行此操作,从而通过位置p (又称理想折现累积增益)产生最大可能的DCG-见图3。

Image for post
Figure 3: Normalized Discounted Cumulative Gain Mathematical expression; REL_p represents the list of relevant documents (ordered by their relevance) in the corpus up to position p.
图3:归一化的折合累积增益数学表达式; REL_p代表语料库中直至位置p的相关文档列表(按其相关性排序)。

To perform this metric in python we created the function normalizedDiscountedCumulativeGain to assist with this functionality.

为了在python中执行此指标,我们创建了功能normalizedDiscountedCumulativeGain来辅助此功能。

def normalizedDiscountedCumulativeGain(result, sorted_result): 
dcg = discountedCumulativeGain(result)
idcg = discountedCumulativeGain(sorted_result)
ndcg = dcg / idcg
return ndcgprint(f"DCG setA: {normalizedDiscountedCumulativeGain(setA, setB)}\nDCG setB: {normalizedDiscountedCumulativeGain(setB, setB)}")DCG setA: 0.9116730277265138
DCG setB: 1.0

The ratios will always be in the range of [0, 1] with 1 being a perfect score — meaning that the DCG is the same as the IDCG. Therefore, the NDCG values can be averaged for all queries to obtain a measure of the average performance of a recommender systems ranking algorithm.

比率将始终在[0,1]范围内,其中1为完美分数-意味着DCG与IDCG相同。 因此,可以对所有查询的NDCG值取平均值,以获得对推荐系统排名算法的平均性能的度量。

NDCG的局限性 (Limitations of NDCG)

(source: Wikipedia)

(来源:维基百科)

  1. The NDCG does not penalize for bad documents in the results

    NDCG不会对结果中的不良文件进行处罚
  2. Does not penalize missing documents in the results

    不惩罚结果中缺少的文件
  3. May not be suitable to measure performance of queiries that may often have several equally good results

    可能不适合测量可能经常具有几个同样好的结果的查询的性能

结语 (Wrap Up)

The main difficulty that we face when using NDCG is that often times we don’t know the ideal ordering of results when only partial relevance feedback is available. However, the NDCG has proven to be an effect metric to evaluate ranking quality for various problems, for example the Personalized Web Search Challenge, AirBnB New User Booking Challenge, and Personalize Expedia Hotel Searches — ICDM 2013 to name a few.

使用NDCG时,我们面临的主要困难是,当只有部分相关性反馈可用时,我们常常不知道结果的理想排序。 但是,事实证明,NDCG是评估各种问题排名质量的一种效果指标,例如个性化Web搜索挑战赛 , AirBnB新用户预订挑战赛和个性化Expedia酒店搜索-ICDM 2013等 。

Thank you for reading to the end of this post. If you’d like to get in contact with me, I am most accessible on LinkedIn.

感谢您阅读这篇文章的结尾。 如果您想与我联系,可以在LinkedIn上访问我。

翻译自: https://towardsdatascience.com/normalized-discounted-cumulative-gain-37e6f75090e9

归一化 均值归一化

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388948.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

sqlserver垮库查询_Oracle和SQLServer中实现跨库查询

一、在SQLServer中连接另一个SQLServer库数据在SQL中,要想在本地库中查询另一个数据库中的数据表时,可以创建一个链接服务器:EXEC master.dbo.sp_addlinkedserver server N别名, srvproductN库名,providerNSQLOLEDB, datasrcN服务器地址EXEC…

机器学习实践三---神经网络学习

Neural Networks 在这个练习中,将实现神经网络BP算法,练习的内容是手写数字识别。Visualizing the data 这次数据还是5000个样本,每个样本是一张20*20的灰度图片fig, ax_array plt.subplots(nrows10, ncols10, figsize(6, 4))for row in range(10):fo…

机器学习实践四--正则化线性回归 和 偏差vs方差

这次实践的前半部分是,用水库水位的变化,来预测大坝的出水量。 给数据集拟合一条直线,可能得到一个逻辑回归拟合,但它并不能很好地拟合数据,这是高偏差(high bias)的情况,也称为“欠…

深度学习 推理 训练_使用关系推理的自我监督学习进行训练而无需标记数据

深度学习 推理 训练背景与挑战📋 (Background and challenges 📋) In a modern deep learning algorithm, the dependence on manual annotation of unlabeled data is one of the major limitations. To train a good model, usually, we have to prepa…

CentOS 7 使用 ACL 设置文件权限

Linux 系统标准的 ugo/rwx 集合并不允许为不同的用户配置不同的权限,所以 ACL 便被引入了进来,为的是为文件和目录定义更加详细的访问权限,而不仅仅是这些特别指定的特定权限。 ACL 可以为每个用户,每个组或不在文件所属组中的用…

机器学习实践五---支持向量机(SVM)

之前已经学到了很多监督学习算法, 今天的监督学习算法是支持向量机,与逻辑回归和神经网络算法相比,它在学习复杂的非线性方程时提供了一种更为清晰,更强大的方式。 Support Vector Machines SVM hypothesis Example Dataset 1…

服务器安装mysql_阿里云服务器上安装MySQL

关闭防火墙和selinuxCentOS7以下:service iptables stopsetenforce 0CentOS7.xsystemctl stop firewalldsystemctl disable firewalldsystemctl status firewalldvi /etc/selinux/config把SELINUXenforcing 改成 SELINUXdisabled一、安装依赖库yum -y install make …

在PyTorch中转换数据

In continuation of my previous post ,we will keep on deep diving into basic fundamentals of PyTorch. In this post we will discuss about ways to transform data in PyTorch.延续我以前的 发布后 ,我们将继续深入研究PyTorch的基本原理。 在这篇文章中&a…

机器学习实践六---K-means聚类算法 和 主成分分析(PCA)

在这次练习中将实现K-means 聚类算法并应用它压缩图片,第二部分,将使用主成分分析算法去找到一个脸部图片的低维描述。 K-means Clustering Implementing K-means K-means算法是一种自动将相似的数据样本聚在一起的方法,K-means背后的直观是一个迭代过…

打包 压缩 命令tar zip

2019独角兽企业重金招聘Python工程师标准>>> 打包 压缩 命令tar zip tar语法 #压缩 tar -czvf ***.tar.gz tar -cjvf ***.tar.bz2 #解压缩 tar -xzvf ***.tar.gz tar -xjvf ***.tar.bz2 tar [主选项辅选项] 文件或目录 主选项是必须要有的,它告诉tar要做…

mysql免安装5.7.17_mysql免安装5.7.17数据库配置

首先要有 mysql-5.7.10-winx64环境: mysql-5.7.10-winx64 win10(64位)配置环境变量:1、把mysql-5.7.10-winx64放到D盘,进入D\mysql-5.7.10-winx64\bin目录,复制路径,配置环境变量,在path后面添加D\mysql-5.7.10-winx6…

tidb数据库_异构数据库复制到TiDB

tidb数据库This article is based on a talk given by Tianshuang Qin at TiDB DevCon 2020.本文基于Tianshuang Qin在 TiDB DevCon 2020 上的演讲 。 When we convert from a standalone system to a distributed one, one of the challenges is migrating the database. We’…

机器学习实践七----异常检测和推荐系统

Anomaly detection 异常检测是机器学习中比较常见的应用,它主要用于非监督学习问题,从某些角度看, 它又类似于一些监督学习问题。 什么是异常检测?来看几个例子: 例1. 假设是飞机引擎制造商, 要对引擎进行…

CODE[VS] 1621 混合牛奶 USACO

题目描述 Description牛奶包装是一个如此低利润的生意,所以尽可能低的控制初级产品(牛奶)的价格变的十分重要.请帮助快乐的牛奶制造者(Merry Milk Makers)以可能的最廉价的方式取得他们所需的牛奶.快乐的牛奶制造公司从一些农民那购买牛奶,每个农民卖给牛奶制造公司的价格不一定…

刚认识女孩说不要浪费时间_不要浪费时间寻找学习数据科学的最佳方法

刚认识女孩说不要浪费时间重点 (Top highlight)Data science train is moving, at a constantly accelerating speed, and increasing its length by adding up new coaches. Businesses want to be on the data science train to keep up with the ever-evolving technology a…

测试工具之badboy

badboy这个工具本身用处不是很大,但有个录制脚本的功能,还是jmeter脚本,所以针对这一点很多懒人就可以通过这个录制脚本,而不需要自己去编写 badboy工具最近还是2016年更新的,后面也没在更新了,官方下载地址…

hive 集成sentry

2019独角兽企业重金招聘Python工程师标准>>> 环境 apache-hive-2.3.3-bin apache-sentry-2.1.0-bin 1 2 sentry是目前最新的版本,支持hive的最高版本为2.3.3,hive版本如果高于2.3.3,会出一些版本兼容问题[亲测] hive快速安装 wget…

isql 测试mysql连接_[libco] 协程库学习,测试连接 mysql

历史原因,一直使用 libev 作为服务底层;异步框架虽然性能比较高,但新人学习和使用门槛非常高,而且串行的逻辑被打散为状态机,这也会严重影响生产效率。用同步方式实现异步功能,既保证了异步性能优势&#x…

什么是数据仓库,何时以及为什么要考虑一个

The term “Data Warehouse” is widely used in the data analytics world, however, it’s quite common for people who are new with data analytics to ask the above question.术语“数据仓库”在数据分析领域中被广泛使用,但是,对于数据分析新手来…

探索性数据分析入门_入门指南:R中的探索性数据分析

探索性数据分析入门When I started on my journey to learn data science, I read through multiple articles that stressed the importance of understanding your data. It didn’t make sense to me. I was naive enough to think that we are handed over data which we p…