# String inputs in Machine Learning

Several popular machine learning algorithms such as Logistic regression or Neural networks require its inputs to be numeric.

What I'm interested in is how you make these algorithms work on non-numeric inputs (such as short strings).

As an example, let's say we're building an email classification system (spam/not spam), where one of the input features is the sender address.

To be able to use a learning algorithm, we need to represent the sender address as a number. One way is to simply number the senders 1..n. Our training set might then look like this:

This won't work, however, because algorithms such as Logistic regression or Neural networks learn patterns in the input data, while in our example, the output looks totally random to the algorithm. Indeed, once in a university class, we tried to train a Neural network on a dataset that looked like this and the network was unable to learn anything (the learning curve was flat).

Would you use Logistic regression or Neural networks in this example at all? If yes, in which way? If not, what would be a good way to classify emails based on sender address?

A perfect answer would discuss the email classification example as well as handling short strings in ML in general.

A pretty famous distance metric is the Levenshtein distance which is based on the the number of single character edits. eg. that is, $d(walk,talk)<d(walk,plod)$.