I have a dataset that would be useful for training future machine learning models.

However, it contains sensitive information (personal identifiers like names and addresses) that make it difficult to store or retain longterm.

I'm wondering if there are transformations that could be applied that would remove the sensitive information, while retaining it's usefulness?

The dataset is specifically useful for training NLP related models, but I'm also interested in a general solution to this for general machine learning tasks if one exists.

  • $\begingroup$ Why can't you .... just remove the sensitive information from the database? Or just pull relevant data from the database? $\endgroup$
    – SmallChess
    Commented Jul 19, 2017 at 16:31
  • $\begingroup$ Imagine the training set is a collection of lines like: "My name is John Smith, and I think the service here was great". Removing 'John Smith' and replacing it with <name> will weaken the ability of a future model to do named entity detection. Is there a way to remove the sensitive information without weakening the data set? I'm hoping there is an industry best practice for doing this sort of thing $\endgroup$ Commented Jul 19, 2017 at 16:49
  • $\begingroup$ If that's the case, can you just replace the names with a random name or even better a number such as "R100001"? $\endgroup$
    – SmallChess
    Commented Jul 19, 2017 at 16:50
  • $\begingroup$ datascience.stackexchange.com/a/20443/8560 $\endgroup$
    – D.W.
    Commented Jul 20, 2017 at 6:30

1 Answer 1


There are lots of solutions to this problem and both of them would allow you to release the dataset. There are in general, two factors that are of importance, the first, whether the method is error prone or not and secondly, whether it is time consuming or not.

The first, being a simpler and dependent solution. If you have a dictionary of names that you maintain, in your database, what you can do is search for whether the given word is a substring of a name (probably through a trie search) and then, check to see if it's a name in your database. If it is, replace it with some string, something even as easy as "Name101" would be easy to accomplish. The same can be done for geographical locations and other possibly sensitive data. This is a non-error prone and time saving method.

If you haven't done the former, there is a solution, however, it's a natural language processing technique called Named Entity Recognition (https://en.wikipedia.org/wiki/Named-entity_recognition), where you can detect if a given word is a name, location or anything that could be worth hiding. However, please understand that this method is not guaranteed to succeed, it may hide most of your data, but it is not guaranteed to hide all of it. This is time saving but certainly error prone.

The last possible alternative is to actually comb through the data yourself and make sure that you've changed all of the names. This is an error prone and time consuming technique.

Ultimately, you can use any of these to accomplish the tasks, but some of them are possible given your method of data collection, or your data pipeline.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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