/** * Return true if the outputtype is set * * @param num value that is reserved for a specific outputtype * @return return true if the output type is set */ public boolean outputTypeSet(int num) { return (m_outputTypes.isInRange(num)); }
/** * Returns true if attribute is boolean * * @param index of the attribute * @return true if the attribute is boolean */ public boolean isBoolean(int index) { return m_booleanCols.isInRange(index); }
/** * Returns true if attribute is nominal * * @param index of the attribute * @return true if the attribute is nominal */ public boolean isNominal(int index) { return m_nominalCols.isInRange(index); }
/** * Return true if the outputtype is set * * @param num value that is reserved for a specific outputtype * @return return true if the output type is set */ public boolean outputTypeSet(int num) { return (m_outputTypes.isInRange(num)); }
/** * Returns true if attribute is boolean * * @param index of the attribute * @return true if the attribute is boolean */ public boolean isBoolean(int index) { return m_booleanCols.isInRange(index); }
/** * Returns true if attribute is nominal * * @param index of the attribute * @return true if the attribute is nominal */ public boolean isNominal(int index) { return m_nominalCols.isInRange(index); }
/** * check if attribute types are not contradicting * * @return empty string if no problem, otherwise error message */ protected String checkIndices() { for (int i = 0; i < getNumAttributes(); i++) { if (m_booleanCols.isInRange(i) && m_nominalCols.isInRange(i)) { return "Error in attribute type: Attribute " + i + " is set boolean and nominal."; } } return ""; } }
/** * check if attribute types are not contradicting * * @return empty string if no problem, otherwise error message */ protected String checkIndices() { for (int i = 0; i < getNumAttributes(); i++) { if (m_booleanCols.isInRange(i) && m_nominalCols.isInRange(i)) { return "Error in attribute type: Attribute " + i + " is set boolean and nominal."; } } return ""; } }
/** * Builds a string listing the attribute values in a specified range of indices, * separated by commas and enclosed in brackets. * * @param instance the instance to print the values from * @return a string listing values of the attributes in the range */ protected String attributeValuesString(Instance instance) { StringBuffer text = new StringBuffer(); if (m_Attributes != null) { boolean firstOutput = true; m_Attributes.setUpper(instance.numAttributes() - 1); for (int i=0; i<instance.numAttributes(); i++) if (m_Attributes.isInRange(i) && i != instance.classIndex()) { if (firstOutput) text.append("("); else text.append(","); text.append(instance.toString(i)); firstOutput = false; } if (!firstOutput) text.append(")"); } return text.toString(); }
/** * initializes the attribute indices. */ protected void initializeAttributeIndices() { m_AttributeIndices.setUpper(m_Data.numAttributes() - 1); m_ActiveIndices = new boolean[m_Data.numAttributes()]; for (int i = 0; i < m_ActiveIndices.length; i++) { m_ActiveIndices[i] = m_AttributeIndices.isInRange(i); } }
/** * initializes the attribute indices. */ protected void initializeAttributeIndices() { m_AttributeIndices.setUpper(m_Data.numAttributes() - 1); m_ActiveIndices = new boolean[m_Data.numAttributes()]; for (int i = 0; i < m_ActiveIndices.length; i++) { m_ActiveIndices[i] = m_AttributeIndices.isInRange(i); } }
/** * Builds a string listing the attribute values in a specified range of * indices, separated by commas and enclosed in brackets. * * @param instance the instance to print the values from * @return a string listing values of the attributes in the range */ protected String attributeValuesString(Instance instance) { StringBuffer text = new StringBuffer(); if (m_Attributes != null) { m_Attributes.setUpper(instance.numAttributes() - 1); boolean first = true; for (int i = 0; i < instance.numAttributes(); i++) { if (m_Attributes.isInRange(i) && i != instance.classIndex()) { if (!first) { text.append(m_Delimiter); } text.append(instance.toString(i)); first = false; } } } return text.toString(); }
/** * Builds a string listing the attribute values in a specified range of indices, * separated by commas and enclosed in brackets. * * @param instance the instance to print the values from * @return a string listing values of the attributes in the range */ protected String attributeValuesString(Instance instance) { StringBuffer text = new StringBuffer(); if (m_Attributes != null) { text.append(" <" + TAG_ATTRIBUTES + ">\n"); m_Attributes.setUpper(instance.numAttributes() - 1); for (int i=0; i<instance.numAttributes(); i++) { if (m_Attributes.isInRange(i) && i != instance.classIndex()) { text.append(" <" + TAG_ATTRIBUTE + " " + ATT_INDEX + "=\"" + (i+1) + "\"" + " " + ATT_NAME + "=\"" + sanitize(instance.attribute(i).name()) + "\"" + " " + ATT_TYPE + "=\"" + Attribute.typeToString(instance.attribute(i).type()) + "\"" + ">"); text.append(sanitize(instance.toString(i))); text.append("</" + TAG_ATTRIBUTE + ">\n"); } } text.append(" </" + TAG_ATTRIBUTES + ">\n"); } return text.toString(); }
/** * Builds a string listing the attribute values in a specified range of indices, * separated by commas and enclosed in brackets. * * @param instance the instance to print the values from * @return a string listing values of the attributes in the range */ protected String attributeValuesString(Instance instance) { StringBuffer text = new StringBuffer(); if (m_Attributes != null) { text.append(" <" + TAG_ATTRIBUTES + ">\n"); m_Attributes.setUpper(instance.numAttributes() - 1); for (int i=0; i<instance.numAttributes(); i++) { if (m_Attributes.isInRange(i) && i != instance.classIndex()) { text.append(" <" + TAG_ATTRIBUTE + " " + ATT_INDEX + "=\"" + (i+1) + "\"" + " " + ATT_NAME + "=\"" + sanitize(instance.attribute(i).name()) + "\"" + " " + ATT_TYPE + "=\"" + Attribute.typeToString(instance.attribute(i).type()) + "\"" + ">"); text.append(sanitize(instance.toString(i))); text.append("</" + TAG_ATTRIBUTE + ">\n"); } } text.append(" </" + TAG_ATTRIBUTES + ">\n"); } return text.toString(); }
/** Generate the cutpoints for each attribute */ protected void calculateCutPoints() { Instances copy = null; m_CutPoints = new double[getInputFormat().numAttributes()][]; for (int i = getInputFormat().numAttributes() - 1; i >= 0; i--) { if ((m_DiscretizeCols.isInRange(i)) && (getInputFormat().attribute(i).isNumeric())) { // Use copy to preserve order if (copy == null) { copy = new Instances(getInputFormat()); } calculateCutPointsByMDL(i, copy); } } }
/** Generate the cutpoints for each attribute */ protected void calculateCutPoints() { Instances copy = null; m_CutPoints = new double[getInputFormat().numAttributes()][]; for (int i = getInputFormat().numAttributes() - 1; i >= 0; i--) { if ((m_DiscretizeCols.isInRange(i)) && (getInputFormat().attribute(i).isNumeric())) { // Use copy to preserve order if (copy == null) { copy = new Instances(getInputFormat()); } calculateCutPointsByMDL(i, copy); } } }
/** * Set the output format. Takes the current average class values and * m_InputFormat and calls setOutputFormat(Instances) appropriately. */ private void setOutputFormat() { Instances newData; ArrayList<Attribute> newAtts = new ArrayList<Attribute>(getInputFormat() .numAttributes()); for (int j = 0; j < getInputFormat().numAttributes(); j++) { Attribute att = getInputFormat().attribute(j); if (!att.isNominal() || !m_AttIndex.isInRange(j)) { newAtts.add(att); } else { Attribute newAtt = new Attribute(att.name(), (ArrayList<String>) null); newAtt.setWeight(getInputFormat().attribute(j).weight()); newAtts.add(newAtt); } } // Construct new header newData = new Instances(getInputFormat().relationName(), newAtts, 0); newData.setClassIndex(getInputFormat().classIndex()); setOutputFormat(newData); }
/** * Set the output format. Takes the current average class values and * m_InputFormat and calls setOutputFormat(Instances) appropriately. */ private void setOutputFormat() { Instances newData; ArrayList<Attribute> newAtts = new ArrayList<Attribute>(getInputFormat() .numAttributes()); for (int j = 0; j < getInputFormat().numAttributes(); j++) { Attribute att = getInputFormat().attribute(j); if (!att.isNominal() || !m_AttIndex.isInRange(j)) { newAtts.add(att); } else { Attribute newAtt = new Attribute(att.name(), (ArrayList<String>) null); newAtt.setWeight(getInputFormat().attribute(j).weight()); newAtts.add(newAtt); } } // Construct new header newData = new Instances(getInputFormat().relationName(), newAtts, 0); newData.setClassIndex(getInputFormat().classIndex()); setOutputFormat(newData); }
/** Generate the cutpoints for each attribute */ protected void calculateCutPoints() { m_CutPoints = new double[getInputFormat().numAttributes()][]; for (int i = getInputFormat().numAttributes() - 1; i >= 0; i--) { if ((m_DiscretizeCols.isInRange(i)) && (getInputFormat().attribute(i).isNumeric()) && (getInputFormat().classIndex() != i)) { if (m_FindNumBins) { findNumBins(i); } else if (!m_UseEqualFrequency) { calculateCutPointsByEqualWidthBinning(i); } else { calculateCutPointsByEqualFrequencyBinning(i); } } } }
/** Generate the cutpoints for each attribute */ protected void calculateCutPoints() { m_CutPoints = new double[getInputFormat().numAttributes()][]; for (int i = getInputFormat().numAttributes() - 1; i >= 0; i--) { if ((m_DiscretizeCols.isInRange(i)) && (getInputFormat().attribute(i).isNumeric()) && (getInputFormat().classIndex() != i)) { if (m_FindNumBins) { findNumBins(i); } else if (!m_UseEqualFrequency) { calculateCutPointsByEqualWidthBinning(i); } else { calculateCutPointsByEqualFrequencyBinning(i); } } } }