當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。