如何决定权? [英] How to decide on weights?

查看:126
本文介绍了如何决定权?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的工作,我需要某种算法具有以下输入和输出:

For my work, I need some kind of algorithm with the following input and output:

输入:一组日期(过去)。输出:一组权重 - 每一给定的日期1重量(所有重量总和= 1)

Input: a set of dates (from the past). Output: a set of weights - one weight per one given date (the sum of all weights = 1).

的基本思想是,最接近的日期为当天的日期应接收的最高重量,第二个最接近的日期会得到一个第二最高权重,等等...

The basic idea is that the closest date to today's date should receive the highest weight, the second closest date will get the second highest weight, and so on...

任何想法?

在此先感谢!

推荐答案

首先,在你输入每个日期设置指定的日期和今天之间的时间量。

First, for each date in your input set assign the amount of time between the date and today.

例如:下面的日期定 {今天,明天,昨天,一个星期从今天} 变成 {0,1,1,7 } 。从形式上看: VAL [I] = ABS(今 - 日[I])

For example: the following date set {today, tomorrow, yesterday, a week from today} becomes {0, 1, 1, 7}. Formally: val[i] = abs(today - date[i]).

其次,逆以这样的方式它们的相对权重反转的值。这样做的最简单的方法是: VAL [i] = 1 / VAL [I]

Second, inverse the values in such a way that their relative weights are reversed. The simplest way of doing so would be: val[i] = 1/val[i].

其他建议:

  • VAL [i] = 1 / VAL [I] ^ 2
  • VAL [i] = 1 /开方(VAL [I])
  • VAL [i] = 1 /日志(VAL [I])
  • val[i] = 1/val[i]^2
  • val[i] = 1/sqrt(val[i])
  • val[i] = 1/log(val[i])

最难和最重要的部分就是决定如何逆值。想想,应该是什么权的性质是什么? (你希望两个遥远日期,或者两个遥远日期应该有pretty的平等权重之间的显着差异吗?你想这是非常接近今天有一个非常大的重量还是相当大重量的日期?)

The hardest and most important part is deciding how to inverse the values. Think, what should be the nature of the weights? (do you want noticeable differences between two far away dates, or maybe two far away dates should have pretty equal weights? Do you want a date which is very close to today have an extremely bigger weight or a reasonably bigger weight?).

请注意,你应该拿出一个反向的过程,你不能除以零。在上面的例子中,由 VAL [I] 导致分裂除以零。一种方法来避免除零称为平滑的。最平凡的方式来平滑你的数据是使用外接一个光滑,你只需要添加一个每个值(所以今天变成1,明天变成2,下周变为8等)。

Note that you should come up with an inverting procedure where you cannot divide by zero. In the example above, dividing by val[i] results in division by zero. One method to avoid division by zero is called smoothing. The most trivial way to "smooth" your data is using the add-one smoothing where you just add one to each value (so today becomes 1, tomorrow becomes 2, next week becomes 8, etc).

现在最容易的部分是标准化的价值观,这样他们就会总结为一。

Now the easiest part is to normalize the values so that they'll sum up to one.

sum = val[1] + val[2] + ... + val[n]
weight[i] = val[i]/sum for each i

这篇关于如何决定权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