0
$\begingroup$

So I want to compare strings and find out there relation to one another. For this I figured out I also have to encode the positional info. For eg: aaaaassssssbbbbbb should be more relevant to aaaasssssbbbbrather than bbbbaaasssss. The output will be a relative measure and 1 and 2 should match more compared to 1 and 3. Also I will represent each character by a number.

So how can I re-design my feature vector (feature transformation) to be input in a NN to capture this information effectively?

$\endgroup$
2
$\begingroup$

If you just want to compare the letter and position, you could just use the strings as lists of characters and either compare up to the index of the shortest list or by sliding the shorter list over the longer list and grabbing the average number of matches.

Depending on your needs though I would recommend using more than just the positional data in the string. Two approaches I would probably try in addition to the above.

  1. You could try converting the string to m length subsequences and then compare or aggregate in some way the number of matching or similar subsequences.
  2. You could try converting the string to a regex and then compare the regex similarity.
$\endgroup$
1
$\begingroup$

Assuming you are using Keras, you should use the Embedding Layer to convert your strings into vectors of real numbers and compare their distance in a high-dimensional space.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.