/** * Main method for testing this class * * @param argv should contain the command line arguments to the * evaluator/transformer (see AttributeSelection) */ public static void main(String[] argv) { runEvaluator(new PrincipalComponents(), argv); } }
/** * Initializes principal components and performs the analysis * * @param data the instances to analyse/transform * @throws Exception if analysis fails */ @Override public void buildEvaluator(Instances data) throws Exception { // can evaluator handle data? getCapabilities().testWithFail(data); buildAttributeConstructor(data); }
/** * Gets the current settings of PrincipalComponents * * @return an array of strings suitable for passing to setOptions() */ @Override public String[] getOptions() { Vector<String> options = new Vector<String>(); if (getCenterData()) { options.add("-C"); } options.add("-R"); options.add("" + getVarianceCovered()); options.add("-A"); options.add("" + getMaximumAttributeNames()); if (getTransformBackToOriginal()) { options.add("-O"); } return options.toArray(new String[0]); }
getCapabilities().testWithFail(m_trainInstances); fillCovariance(); m_sumOfEigenValues = Utils.sum(m_eigenvalues); m_transformedFormat = setOutputFormat(); if (m_transBackToOriginal) { m_originalSpaceFormat = setOutputFormatOriginal();
/** Creates a default PrincipalComponents */ public ASEvaluation getEvaluator() { return new PrincipalComponents(); }
/** * Gets the transformed training data. * * @return the transformed training data * @throws Exception if transformed data can't be returned */ @Override public Instances transformedData(Instances data) throws Exception { if (m_eigenvalues == null) { throw new Exception("Principal components hasn't been built yet"); } Instances output = null; if (m_transBackToOriginal) { output = new Instances(m_originalSpaceFormat); } else { output = new Instances(m_transformedFormat); } for (int i = 0; i < data.numInstances(); i++) { Instance converted = convertInstance(data.instance(i)); output.add(converted); } return output; }
return convertInstanceToOriginal(new SparseInstance(instance.weight(), newVals)); } else { return convertInstanceToOriginal(new DenseInstance(instance.weight(), newVals));
getCapabilities().testWithFail(m_trainInstances); fillCovariance(); m_sumOfEigenValues = Utils.sum(m_eigenvalues); m_transformedFormat = setOutputFormat(); if (m_transBackToOriginal) { m_originalSpaceFormat = setOutputFormatOriginal();
/** Creates a default PrincipalComponents */ public ASEvaluation getEvaluator() { return new PrincipalComponents(); }
/** * Gets the transformed training data. * * @return the transformed training data * @throws Exception if transformed data can't be returned */ @Override public Instances transformedData(Instances data) throws Exception { if (m_eigenvalues == null) { throw new Exception("Principal components hasn't been built yet"); } Instances output = null; if (m_transBackToOriginal) { output = new Instances(m_originalSpaceFormat); } else { output = new Instances(m_transformedFormat); } for (int i = 0; i < data.numInstances(); i++) { Instance converted = convertInstance(data.instance(i)); output.add(converted); } return output; }
return convertInstanceToOriginal(new SparseInstance(instance.weight(), newVals)); } else { return convertInstanceToOriginal(new DenseInstance(instance.weight(), newVals));
/** * Gets the current settings of PrincipalComponents * * @return an array of strings suitable for passing to setOptions() */ @Override public String[] getOptions() { Vector<String> options = new Vector<String>(); if (getCenterData()) { options.add("-C"); } options.add("-R"); options.add("" + getVarianceCovered()); options.add("-A"); options.add("" + getMaximumAttributeNames()); if (getTransformBackToOriginal()) { options.add("-O"); } return options.toArray(new String[0]); }
/** * Main method for testing this class * * @param argv should contain the command line arguments to the * evaluator/transformer (see AttributeSelection) */ public static void main(String[] argv) { runEvaluator(new PrincipalComponents(), argv); } }
public void testPrincipalComponent() { m_Filter = getFilter(new weka.attributeSelection.PrincipalComponents(), new weka.attributeSelection.Ranker()); Instances result = useFilter(); assertTrue(m_Instances.numAttributes() != result.numAttributes()); }
/** * Initializes principal components and performs the analysis * * @param data the instances to analyse/transform * @throws Exception if analysis fails */ @Override public void buildEvaluator(Instances data) throws Exception { // can evaluator handle data? getCapabilities().testWithFail(data); buildAttributeConstructor(data); }
public void testPrincipalComponent() { m_Filter = getFilter(new weka.attributeSelection.PrincipalComponents(), new weka.attributeSelection.Ranker()); Instances result = useFilter(); assertTrue(m_Instances.numAttributes() != result.numAttributes()); }