Active Hackathon

Tensorflow Model Remediation- A framework for responsible AI

Tensorflow model remediation is a framework used to obtain fairness free and bias free models. It aims to produce robust models that is not affected by sensitive attributes of data.
Listen to this story

Tensorflow model remediation is a library that provides solutions for various concerns that generally occur while modeling. TensorFlow model remediation is a library that is used to handle the concerns efficiently with respect to model performance and to overcome biases of models for particular sets of features and the library generally uses two techniques to address the concerns of the models developed. Through this article, let us try to understand the Tensorflow model remediation library and the different techniques that the library uses to address the concerns associated with the model.

Table of Contents

  1. About TensorFlow model remediation
  2. MinDiff technique for Tensorflow model remediation
  3. Counterfactual Logit Pairing for Model Remediation 
  4. Use cases of Model remediation techniques
  5. Summary

About TensorFlow model remediation

The Tensorflow model remediation technique is used to address the inclination of the model’s performance on a certain set of features or to handle the bias of the models. The library acts as a fairness regulator for the models developed and helps to handle the concerns associated with the models developed. In general, there are three ways of handling model biases, and the Tensorflow model remediation library uses the Training-time modeling technique.

THE BELAMY

Sign up for your weekly dose of what's up in emerging technology.

Are you looking for a complete repository of Python libraries used in data science, check out here.

The Training-time modeling technique tries to handle the model biases or fairness by altering the model objectives and adding certain constraints to a certain set of features based on subject expertise. The training time modeling technique has two inbuilt functionality to handle the concerns associated with the modeling. They are the Mindiff technique and Counterfactual Logit Pairing technique. Now let us look at how the different techniques are used within the Tensorflow model remediation library to handle the concerns associated with models developed.

MinDiff technique for Tensorflow model remediation

The MinDiff technique for model remediation aims to balance the error rates across the set of features by balancing the distribution of scores for each set of features being considered. So this technique scales the distribution of the feature to a common scale before model training so that the model is not affected by uncertain values present in the data.

The Mindiff technique is mainly employed to balance the difference in False Positive Rates (FPR) and False Negative Rates (FNR), where the sensitive classes of the data are sliced, and a certain penalty term is added to the sensitive terms to balance the sensitivity between the classes. This technique aims to predict the class labels accurately, even for classes with sensitivity where an equal opportunity for each of the classes is provided to each of the classes in the data. Now let us try to understand the Mindiff technique in detail.

Working of MinDiff technique

To understand the working of the MinDiff technique, let us consider two sets of features from the dataset. Suppose the features considered are not having a considerable number of occurrences, then the Mindiff technique penalizes the model during the training process itself and equalizes the distribution of scores between the sets. The smaller the variation in distribution, the lesser the penalization applied, and the larger the variation in distribution, the more the penalization applied to balance the distribution of data between the sets considered.

The application of the MinDiff technique is inclined with the tradeoffs between the performance with the original task. The MinDiff technique may be beneficial as it does not deprecate model performance, but the balance of distribution of features can be entirely dependent on the subject’s expertise. Now let us look into when to use the  MinDiff technique.

When should we use the MinDiff technique?

The MinDiff technique bridges the gap between the lower occurring instances of the classes. The sensitivity between the classes entirely depends on subjective expertise, and if the sensitivity between the classes has to be handled, we will have to use this technique. There are basically two conditions for using the MinDiff technique. They are as follows.

  • The technique has to be applied only after evaluating the performance of the original model without any remediation so that the underperforming classes can be identified and corrected accordingly using the technique.
  • The technique can be used if and only if there is a possibility to obtain a required number of samples for underperforming class instances.

So as mentioned earlier, this technique is used to handle the uncertainty in the behaviour of the model for sensitive classes, and this technique is a good choice when we try to equalize the performance

When not to use the MinDiff technique?

The MinDiff technique is known to yield phenomenal results, but at certain times, uneven distribution of certain classes would be skewed asymmetrically. So it is important to understand the distribution of data and in general, it is a better practice to normalize the model parameters before modelling. So if skewed parameters are penalized even more, it would lead to wrong interpretations from the models developed. So in these cases, the MinDiff technique should not be used.

Model type and metrics suitable for MinDiff

The MinDiff technique is most beneficial for binary class classification tasks. The application of this technique can also be used for multi-class classification tasks, but this technique is well set up for binary class classification. The technique is extremely useful to balance the distribution among the False Positive and False Negative rates from the model for efficient prediction where the concerns associated with false predictions are biased towards the most occurring categories can be evacuated using the MinDiff technique.

Counterfactual Logit Pairing for Model Remediation 

Counterfactual Logit Pairing is also known as the CLP technique, and this is one of the techniques used by the Tensorflow model remediation library. The technique is mainly used to ensure that the model prediction remains robust irrespective of counterfactual aspects, that is, the sensitivity attribute in each feature is different. So this technique ensures that the model’s prediction is right even if, in some cases sensitive features of the data are removed due to toxicity factors or decided after subjective discussions.

