# Machine Learning Analysis for Redaction Purposes of Personally Identifying Information from Open Text Fields

Let's say that I wanted to use machine learning to find and redact personally identifying information (PII) from millions of records with open text fields.

Let's also say the PII could include a wide array of information categories like full names, dates of birth, places of residence, driver's license numbers, passports, family member names, etc.

Let's not forget to mention that thousands upon thousands of collectors were used to input this data too, which introduces an additional layer of complication (e.g. inconsistent reporting, nuanced terminology, abbreviations, spelling errors).

And finally, let's say that this data is meant to be released to the public so the risks of re-identification for nefarious purposes are very high.

Given that background, how feasible would it be to apply machine learning here? What important limitations/considerations should be taken during this process? Can machine learning address the problem of PII in this case? Why or why not?

• For free-form texts the chance of not missing any PII using ML is probably zero. Are there any more assumptions one can make or additional information about the type of text you can provide? What level of accuracy do you expect? 100%?
– oW_
Dec 10 '19 at 17:19
• I can't go into too much detail, but I can say that the open text fields are meant to provide context surrounding the decision to include the individual in the data set. I can provide analogous examples though. One situation would be a company publishing the browsing history of millions of people, but thousands of people could be identified based on the open text fields. Depending on the individual, the information could be highly embarrassing and could be used by others (e.g. employers, friends, family members) to target them. Dec 10 '19 at 17:30

Given that background, how feasible would it be to apply machine learning here? What important limitations/considerations should be taken during this process? Can machine learning address the problem of PII in this case? Why or why not?

I think that ML can be used to speed up the process (by annotating the most obvious types of PII), but ML cannot be trusted to reliably redact any and all occurrences of PII. Two main reasons why:

• Even for the reasonably simple task of Named Entity Recognition (NER), where state of the art ML perform very well, realistically the performance is never 100%.
• NER is not sufficient to remove any PII, and to the best of my knowledge there is no safe automatic method to do so. Consider the following example: "my girlfriend has a butterfly tatoo on her ankle" -> this is a PII, even though there is no named entity: if the text contains other specific details about this person, crossing this information with other sources can lead to identification of the author.

If the goal is to satisfy some legal/contractual requirements, there is no other way than to have human annotators do it, possibly with the help of ML (and even human annotators will need very specific guidelines).

• I know this isn't part of the original question, but I would be really curious to read any sources you may have. This is all very interesting to me. Dec 11 '19 at 19:27
• @Craig sorry I don't have any specific source. The first point is obvious for anybody with a bit of experience in ML and NLP, I haven't checked the state of the art performance in NER for a while but I'm sure it's not 100%. The second point is based on a recent experience I had with anonymizing a small dataset: it had to be done for legal reasons so quite seriously... and it was a very unpleasant task. Dec 11 '19 at 23:53
• Named entities: relationships=[father,mother, girlfriend, spouse] or animals=[dog, cat, butterfly, elephant] or body_parts=[head, arm, ankle]. Apply named entity extraction on my girlfriend has a butterfly tatoo on her ankle and you get my ----- has a ------ tatoo on her -----. So I think NER can do the job. Problem is on the recall that you will get on this. Dec 12 '19 at 7:09
• @BrunoGL But this option requires preparing a very big vocabulary of all the words which are potentially involved in a PII: 1) it's a massive job, as opposed to applying a pre-trained NER, 2) it's virtually impossible to anticipate every possible case (i.e. imperfect recall as you said) ; 3) even if it was, the trigger vocabulary would have to cover so much that there would be very little text left after removing the entities, so we end up with redacting nearly everything. Dec 12 '19 at 11:43
• @Erwan I totally agree with all your points! But the task he want to accomplish is ambitious, so he will need to put in a lot of effort for it. Dec 13 '19 at 9:46

## NER

Basically the problem you have is Named Entity Recognition (NER).

This is a classic NLP problem and there are many machine learning approaches to it. Some recurring neural networks can be used, or the go-to method conditional random fields.

There are different techniques, usually in training, to overcome the issues (inconsistent reporting, nuanced terminology, abbreviations, spelling errors) that you mentioned.

## Consideration

One important thing you need to consider is accuracy vs recall. You can choose to optimize one or the other, or both.

Accuracy = you try to redact something only if it really is some personal information.

Recall = you try to not miss any personal information.

Let say you have the sentence "Hello, my name is John, and my social security number is 123456789."

If you redact the sentence to: "Hello, -- ---- -- ----, --- -- ----- ------ ------ -- --------." You get really high recall (all personal information is gone)! But your accuracy is low, you redacted more than you should.

All this can be leveraged during prediction time. The probability score from your NER can make you optimize or the other.

Of course, this begs the questions: Why not redact EVERYTHING and so that 100% of personal information is not leaked?

• Thank you for your answer. But as with my previous comment, I'd be very curious to see any sources you may have that go into this detail and speak to your point. Dec 11 '19 at 19:28
• Dec 12 '19 at 7:15