我正在开发一个群集程序,并且有一个双精度数据集,我需要对其进行规范化以确保每个双精度(变量)具有相同的影响力。
我想使用min-max规范化,其中确定每个变量的min和max值,但是我不确定如何在Java数据集中实现此功能。有没有人有什么建议?
该Encog项目wiki给出了一个实用工具类,做范围正常化。
构造函数采用输入和规范化数据的高值和低值。
/**
* Construct the normalization utility, allow the normalization range to be specified.
* @param dataHigh The high value for the input data.
* @param dataLow The low value for the input data.
* @param dataHigh The high value for the normalized data.
* @param dataLow The low value for the normalized data.
*/
public NormUtil(double dataHigh, double dataLow, double normalizedHigh, double normalizedLow) {
this.dataHigh = dataHigh;
this.dataLow = dataLow;
this.normalizedHigh = normalizedHigh;
this.normalizedLow = normalizedLow;
然后,您可以normalize
在样本上使用该方法。
/**
* Normalize x.
* @param x The value to be normalized.
* @return The result of the normalization.
*/
public double normalize(double x) {
return ((x - dataLow)
/ (dataHigh - dataLow))
* (normalizedHigh - normalizedLow) + normalizedLow;
}
要找到数据集的最小值和最大值,请使用以下问题的一个答案:使用Java在原始数组中查找最大值/最小值。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句