Java Code Examples for weka.core.Utils#correlation()
The following examples show how to use
weka.core.Utils#correlation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrincipalComponents.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Fill the correlation matrix */ private void fillCorrelation() throws Exception { m_correlation = new double[m_numAttribs][m_numAttribs]; double [] att1 = new double [m_numInstances]; double [] att2 = new double [m_numInstances]; double corr; for (int i = 0; i < m_numAttribs; i++) { for (int j = 0; j < m_numAttribs; j++) { for (int k = 0; k < m_numInstances; k++) { att1[k] = m_trainInstances.instance(k).value(i); att2[k] = m_trainInstances.instance(k).value(j); } if (i == j) { m_correlation[i][j] = 1.0; // store the standard deviation m_stdDevs[i] = Math.sqrt(Utils.variance(att1)); } else { corr = Utils.correlation(att1,att2,m_numInstances); m_correlation[i][j] = corr; m_correlation[j][i] = corr; } } } // now standardize the input data m_standardizeFilter = new Standardize(); m_standardizeFilter.setInputFormat(m_trainInstances); m_trainInstances = Filter.useFilter(m_trainInstances, m_standardizeFilter); }
Example 2
Source File: PrincipalComponents.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Fill the correlation matrix. */ protected void fillCorrelation() throws Exception { int i; int j; int k; double[] att1; double[] att2; double corr; m_Correlation = new double[m_NumAttribs][m_NumAttribs]; att1 = new double [m_NumInstances]; att2 = new double [m_NumInstances]; for (i = 0; i < m_NumAttribs; i++) { for (j = 0; j < m_NumAttribs; j++) { for (k = 0; k < m_NumInstances; k++) { att1[k] = m_TrainInstances.instance(k).value(i); att2[k] = m_TrainInstances.instance(k).value(j); } if (i == j) { m_Correlation[i][j] = 1.0; } else { corr = Utils.correlation(att1,att2,m_NumInstances); m_Correlation[i][j] = corr; m_Correlation[j][i] = corr; } } } // now standardize the input data m_standardizeFilter = new Standardize(); m_standardizeFilter.setInputFormat(m_TrainInstances); m_TrainInstances = Filter.useFilter(m_TrainInstances, m_standardizeFilter); }