/** * Instantiates an empty kernel with the given dimensionality. * @param dimensions The number of dimensions of the points that can be in * this kernel. */ public CFCluster(Instance instance, int dimensions) { this(instance.toDoubleArray(), dimensions); }
/** * Instantiates an empty kernel with the given dimensionality. * @param dimensions The number of dimensions of the points that can be in * this kernel. */ public CFCluster(Instance instance, int dimensions) { this(instance.toDoubleArray(), dimensions); }
/** * Instantiates an empty kernel with the given dimensionality. * @param dimensions The number of dimensions of the points that can be in * this kernel. */ public CFCluster(Instance instance, int dimensions) { this(instance.toDoubleArray(), dimensions); }
public MicroCluster(Instance instance, int dimensions, long timestamp, double lambda, Timestamp currentTimestamp) { this(instance.toDoubleArray(), dimensions, timestamp, lambda, currentTimestamp); }
/** * Calculates Euclidian distance * @param inst1 point as double array * @param inst2 point as double array * @return euclidian distance */ private double distance(Instance inst1, Instance inst2){ return distance(inst1, inst2.toDoubleArray()); }
/** * Calculates Euclidian distance * @param inst1 point as double array * @param inst2 point as double array * @return euclidian distance */ private double distance(Instance inst1, Instance inst2){ return distance(inst1, inst2.toDoubleArray()); }
/** * Calculates Euclidian distance * @param inst1 point as double array * @param inst2 point as double array * @return euclidian distance */ private double distance(Instance inst1, Instance inst2){ return distance(inst1, inst2.toDoubleArray()); }
/** * Standard constructor for <code>DataObject</code>. * @param idCounter The id for the <code>DataObject</code>. * @param features The feature as a <code>double[]</code> * @param classLabel The label id for the <code>DataObject</code>. */ public DataObject(int idCounter, Instance inst){ this.id = idCounter; this.inst = inst; this.features = inst.toDoubleArray(); this.classLabel = (int)inst.classValue(); this.isOutiler = false; }
public double[] getDistanceVector(Instance instance){ return distanceVector(getCenter(), instance.toDoubleArray()); }
public static List<List<Double>> fileToMatrix(String path) { List<List<Double>> x = new ArrayList(); try { FileReader reader = new FileReader(path); ArffLoader arff = new ArffLoader(reader, 1, -1); Instance inst = arff.readInstance(); while (inst != null) { double[] dArray = inst.toDoubleArray(); List<Double> list = new ArrayList(); for (double d : dArray) { list.add(d); } x.add(list); inst = arff.readInstance(); } } catch (FileNotFoundException e) { System.out.println(e); } return x; }
public double[] getDistanceVector(Instance instance){ return distanceVector(getCenter(), instance.toDoubleArray()); }
public double[] getDistanceVector(Instance instance){ return distanceVector(getCenter(), instance.toDoubleArray()); }
@Override public double getInclusionProbability(Instance instance) { //trivial cluster if(N == 1){ double distance = 0.0; for (int i = 0; i < LS.length; i++) { double d = LS[i] - instance.value(i); distance += d * d; } distance = Math.sqrt(distance); if( distance < EPSILON ) return 1.0; return 0.0; } else{ double dist = calcNormalizedDistance(instance.toDoubleArray()); if(dist <= getRadius()){ return 1; } else{ return 0; } // double res = AuxiliaryFunctions.distanceProbabilty(dist, LS.length); // return res; } }
double dist = calcNormalizedDistance(instance.toDoubleArray()); if(dist <= getRadius()){ return 1;
double dist = calcNormalizedDistance(instance.toDoubleArray()); if(dist <= getRadius()){ return 1;
public SphereCluster(List<?extends Instance> instances, int dimension){ this(); if(instances == null || instances.size() <= 0) return; weight = instances.size(); Miniball mb = new Miniball(dimension); mb.clear(); for (Instance instance : instances) { mb.check_in(instance.toDoubleArray()); } mb.build(); center = mb.center(); radius = mb.radius(); mb.clear(); }
public Instance extendWithOldLabels(Instance instance) { if (this.header == null) { initHeader(instance.dataset()); this.baseLearner.setModelContext(new InstancesHeader(this.header)); } int numLabels = this.oldLabels.length; if (numLabels == 0) { return instance; } double[] x = instance.toDoubleArray(); double[] x2 = Arrays.copyOfRange(this.oldLabels, 0, numLabels + x.length); System.arraycopy(x, 0, x2, numLabels, x.length); Instance extendedInstance = new DenseInstance(instance.weight(), x2); extendedInstance.setDataset(this.header); //System.out.println( extendedInstance); return extendedInstance; }
public SphereCluster(List<?extends Instance> instances, int dimension){ this(); if(instances == null || instances.size() <= 0) return; weight = instances.size(); Miniball mb = new Miniball(dimension); mb.clear(); for (Instance instance : instances) { mb.check_in(instance.toDoubleArray()); } mb.build(); center = mb.center(); radius = mb.radius(); mb.clear(); }
public SphereCluster(List<?extends Instance> instances, int dimension){ this(); if(instances == null || instances.size() <= 0) return; weight = instances.size(); Miniball mb = new Miniball(dimension); mb.clear(); for (Instance instance : instances) { mb.check_in(instance.toDoubleArray()); } mb.build(); center = mb.center(); radius = mb.radius(); mb.clear(); }
@Override public void trainOnInstanceImpl(Instance instance) { timestamp++; //TODO check if instance contains label if(root == null){ numberDimensions = instance.numAttributes(); root = new Node(numberDimensions, 0); } else{ if(numberDimensions!=instance.numAttributes()) System.out.println("Wrong dimensionality, expected:"+numberDimensions+ "found:"+instance.numAttributes()); } ClusKernel newPointAsKernel = new ClusKernel(instance.toDoubleArray(), numberDimensions); insert(newPointAsKernel, new SimpleBudget(1000),timestamp); }