public static void buildEstimator(Estimator est, Instances instances, int attrIndex, int classIndex, int classValueIndex, boolean isIncremental) throws Exception { // DBO.pln("buildEstimator 2 " + classValueIndex); // non-incremental estimator add all instances at once if (!isIncremental) { if (classValueIndex == -1) { // DBO.pln("before addValues -- Estimator"); est.addValues(instances, attrIndex); } else { // DBO.pln("before addValues with classvalue -- Estimator"); est.addValues(instances, attrIndex, classIndex, classValueIndex); } } else { // incremental estimator, read one value at a time Enumeration<Instance> enumInsts = (instances).enumerateInstances(); while (enumInsts.hasMoreElements()) { Instance instance = enumInsts.nextElement(); ((IncrementalEstimator) est).addValue(instance.value(attrIndex), instance.weight()); } } }
/** * Initialize the estimator with a new dataset. Finds min and max first. * * @param data the dataset used to build this estimator * @param attrIndex attribute the estimator is for * @exception Exception if building of estimator goes wrong */ public void addValues(Instances data, int attrIndex) throws Exception { // can estimator handle the data? getCapabilities().testWithFail(data); double[] minMax = new double[2]; try { EstimatorUtils.getMinMax(data, attrIndex, minMax); } catch (Exception ex) { ex.printStackTrace(); System.out.println(ex.getMessage()); } double min = minMax[0]; double max = minMax[1]; // factor is 1.0, data set has not been reduced addValues(data, attrIndex, min, max, 1.0); }
public static void buildEstimator(Estimator est, Instances instances, int attrIndex, int classIndex, int classValueIndex, boolean isIncremental) throws Exception { // DBO.pln("buildEstimator 2 " + classValueIndex); // non-incremental estimator add all instances at once if (!isIncremental) { if (classValueIndex == -1) { // DBO.pln("before addValues -- Estimator"); est.addValues(instances, attrIndex); } else { // DBO.pln("before addValues with classvalue -- Estimator"); est.addValues(instances, attrIndex, classIndex, classValueIndex); } } else { // incremental estimator, read one value at a time Enumeration<Instance> enumInsts = (instances).enumerateInstances(); while (enumInsts.hasMoreElements()) { Instance instance = enumInsts.nextElement(); ((IncrementalEstimator) est).addValue(instance.value(attrIndex), instance.weight()); } } }
/** * Initialize the estimator with a new dataset. Finds min and max first. * * @param data the dataset used to build this estimator * @param attrIndex attribute the estimator is for * @exception Exception if building of estimator goes wrong */ public void addValues(Instances data, int attrIndex) throws Exception { // can estimator handle the data? getCapabilities().testWithFail(data); double[] minMax = new double[2]; try { EstimatorUtils.getMinMax(data, attrIndex, minMax); } catch (Exception ex) { ex.printStackTrace(); System.out.println(ex.getMessage()); } double min = minMax[0]; double max = minMax[1]; // factor is 1.0, data set has not been reduced addValues(data, attrIndex, min, max, 1.0); }
/** * Initialize the estimator using only the instance of one class. It is using * the values of one attribute only. * * @param data the dataset used to build this estimator * @param attrIndex attribute the estimator is for * @param classIndex index of the class attribute * @param classValue the class value * @param min minimal value of this attribute * @param max maximal value of this attribute * @exception Exception if building of estimator goes wrong */ public void addValues(Instances data, int attrIndex, int classIndex, int classValue, double min, double max) throws Exception { // extract the instances with the given class value Instances workData = new Instances(data, 0); double factor = getInstancesFromClass(data, attrIndex, classIndex, classValue, workData); // if no data return if (workData.numInstances() == 0) { return; } addValues(data, attrIndex, min, max, factor); }
/** * Initialize the estimator using only the instance of one class. It is using * the values of one attribute only. * * @param data the dataset used to build this estimator * @param attrIndex attribute the estimator is for * @param classIndex index of the class attribute * @param classValue the class value * @param min minimal value of this attribute * @param max maximal value of this attribute * @exception Exception if building of estimator goes wrong */ public void addValues(Instances data, int attrIndex, int classIndex, int classValue, double min, double max) throws Exception { // extract the instances with the given class value Instances workData = new Instances(data, 0); double factor = getInstancesFromClass(data, attrIndex, classIndex, classValue, workData); // if no data return if (workData.numInstances() == 0) { return; } addValues(data, attrIndex, min, max, factor); }
addValues(data, attrIndex, min, max, factor);
addValues(data, attrIndex, min, max, factor);
estimator.addValues(train, attrIndex, classType, classIndex); built = true;
estimator.addValues(train, attrIndex, classType, classIndex); built = true;
estimator.addValues(train, attrIndex); built = true;
estimator.addValues(train, attrIndex); built = true;
Instances trainCopy = new Instances(train); int attrIndex = 0; estimator.addValues(trainCopy, attrIndex); compareDatasets(train, trainCopy); built = true;
Instances trainCopy = new Instances(train); int attrIndex = 0; estimator.addValues(trainCopy, attrIndex); compareDatasets(train, trainCopy); built = true;
estimators[0].addValues(train, attrIndex); } catch (Exception ex) { throw new Error("Error setting up for tests: " + ex.getMessage());
estimators[0].addValues(train, attrIndex); } catch (Exception ex) { throw new Error("Error setting up for tests: " + ex.getMessage());