// Path: ensemble-clustering/src/main/java/com/oculusinfo/ml/feature/Feature.java
// public abstract class Feature implements Serializable {
//     private static final long serialVersionUID = 192274668774344842L;
//     
//     // the unique name of the feature
//     protected String          name;
//    
//     // The weight of this feature
//     private double            weight;
// 
// 	public Feature() {
// 		// empty constructor
// 	    this.weight = 1.0;
// 	}
// 
// 	public Feature(String name) {
// 		this.name = name;
//         this.weight = 1.0;
// 	}
// 
// 	public double getWeight () {
// 	    return weight;
// 	}
// 
// 	public void setWeight (double weight) {
// 	    this.weight = weight;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 	
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	
// 	@JsonIgnore
// 	public String getId() {
// 		return name;
// 	}
// 	
// 	@Override
// 	public int hashCode() {
// 		return name.hashCode();
// 	}
// }
// 
// Path: ensemble-clustering/src/main/java/com/oculusinfo/ml/feature/numeric/NumericVectorFeature.java
// public class NumericVectorFeature extends Feature {
// 	private static final long serialVersionUID = 4845380498652903996L;
// 	private double[] vector;
// 	
// 	private String vectorToString() {
// 		StringBuilder str = new StringBuilder();
// 		str.append("[");
// 		for (int i=0; i < vector.length; i++) {
// 			str.append(vector[i]);
// 			if (i < vector.length - 1) str.append(";");
// 		}
// 		str.append("]");
// 		return str.toString();
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return (this.getName() + ":" + vectorToString());
// 	}
// 	
// 	public NumericVectorFeature() {
// 		super();
// 	}
// 	
// 	public NumericVectorFeature(String name) {
// 		super(name);
// 	}
// 
// 	public void setValue(double[] vector) {
// 		this.vector = vector;
// 	}
// 	
// 	public void setValue(List<Double> vector) {
// 		setValue(new ArrayList<Double>(vector));
// 	}
// 	
// 	public double[] getValue() {
// 		return this.vector;
// 	}
// }


import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import com.oculusinfo.ml.feature.Feature;
import com.oculusinfo.ml.feature.numeric.NumericVectorFeature;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;

		return map.get(id);
	}
	
	/***
	 * Return the number of Instances in the DataSet
	 * @return
	 */
	public int size() {
		return map.size();
	}
	
	/***
	 * Return a DataSet with random fraction number of Instances as this DataSet
	 * @param fraction fraction of Instances to return in the range of 0 and 1
	 * @return resulting sample DataSet
	 */
	public DataSet sample(double fraction) {
		DataSet sample = new DataSet();
		
		// max fraction is 1
		if (fraction > 1) fraction = 1;
		
		// no samples are requested - return an empty data set
		if (fraction <= 0) return sample;
		
		long numToSample = Math.round( map.size() * fraction );
		
		ArrayList<String> keys = new ArrayList<String>(map.keySet());
		
		// randomly pick k instances as the initial k means

// Path: ensemble-clustering/src/main/java/com/oculusinfo/ml/feature/Feature.java
// public abstract class Feature implements Serializable {
//     private static final long serialVersionUID = 192274668774344842L;
//     
//     // the unique name of the feature
//     protected String          name;
//    
//     // The weight of this feature
//     private double            weight;
// 
// 	public Feature() {
// 		// empty constructor
// 	    this.weight = 1.0;
// 	}
// 
// 	public Feature(String name) {
// 		this.name = name;
//         this.weight = 1.0;
// 	}
// 
// 	public double getWeight () {
// 	    return weight;
// 	}
// 
// 	public void setWeight (double weight) {
// 	    this.weight = weight;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 	
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	
// 	@JsonIgnore
// 	public String getId() {
// 		return name;
// 	}
// 	
// 	@Override
// 	public int hashCode() {
// 		return name.hashCode();
// 	}
// }
// 
// Path: ensemble-clustering/src/main/java/com/oculusinfo/ml/feature/numeric/NumericVectorFeature.java
// public class NumericVectorFeature extends Feature {
// 	private static final long serialVersionUID = 4845380498652903996L;
// 	private double[] vector;
// 	
// 	private String vectorToString() {
// 		StringBuilder str = new StringBuilder();
// 		str.append("[");
// 		for (int i=0; i < vector.length; i++) {
// 			str.append(vector[i]);
// 			if (i < vector.length - 1) str.append(";");
// 		}
// 		str.append("]");
// 		return str.toString();
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return (this.getName() + ":" + vectorToString());
// 	}
// 	
// 	public NumericVectorFeature() {
// 		super();
// 	}
// 	
// 	public NumericVectorFeature(String name) {
// 		super(name);
// 	}
// 
// 	public void setValue(double[] vector) {
// 		this.vector = vector;
// 	}
// 	
// 	public void setValue(List<Double> vector) {
// 		setValue(new ArrayList<Double>(vector));
// 	}
// 	
// 	public double[] getValue() {
// 		return this.vector;
// 	}
// }


// Path: ensemble-clustering/src/main/java/com/oculusinfo/ml/DataSet.java
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import com.oculusinfo.ml.feature.Feature;
import com.oculusinfo.ml.feature.numeric.NumericVectorFeature;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;

		return map.get(id);
	}
	
	/***
	 * Return the number of Instances in the DataSet
	 * @return
	 */
	public int size() {
		return map.size();
	}
	
	/***
	 * Return a DataSet with random fraction number of Instances as this DataSet
	 * @param fraction fraction of Instances to return in the range of 0 and 1
	 * @return resulting sample DataSet
	 */
	public DataSet sample(double fraction) {
		DataSet sample = new DataSet();
		
		// max fraction is 1
		if (fraction > 1) fraction = 1;
		
		// no samples are requested - return an empty data set
		if (fraction <= 0) return sample;
		
		long numToSample = Math.round( map.size() * fraction );
		
		ArrayList<String> keys = new ArrayList<String>(map.keySet());
		
		// randomly pick k instances as the initial k means

		ArrayList<String> indexes = new ArrayList<String>(keys.size()); 
