public String getTransformedString(String attributes[], MetaData md) { String result = ""; String missingValues[] = getMissingValues(); DataTransformation dt = new DataTransformation(); int index = 0; String attributeDetails[] = md.attributeDetails.split(";"); for (int i = 0; i < md.attributeDescription.length(); i++) { if (md.attributeDescription.charAt(i) == '2') continue; else if (md.attributeDescription.charAt(i) == '0') { if (attributes[i].equals(md.missingCharacter)) result += missingValues[index]; else result += dt.getNumericalAttributeCategory( attributeDetails[0], Integer.parseInt(attributes[i])); result += ","; index++; } else if (md.attributeDescription.charAt(i) == '1') { if (attributes[i].equals(md.missingCharacter)) result += missingValues[index]; else result += dt.getCategoricalAttributeCategory(attributeDetails[index], attributes[i]); result += ","; index++; } } return result.substring(0, result.length() - 1); /* if(attributes[0].equals(md.missingCharacter)) result+=missingValues[0]; else result+=dt.getAgeCategory(Integer.parseInt(attributes[0])); result+=","; if(attributes[1].equals("?")) result+=missingValues[1]; else result+=dt.getWorkClassCategory(attributes[1]); result+=","; if(attributes[4].equals("?")) result+=missingValues[2]; else result+=attributes[4]; result+=","; if(attributes[5].equals("?")) result+=missingValues[3]; else result+=dt.getMarriedStatusCategory(attributes[5]); result+=","; if(attributes[6].equals("?")) result+=missingValues[4]; else result+=dt.getOccupationCategory(attributes[6]); result+=","; if(attributes[7].equals("?")) result+=missingValues[5]; else result+=dt.getRelationshipCategory(attributes[7]); result+=","; if(attributes[9].equals("?")) result+=missingValues[6]; else result+=dt.getGenderCategory(attributes[9]); result+=","; if(attributes[12].equals("?")) result+=missingValues[7]; else result+=attributes[12]; result+=","; if(attributes[14].equals("?")) result+=missingValues[8]; else result+=dt.getSalaryCategory(attributes[14]); */ }
/** * Applies the inverse operation of the transformation on the Data sample and creates a new Data * with the inverse transformed version * * @param data Data to be inverse-transformed * @return Inverse-Transformed Data sample (new object) */ public Object inverse(Object data) { return first.inverse(second.inverse(data)); }
/** * Determines if the operation is reversible or not * * @return True if the transformation is reversible, false otherwise */ public boolean isReversible() { return first.isReversible() && second.isReversible(); }
/** * Applies the transformation on the Data Sample and creates a new DataSample with the transformed * version * * @param data Data sample to be transformed * @return Transformed Data Sample (new object) */ public Object apply(Object data) { return second.apply(first.apply(data)); }