当前位置: 首页>>代码示例>>C#>>正文


C# Instances.attributeToDoubleArray方法代码示例

本文整理汇总了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);
        }
开发者ID:wushian,项目名称:MLEA,代码行数:94,代码来源:SimilarityAnalysis.cs


注:本文中的weka.core.Instances.attributeToDoubleArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。