function data = create_ecoli_data()

% function data = create_ecoli_data()
% 
% Processing of E. coli dataset, take only numeric attributes and code 8
% possible classes with integers from 1 to 8.
% 
% Inputs :  none.
% Outputs:  data        - matrix representing the E. coli dataset, columns
%                         1 - 7 are features, 8. column is label.
%
% Author: Nemanja Djuric
% Date  : Sept. 25th, 2010

data = zeros(336, 8);
fid = fopen('ecoli.txt', 'r');
classes = {'cp', 'im', 'imS', 'imL', 'imU', 'om', 'omL', 'pp'};
  
for i = 1 : 336
    cell_array = textscan(fid, '%s\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%s\n', 1);

    % take only numeric features
    for j = 2 : 8
        data(i, j - 1) = cell_array{j};
    end;
    
    % represent classes with numbers
    for j = 1 : 8
        if (strcmp(classes{j}, cell_array{9}))
            data(i, 8) = j;
            break;
        end;
    end;
end;