Working on the CLP technique

The CLP technique adds a loss factor to the original model developed that is provided by logit pairing and from counterfactual details obtained from the data. The difference between the loss factor and the logit pairing factor will be computed, and the differences in the classifiers will be penalized accordingly so that the prediction from the models is not affected by the sensitive parameters. 

When to use the CLP technique?

CLP technique is used to balance the predictions of the model where the change in a certain set of attributes or parameters affects the prediction of the model to a large extent. This technique is extensively used to handle textual data with offensive or toxic statements. So the technique takes in certain textual data as the input and returns a certain set of scores on a scale of 0 to 1 as a measure of toxicity. The toxicity between sentences is evaluated through correlation scores and for similar contexity or, to be more precise similar toxicity levels of sentences should have the same correlation value. So the CLP technique can be extensively used to check the correlation between similar types of text data and to evaluate the correlation between them.

Measuring the effectiveness of the CLP technique

Once the model is developed without any remediation technique and if the model’s prediction changes with respect to the presence of the sensitive attributes, the CLP technique has to be used. The effectiveness of the CLP technique can be measured using the “flip” parameter. So the flip parameter will be responsible for yielding the flip count and flip rates where the prevalence of issues due to toxicity can be correspondingly evaluated using this parameter. So depending on the flip parameter and the effectiveness of the flip parameter, the sensitivity of the textual data can be suitably handled for sensitivity.

When not to use the CLP technique?

As mentioned earlier, the CLP technique handles sensitive attributes, especially in textual data. The CLP technique is not structured to handle a few toxic statements like the gender and the characteristics of certain individuals. Before using the CLP technique, it is important to understand that this technique is mainly used to handle the sensitive attributes of the data and the change in prediction associated with respect to changes in the future accordingly. The CLP technique as well cannot bridge huge gaps in performance. So the CLP technique has to be used very sensibly, and if used, it is a good practice to study the sensitivity of attributes between two sets of parameters and understand the distribution of the data if possible and then only use the CLP technique to handle the sensitive attributes in the data.

Use cases of Model remediation techniques

As mentioned earlier, the model remediation technique is mainly used to balance the distribution of data, and with respect to textual data, it is also used to efficiently handle the toxicity in the data. But the model remediation techniques can be used in various places, and some of the major benefits of model remediation are mentioned below.

i) Model editing is easy with the use of remediation techniques. Some of the machine learning models, like decision trees, are extremely sensitive to smaller changes in the data. So this is where the model remediation techniques are useful, where the sensitive attributes of the data are handled efficiently so that the model is not affected by the sensitive parameters.

ii) Model assertions are also possible through model remediation techniques as it helps us to improve the business outcomes of the model as certain penalization can be applied to a certain set of features, and the model will be robust to sensitive attributes.

iii) Reduction in bias is also possible through model remediation techniques as it helps us have diverse data. The model remediation technique is responsible for careful feature selection from the trained model, and bias towards certain features is normalized using certain penalized factors.

iv) Model monitoring is also possible through the model remediation technique as it helps us to conduct continuous model debugging and continuously monitor various parameters of the model to maintain the continuous reliability of the model.

Summary

Tensorflow model remediation is one of the frameworks of Tensorflow, which ensures robust models that are not affected by sensitive attributes or small changes in data. The library aims to efficiently handle the underperforming classes in the data and tries to penalize the classes by balancing the distribution between the parameters. So on a whole, the Tensorflow remediation library is extensively used to handle the model performance concerns associated with sensitivity and aims to produce robust models.

More Great AIM Stories

Darshan M
Darshan is a Master's degree holder in Data Science and Machine Learning and an everyday learner of the latest trends in Data Science and Machine Learning. He is always interested to learn new things with keen interest and implementing the same and curating rich content for Data Science, Machine Learning,NLP and AI

Our Upcoming Events

Conference, Virtual
Genpact Analytics Career Day
3rd Sep

Conference, in-person (Bangalore)
Cypher 2022
21-23rd Sep

Conference, in-person (Bangalore)
Machine Learning Developers Summit (MLDS) 2023
19-20th Jan

Conference, in-person (Bangalore)
Data Engineering Summit (DES) 2023
21st Apr, 2023

3 Ways to Join our Community

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Telegram Channel

Discover special offers, top stories, upcoming events, and more.

Subscribe to our newsletter

Get the latest updates from AIM
MOST POPULAR

The curious case of Google Cloud revenue

Porat had earlier said that Google Cloud was putting in money to make more money, but even with the bucket-loads of money that it was making, profitability was still elusive.

Global Parliaments can do much more with Artificial Intelligence

The world is using AI to enhance the performance of its policymakers. India, too, has launched its own machine learning system NeVA, which at the moment is not fully implemented across the nation. How can we learn and adopt from the advancement in the Parliaments around the world? 

Why IISc wins?

IISc was selected as the world’s top research university, trumping some of the top Ivy League colleges in the QS World University Rankings 2022

[class^="wpforms-"]
[class^="wpforms-"]