/** * Constructor of an instance that sets weight to one, all values to be * missing, and the reference to the dataset to null. (ie. the instance * doesn't have access to information about the attribute types) * * @param numAttributes the size of the instance */ // @ requires numAttributes > 0; // Or maybe == 0 is okay too? // @ ensures m_Dataset == null; public DenseInstance(int numAttributes) { m_AttValues = new double[numAttributes]; for (int i = 0; i < m_AttValues.length; i++) { m_AttValues[i] = Utils.missingValue(); } m_Weight = 1; m_Dataset = null; }
/** * Constructor of an instance that sets weight to one, all values to be * missing, and the reference to the dataset to null. (ie. the instance * doesn't have access to information about the attribute types) * * @param numAttributes the size of the instance */ public SparseInstance(int numAttributes) { m_AttValues = new double[numAttributes]; m_NumAttributes = numAttributes; m_Indices = new int[numAttributes]; for (int i = 0; i < m_AttValues.length; i++) { m_AttValues[i] = Utils.missingValue(); m_Indices[i] = i; } m_Weight = 1; m_Dataset = null; }
/** * Constructor of an instance that sets weight to one, all values to be * missing, and the reference to the dataset to null. (ie. the instance * doesn't have access to information about the attribute types) * * @param numAttributes the size of the instance */ // @ requires numAttributes > 0; // Or maybe == 0 is okay too? // @ ensures m_Dataset == null; public DenseInstance(int numAttributes) { m_AttValues = new double[numAttributes]; for (int i = 0; i < m_AttValues.length; i++) { m_AttValues[i] = Utils.missingValue(); } m_Weight = 1; m_Dataset = null; }
/** * Get the count for a given label * * @param label the label to get the count for * @return the count or missing value if the label is unknown */ public double getCount(String label) { NominalStats.Count c = m_counts.get(label); if (c == null) { return Utils.missingValue(); } return c.m_count; }
/** * Inserts an attribute at the given position (0 to numAttributes()) and sets * its value to be missing. * * @param position the attribute's position */ @Override protected void forceInsertAttributeAt(int position) { double[] newValues = new double[m_AttValues.length + 1]; System.arraycopy(m_AttValues, 0, newValues, 0, position); newValues[position] = Utils.missingValue(); System.arraycopy(m_AttValues, position, newValues, position + 1, m_AttValues.length - position); m_AttValues = newValues; }
/** * Inserts an attribute at the given position (0 to numAttributes()) and sets * its value to be missing. * * @param position the attribute's position */ @Override protected void forceInsertAttributeAt(int position) { double[] newValues = new double[m_AttValues.length + 1]; System.arraycopy(m_AttValues, 0, newValues, 0, position); newValues[position] = Utils.missingValue(); System.arraycopy(m_AttValues, position, newValues, position + 1, m_AttValues.length - position); m_AttValues = newValues; }
/** * Sets a specific value to be "missing". Performs a deep copy of the vector * of attribute values before the value is set to be missing. * * @param attIndex the attribute's index */ @Override public final void setMissing(int attIndex) { setValue(attIndex, Utils.missingValue()); }
/** * Sets a specific value to be "missing". Performs a deep copy of the vector * of attribute values before the value is set to be missing. * * @param attIndex the attribute's index */ @Override public final void setMissing(int attIndex) { setValue(attIndex, Utils.missingValue()); }
/** * Classifies a given instance. * * @param inst the instance to be classified * @return the classification */ public double classifyInstance(Instance inst) { int result = m_rules.resultRules(inst); if (result == -1) { return Utils.missingValue(); } else { return (double)result; } }
/** * Constructs a new NumericStats * * @param attributeName the name of the attribute that these statistics are * for */ public NumericStats(String attributeName) { super(attributeName); m_stats[ArffSummaryNumericMetric.MIN.ordinal()] = Utils.missingValue(); m_stats[ArffSummaryNumericMetric.MAX.ordinal()] = Utils.missingValue(); m_stats[ArffSummaryNumericMetric.FIRSTQUARTILE.ordinal()] = Utils.missingValue(); m_stats[ArffSummaryNumericMetric.MEDIAN.ordinal()] = Utils.missingValue(); m_stats[ArffSummaryNumericMetric.THIRDQUARTILE.ordinal()] = Utils.missingValue(); }
/** * Get the value of the attribute as a number or Utils.missingValue() if the * attribute is not numeric. * * @return the value of the attribute as a number */ public double getNumericValue() { if (getResolvedType().toLowerCase().startsWith("numeric")) { return Double.parseDouble(getResolvedValue()); } return Utils.missingValue(); // not a numeric attribute }
/** * Get the value of the attribute as a number or Utils.missingValue() if the * attribute is not numeric. * * @return the value of the attribute as a number */ public double getNumericValue() { if (getResolvedType().toLowerCase().startsWith("numeric")) { return Double.parseDouble(getResolvedValue()); } return Utils.missingValue(); // not a numeric attribute }
/** * Evaluate on the basis of the no true child strategy. * * @param classAtt the class attribute. * @param preds an array to hold the predicted probabilities. * @throws Exception if something goes wrong. */ protected void doNoTrueChild(Attribute classAtt, double[] preds) throws Exception { if (TreeModel.this.m_noTrueChildStrategy == NoTrueChildStrategy.RETURNNULLPREDICTION) { for (int i = 0; i < classAtt.numValues(); i++) { preds[i] = Utils.missingValue(); } } else { // return the predictions at this node doLeaf(classAtt, preds); } }
@Override public double evaluate() { if (isMissing()) { missingAccessed = true; return Utils.missingValue(); } return instance.value(getIndex()); } }
@Override public double evaluate() { if (isMissing()) { missingAccessed = true; return Utils.missingValue(); } return instance.value(getIndex()); } }
/** * Update with a new value * * @param value the string value to update with * @param weight the weight for the update */ public void update(String value, double weight) { if (DistributedJobConfig.isEmpty(value)) { m_missingCount += weight; m_stringLengthStats.update(Utils.missingValue(), weight, false, false); m_wordStats.update(Utils.missingValue(), weight, false, false); } else { m_stringLengthStats.update(value.length(), weight, false, false); m_tokenizer.tokenize(value); m_wordStats.update(m_tokenizer.countTokens(), weight, false, false); } }
/** * Returns the area under precision-recall curve (AUPRC) for those predictions * that have been collected in the evaluateClassifier(Classifier, Instances) * method. Returns Utils.missingValue() if the area is not available. * * @param classIndex the index of the class to consider as "positive" * @return the area under the precision-recall curve or not a number */ public double areaUnderPRC(int classIndex) { // Check if any predictions have been collected if (m_Predictions == null) { return Utils.missingValue(); } else { ThresholdCurve tc = new ThresholdCurve(); Instances result = tc.getCurve(m_Predictions, classIndex); return ThresholdCurve.getPRCArea(result); } }
@Override public double valueFromAttribute(Attribute att) { if (THIRDQUARTILE.ordinal() > att.numValues() - 1) { return Utils.missingValue(); } String value = att.value(THIRDQUARTILE.ordinal()); return toValue(value, toString()); }
@Override public double valueFromAttribute(Attribute att) { if (FIRSTQUARTILE.ordinal() > att.numValues() - 1) { return Utils.missingValue(); } String value = att.value(FIRSTQUARTILE.ordinal()); return toValue(value, toString()); }
@Override public double valueFromAttribute(Attribute att) { if (MEDIAN.ordinal() > att.numValues() - 1) { return Utils.missingValue(); } String value = att.value(MEDIAN.ordinal()); return toValue(value, toString()); }