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

weka.clusterers.ClassSpecificClustererClassCombined Maven / Gradle / Ivy

The newest version!
/**
 * 
 */
package weka.clusterers;

import java.util.Arrays;

import weka.core.Instance;
import weka.core.Utils;

/**
 * A class for clusterers that make separate clustering for each available class. 
 * Then the final cluster is composed using nearest class-specific clusters.
 * @author pawel trajdos
 * @since 0.0.1
 * @version 0.0.1
 *
 */
public class ClassSpecificClustererClassCombined extends ClassSpecificClusterer {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3221556640429200690L;

	/**
	 * 
	 */
	public ClassSpecificClustererClassCombined() {
		super();
	}
	@Override
	public double[] distributionForInstance(Instance instance) throws Exception {
		
		if(this.noClass)
			return this.m_Clusterer.distributionForInstance(instance);

		if(this.classesOnly | this.noInstances){
			double[] result = new double[this.numberOfClasses];
			Arrays.fill(result, 0, result.length-1, 1);
			Utils.normalize(result);
			return result;
		}
		
		double[] distribution = new double[this.numberOfClusters];
		
		this.removeFilter.input(instance);
		Instance filteredInstance = this.removeFilter.output();
		this.removeFilter.batchFinished();
		
		int[] maxRespIndices = new int[this.clusterers.length];
		double[] tmpResponse;
		for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy