Nom2IntArff.m 804 B

123456789101112131415161718192021222324
  1. % Nom2IntArff.m
  2. %
  3. % This function converts all the nominal attributes in the provided ARFF file
  4. % to integer attributes. This helps speeding-up loading and saving times for
  5. % very large ARFF files.
  6. %
  7. % input:
  8. % inputfile - ARFF file to convert
  9. % outputfile - file to store changed ARFF
  10. function Nom2IntArff(inputfile, outputfile)
  11. [data, metadata, attributes, relation, comments] = LoadArff(inputfile);
  12. for i=1:size(attributes,1)
  13. isNom = IsNomAttribute(attributes{i,2});
  14. if (isNom)
  15. description = [' Attribute ' attributes{i,1} ' ' attributes{i,2} ' was converted to integer'];
  16. comments{end+1} = description;
  17. attributes{i,2} = 'integer';
  18. end
  19. end
  20. SaveArff(outputfile, data, metadata, attributes, relation, comments);
  21. end