本文整理汇总了C#中weka.core.Instances.attributeToDoubleArray方法的典型用法代码示例。如果您正苦于以下问题:C# Instances.attributeToDoubleArray方法的具体用法?C# Instances.attributeToDoubleArray怎么用?C# Instances.attributeToDoubleArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.Instances
的用法示例。
在下文中一共展示了Instances.attributeToDoubleArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: analyze
// ---- OPERATIONS ----
///
/// <summary> * Analyze the time series data. The similarity matrices are created
/// * and filled with euclidean distances based on the tolerance values
/// * for similarity.
/// * </summary>
/// * <param name="data"> data to be analyzed </param>
public override void analyze(Instances data)
{
data.setClassIndex(data.numAttributes() - 1);
m_data = data;
m_rangeTemplates.setUpper(data.numAttributes());
//Date startFT = new Date();
// compute fourier transform
FourierTransform dftFilter = new FourierTransform();
dftFilter.setInputFormat(data);
dftFilter.setNumCoeffs(getNumCoeffs());
dftFilter.setUseFFT(getUseFFT());
Instances fourierdata = Filter.useFilter(data, dftFilter);
Date endFT = new Date();
// time taken for FT
//m_DFTTime = new Date(endFT.getTime() - startFT.getTime());
int numdim = data.numAttributes();
//ORIGINAL LINE: m_distancesFreq = new double[numdim][numdim];
//JAVA TO VB & C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
m_distancesFreq = RectangularArrays.ReturnRectangularDoubleArray(numdim, numdim);
//ORIGINAL LINE: m_distancesTime = new double[numdim][numdim];
//JAVA TO VB & C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
m_distancesTime = RectangularArrays.ReturnRectangularDoubleArray(numdim, numdim);
//long ftDistTime = 0;
//long tDistTime = 0;
// compute similarity matrices
for (int i = 0; i < data.numAttributes(); ++i)
{
for (int j = 0; j < i; j++)
{
// not for template sequences
if (m_rangeTemplates.isInRange(i) && m_rangeTemplates.isInRange(j))
{
continue;
}
//Date startFTDist = new Date();
// Compute the Euclidean distance between 2 dims using FT
double[] reCT = fourierdata.attributeToDoubleArray(2 * i);
double[] imCT = fourierdata.attributeToDoubleArray(2 * i + 1);
double[] reCS = fourierdata.attributeToDoubleArray(2 * j);
double[] imCS = fourierdata.attributeToDoubleArray(2 * j + 1);
m_distancesFreq[i][j] = computeEuclidean(reCT, imCT, reCS, imCS);
// if found similar using FT
if (m_distancesFreq[i][j] <= m_epsilon)
{
// then compute normal Euclidean distances between the 2 dims
double[] x = data.attributeToDoubleArray(i);
double[] y = data.attributeToDoubleArray(j);
m_distancesTime[i][j] = computeEuclidean(x, y);
}
//Date endFTDist = new Date();
// time taken for computing similarity based on FT
//ftDistTime += (endFTDist.getTime() - startFTDist.getTime());
// Date startDist = new Date();
//// compute similarity matrices (brute force)
// double[] x1 = data.attributeToDoubleArray(i);
// double[] y1 = data.attributeToDoubleArray(j);
// computeEuclidean(x1, y1);
// Date endDist = new Date();
//// time taken for computing similarity based brute force method
// tDistTime += (endDist.getTime() - startDist.getTime());
}
}
//m_FTEuclideanTime = new Date(ftDistTime);
//m_EuclideanTime = new Date(tDistTime);
}