weka.attributeSelection.PrincipalComponents Java Examples

The following examples show how to use weka.attributeSelection.PrincipalComponents. 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: TransformEnsembles.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
private void init(Instances data){
	numInstances=data.numInstances();
	base=new kNN(1);	//Default Base classifier
	train=new ArrayList<Instances>();
	ps=new PowerSpectrum();
	acf=new ACF();
	acf.setMaxLag((int)(data.numAttributes()-data.numAttributes()*.1));
	pca=new PrincipalComponents (); 
	predictions=new ArrayList<double[][]>();

}
 
Example #2
Source File: BestConf.java    From bestconf with Apache License 2.0 5 votes vote down vote up
public static ArrayList<String> preprocessInstances(Instances retval){
	double[][] cMatrix;
	ArrayList<String> result = new ArrayList<String>();
	ArrayList<String> deleteAttNames = new ArrayList<String>();
	PrincipalComponents pc = new PrincipalComponents();
	HashMap<Integer, ArrayList<Integer>> filter = new HashMap<Integer, ArrayList<Integer>>();
	try {
		pc.buildEvaluator(retval);
		cMatrix = pc.getCorrelationMatrix();		
		for(int i = 0; i < cMatrix.length; i++){
			ArrayList<Integer> record = new ArrayList<Integer>();
			for(int j = i + 1; j < cMatrix.length; j++)
				if(cMatrix[i][j] >= correlationFactorThreshold || cMatrix[i][j] <= -correlationFactorThreshold){
					record.add(j);
				}
			if(record.size() != 0){
				filter.put(i, record);
			}
		}
		Iterator<Map.Entry<Integer, ArrayList<Integer>>> iter = filter.entrySet().iterator();
		while (iter.hasNext()) {
			Map.Entry<Integer, ArrayList<Integer>> entry = iter.next();
			ArrayList<Integer> arr = entry.getValue();
			for(int i = 0; i < arr.size(); i++)
				if(arr.get(i) != cMatrix.length - 1 && !deleteAttNames.contains(retval.attribute(arr.get(i)).name())){
					deleteAttNames.add(retval.attribute(arr.get(i)).name());
				}
			if(arr.contains(cMatrix.length-1)){
				result.add(retval.attribute(Integer.parseInt(entry.getKey().toString())).name());
			}
		}
		for(int i = 0; i < deleteAttNames.size(); i++){
			retval.deleteAttributeAt(retval.attribute(deleteAttNames.get(i)).index());
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return result;
}
 
Example #3
Source File: PCA.java    From AILibs with GNU Affero General Public License v3.0 4 votes vote down vote up
public PCA() {
	super(new Ranker(), new PrincipalComponents());
}