# Machine learning methods on 1 feature dataset

Assuming I have following dataset but much longer. Can I use any machine learning methods having only one feature? Giving Name and predicting Fullname. I'm newbie and think that doesn't make any sense cause it applies just basic statistics computations as mode. But maybe is something better? If some methods can be used, which ones?

Name   | Fullname
------------------
John   | Novak
Sophia | Loren
Dave   | Miller
Anna   | Smith
Dave   | Smith
...

• What you can do is to make ngrams (sequences of letters) to predict what the most likely next letter(s) following a certain sequence would be. By doing so, you could be able to predict the most likely family name following a certain first name. However, this will obviously just yield the most common or likely sequence (name here). See this Python package for instance: github.com/jsvine/markovify/blob/master/README.md – Peter May 20 '20 at 10:29
• Is the full name the last name of the person? In that case it doesn't make any sense to try to predict it. NLP is not magic, it won't work if there is no correlation between the feature/s and the target variable – Guillermo Mosse May 21 '20 at 11:13

# Can I use any machine learning methods having only one feature?

Yes!

In fact, many NLP classifications tasks are in this format. Given 1 piece of text, classify something. For example:

• Given 1 review, classify the sentiment
• Given 1 news article, classify the topic
• Given 1 chat message, classify the intent

And now you have:

• Given 1 name, classify the Fullname

# Can a better method be used?

Like you mentioned, you could just find the most common Fullname for a given name and every time you get a name you have a lookup table for the Fullname. However, what will happen when a name you have never seen before appears, how do you classify it? Are you also assuming that you already have the full list of Fullnames?

## Assumption: you know all Names and Fullnames

In this case, do as you suggested. Create a dictionary mapping Name-Fullname by finding the most common Fullname for every Name.

## Assumption: you know all Fullnames but not all Names

Let say you have the mappings:

Peter -> Johnson
John  -> Smith


Then, there is a name you have never seen before, Pete for example, which does not appear in your mapping table.

You could try two approaches:

1. The simple way - find which name in the mapping is closest to Pete using some word distance measure, like Levenshtein.
2. The more robust way - forget the notion of mapping table and use a machine learning model. You will need the following things:
1. A text vectorizer to transform your text into a numerical vector. I would suggest a character level n-gram TF-IDF.
2. A classifier. If you use the vectorizer I suggested, then you will need a linear classifier, like an SVM.

If you go to with approach two, when you encounter the name Pete, it will be spit into n-grams (e.g. [pe, et, te, pet, ete]) and vectorized.

## Assumption: you don't know all Fullnames and you don't know all Names

This gets more interesting because you could be working with Fullname generation.

It could be used when you move to names from other countries as well.

For example, you already have the mapping:

Peter -> Johnson
John  -> Smith


Then you start dealing with Dutch names and encounter Pieter and Jan. Then you might want to get the following results where even the Fullnames are different:

Pieter -> Janssen
Jan    -> Smeets


For this, you could use a seq-to-seq Recurrent Neural Network. The architecture can be similar to ones used for neural language translation.

However, all embeddings you create have to be character level. Instead of learning an embedding for every word, you learn for every character. You also feed your network one character at a time. This way, you will be less likely to find "out of vocabulary" tokens (except for when you find character from another alphabet).

• Wow. That is very comprehensive answer and very helpful. I didn't look at the problem from this side. Thank you! – Tajni May 20 '20 at 16:12