MATLAB: What has to be done to text input for ANN

anndeep learningDeep Learning Toolboxmachine learningMATLAB

I have 5 inputs and 1 output for my ANN problem. Among the 5 inputs are 2 "text". One is name of manufacturer (3 unique) and the other is specimen exposure type (acid, alkaline, alkaline+salt, water). How should these text type input be modified to train the model?

Best Answer

  • The easiest approach would be to convert the text values to numeric values before feeding to the ANN. For example,
    exposure_types = {'acid', 'alkaline', 'alkaline+salt', 'water'};
    and input data is something like this
    inputs = {'acid', 'acid', 'acid', 'water', 'alkaline', 'acid', 'alkaline+salt'}
    you can get an equivalent numeric form using ismember()
    [~, inputs_numeric] = ismember(inputs, exposure_types);
    >> inputs_numeric
    inputs_numeric =
    1 1 1 4 2 1 3