All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.ucm.fdi.gaia.jcolibri.method.maintenance.TwoStepCaseBaseEditMethod Maven / Gradle / Ivy

Go to download

jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.

There is a newer version: 3.2
Show newest version
package es.ucm.fdi.gaia.jcolibri.method.maintenance;


import java.util.Collection;

import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
import es.ucm.fdi.gaia.jcolibri.method.reuse.classification.KNNClassificationConfig;

/**
 * Provides the ability to run two case base editing algorithms consecutively on
 * a set of cases. This is useful to run, for example, noise elimintaion prior
 * to redundancy removal.
 * 
 * @author Lisa Cummins
 */
public class TwoStepCaseBaseEditMethod extends AbstractCaseBaseEditMethod {

	protected AbstractCaseBaseEditMethod method1;
	protected AbstractCaseBaseEditMethod method2;

	/**
	 * Sets up the edit method using the two provided methods.
	 * @param method1 The first method to run.
	 * @param method2 The second method to run.
	 */
	public TwoStepCaseBaseEditMethod(AbstractCaseBaseEditMethod method1,
			AbstractCaseBaseEditMethod method2) 
	{	this.method1 = method1;
		this.method2 = method2;
	}

	/**
	 * Runs alg1 followed by alg2 on the given cases and returns the cases
	 * deleted by the combined algorithms
	 * 
	 * @param cases
	 *            The group of cases on which to perform maintenance
	 * @param simConfig
	 *            The KNNConfig for these cases
	 * @return the list of cases deleted by the algorithm
	 */
	public Collection retrieveCasesToDelete(Collection cases, KNNClassificationConfig simConfig) {

		Collection deletedCases = method1.retrieveCasesToDelete(cases, simConfig);
		System.out.println(method1.getClass().getName()+" Done, Deleted: " + deletedCases.size());
		System.out.println();
		for(CBRCase c: deletedCases)
		    System.out.println(c.getID());
		cases.removeAll(deletedCases);

		deletedCases.addAll(method2.retrieveCasesToDelete(cases, simConfig));
		System.out.println(method2.getClass().getName()+" Done, Deleted: " + deletedCases.size());
		
		return deletedCases;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy