---
title: Label Flipping in Machine Learning
url: https://www.emergentmind.com/topics/label-flipping
type: topic
---

# Label Flipping in Machine Learning

Label flipping denotes a change in class labels without a corresponding change in the underlying instance representation. In the canonical supervised-learning form, the training set is written as \(D=\{(x_i,y_i)\}_{i=1}^N\), and a poisoned variant replaces some labels by incorrect values, producing \(D'=\{(x_i,y_i')\}_{i=1}^N\) while leaving features unchanged [2403.02995][1803.00992]. Across the literature, however, the same term is also used for constructive label transformation in data augmentation, fairness-oriented preprocessing, and counterfactual evaluation; its meaning is therefore context-dependent rather than uniform [2108.06332][2209.07047][2505.13972].

## 1. Core definitions and semantic scope

In adversarial machine learning, label flipping is a special case of data poisoning in which the attacker cannot change the input features \(x\), but can change the labels \(y\) of a subset of training points [1803.00992]. In the binary URL-detection formulation, with \(y_i \in \{0,1\}\), the attacker flips benign labels \(y_i=0\) to malicious \(y_i'=1\) and malicious labels \(y_i=1\) to benign \(y_i'=0\), creating a poisoned training set \(D'=\{(x_i,y_i')\}_{i=1}^N\) [2403.02995]. A common scalar parameter is the poisoning rate, written either as \(p=M/N\) or \(\alpha=|\mathcal{I}_{\text{poi}}|/n\), denoting the fraction of training samples whose labels are altered [2403.02995][2302.04109].

The term does not always denote adversarial corruption. In FlipDA, “label flipping” means intentionally generating new training examples whose labels are different from the original example they are derived from, and then training on these new \((\text{text},\text{flipped-label})\) pairs [2108.06332]. In iFlipper, label flipping is a pre-processing technique for improving individual fairness by minimally changing labels subject to a bound on individual fairness violations [2209.07047]. In counterfactual data augmentation, label flipping is operationalized through the Label Flip Rate, \(LFR=\frac{1}{N}\sum_{n=1}^{N}\mathds{1}(y'_k\neq y_k)\), where \(y'_k\) is the judge model’s label for the counterfactual and \(y_k\) is the original ground-truth label [2505.13972]. In adversarial computer vision, “label flipping” can also refer to the post-attack event \(f(X_i)\neq f(X_i^{adv})\), which underlies fooling rate [2004.12771].

| Context | Meaning of label flipping | Representative source |
|---|---|---|
| Data poisoning | Modify labels of existing training samples while leaving features unchanged | [1803.00992] |
| Data augmentation | Generate new examples whose labels differ from the source example | [2108.06332] |
| Fairness preprocessing | Minimally flip labels to reduce individual fairness violations | [2209.07047] |
| Counterfactual evaluation | Measure whether a counterfactual’s label differs from the original label | [2505.13972] |
| Adversarial fooling | Count whether the model’s predicted label changes after perturbation | [2004.12771] |

This multiplicity of meanings is a recurrent source of confusion. A precise account must therefore distinguish malicious label corruption, constructive label transformation, and evaluation-only notions of label change.

## 2. Poisoning formulations and empirical effects in centralized learning

The most explicit adversarial formulation is bilevel. For binary linear classification, the attacker chooses an indicator vector \(\mathbf{u}\in\{0,1\}^m\) with \(\|\mathbf{u}\|_0=p\), where \(u(i)=1\) means that point \(i\) is flipped, and then maximizes validation loss after the learner retrains on the poisoned set \(S_p(\mathbf{u})\) [1803.00992]. Because exact search over \(\binom{m}{p}\) possibilities is intractable, a greedy Label Flipping Attack iteratively flips the label whose change yields the largest validation loss after retraining [1803.00992]. In tabular learning, Falfa reformulates the adversary’s objective for cross-entropy classifiers as a linear program and shows that adversarial label-flipping attacks can camouflage a highly skewed dataset as an easily solvable classification problem, often misleading machine learning practitioners into lower defenses and miscalculations of potential risks [2310.10744].

Empirical effects are substantial even at modest budgets. In RF-based malicious URL detection, random LF at poisoning rates \(p\in\{0.02,0.03,0.04,0.05\}\) preserves high training accuracy, typically \(95\text{–}98\%\), while yielding Attack Success Rate between \(50\%\) and \(65\%\); the clean RF baseline reaches \(100\%\) testing accuracy on all six URL datasets [2403.02995]. For linear classifiers on BreastCancer, MNIST 1 vs 7, and Spambase, flipping \(20\%\) of training labels increases average classification error by factors \(2.8\), \(6.0\), and \(4.5\), respectively [1803.00992]. In EEG-based emotion assessment with four classes, AdaBoost drops from about \(99.68\%\) accuracy at \(0\%\) poisoning to about \(21.61\%\) at \(75\%\) poisoning, while Random Forest drops from about \(90.97\%\) to about \(14.52\%\) under the same schedule [2302.04109]. In wearable human activity recognition, poisoning \(15\%\) of training labels reduces MLP accuracy from \(94\%\) to \(39\%\), and at \(30\%\) poisoning the same model reaches \(19\%\) accuracy [2208.08433].

Label flipping also appears in hybrid backdoor constructions. DirtyFlipping is a dirty label-flipping attack for audio models that attaches a trigger such as clapping to selected data patterns associated with the target class and flips labels to a dirty label; with about \(1\%\) poisoned data it reports benign accuracy remaining high and attack success rate reaching \(100\%\) across multiple architectures, including CNN, VGG16, LSTM, and several pre-trained audio transformers [2404.00076]. This suggests that the operational boundary between pure label poisoning and backdoor insertion is porous when triggers and label inversion are coupled.

## 3. Federated and distributed label flipping

In federated learning, label flipping is implemented locally. Each malicious client replaces its local dataset \(D_i=\{(x_k,y_k)\}_{k=1}^{m_i}\) by \(D_i'=\{(x_k,y_k')\}_{k=1}^{m_i}\), then trains normally and uploads a poisoned model update to the server [2509.22873]. A common targeted rule chooses a source class \(s\) and target class \(\tau\), setting \(y_k'=\tau\) if \(y_k=s\) and \(y_k'=y_k\) otherwise [2509.22873][2207.01982]. This is easy to perform because it does not require protocol violations or gradient fabrication; the server sees an apparently legitimate update [2509.22873].

Several studies show that federated label flipping is strongly modulated by data heterogeneity and by how the attack budget is distributed. In distributed logistic regression, a budget of only \(0.1\%\) of labels at each training step can reduce the accuracy of the model by \(6\%\), and some models can perform worse than random guessing when up to \(25\%\) of labels are flipped [2503.00140]. For a fixed corrupted fraction \(k b\), increasing write-access \(k\) generally yields stronger attacks than increasing the flipping budget \(b\) alone [2503.00140]. In a broader empirical study over MLR, SVC, MLP, CNN, Random Forest, XGBoost, and LSTM, models differ in their inherent robustness to the percentage of adversarial clients and the percentage of labels flipped by each adversarial client [2412.18507]. MLR and SVC are comparatively stable across 10-client and 100-client settings, whereas Random Forest and XGBoost degrade strongly as the number of clients increases, even before attack [2412.18507].

Non-IID settings are particularly difficult. One study reports that existing FL methods perform similarly in IID settings but fail to maintain model robustness in Non-IID settings; with MNIST\(_{0.9}\) under attack, Krum, Median, Trimmed Mean, and FLTrust yield global accuracies \(65.04\%\), \(65.71\%\), \(67.22\%\), and \(72.45\%\), whereas HSCSFL reaches \(88.25\%\) [2311.05826]. AntiFLipper addresses multi-class label-flipping attacks by shifting detection to the client side: under a constant attack with \(40\%\) malicious clients, it reports \(68.23\%\) accuracy and \(48.43\) ms aggregation time on CIFAR-10 Non-IID, compared with \(37.77\%\) and \(1334.06\) ms for FLAME [2509.22873]. A separate gradient-based defense shows that the contradicting objectives of attackers and honest peers on source-class examples are reflected in the gradients corresponding to the source and target neurons in the output layer, and reports effectiveness regardless of the data distribution or model dimensionality [2207.01982].

## 4. Detection, sanitization, and robust training defenses

The oldest recurring defense family is neighborhood-based label sanitization. In binary linear classification, a \(k\)-NN defense relabels a point when the mode of its \(k\) nearest neighbors has confidence at least \(\eta\); at \(20\%\) poisoning it keeps BreastCancer and Spambase accuracy close to the clean-data baseline and substantially mitigates the attack on MNIST 1 vs 7, although it causes a small performance drop when no attack is present [1803.00992]. The URL-defense variant first selects the best \(K\) on a trusted dataset, then performs an alarm-and-correction pass over the poisoned set by comparing each sample’s label with the mode of its \(K\) nearest neighbors; on six URL datasets and poisoning rates \(2\text{–}5\%\), detection accuracy reaches up to \(100\%\), post-defense RF training accuracy lies in the range \(99.87\text{–}100\%\), and ASR collapses to near \(0\) after retraining [2403.02995]. In wearable HAR, a KNN-based sanitization mechanism using a small trusted dataset recovers MLP accuracy to \(91\%\) at \(15\%\) poisoning and \(89\%\) at \(30\%\) poisoning, compared with \(39\%\) and \(19\%\) without defense [2208.08433].

Semi-supervised and clustering-based defenses appear when local label consistency is insufficient. In Android malware detection, a Silhouette Clustering-based Label Flipping Attack flips labels when the silhouette value is non-positive, and the proposed Label-based Semi-supervised Defense and clustering-based Semi-supervised Defense correct attacked labels by combining graph-based semi-supervised learning, CNN predictions, and clustering-quality criteria; using random forest feature selection and varying ratios of features can result in an improvement of up to \(19\%\) accuracy when compared with the state-of-the-art method in the literature [1908.04473]. In federated learning, HSCSFL assigns each client an honest score equal to the dot product of its class-wise accuracy vector and the global risk vector, then aggregates only the top \(p\%\) of clients; under MNIST\(_{0.9}\) and label flipping, it preserves attacked-class accuracy far better than Krum, Median, Trimmed Mean, or FLTrust [2311.05826]. AntiFLipper instead uses local evaluation feedback, trust inference, anomaly-guided filtering, and weighted aggregation; with evaluation on only \(10\%\) of local data, the relative overhead is about \(1.1\%\), and aggregation time remains close to FedAvg while robustness remains competitive or superior under both IID and Non-IID settings [2509.22873].

A distinct defense logic exploits output-layer gradients rather than labels themselves. For targeted LF in FL, the gradients attached to source and target neurons are discriminative because honest and malicious peers optimize opposite objectives on source-class examples; dynamically extracting those gradients, clustering them, and filtering the suspicious cluster yields lower test error, higher overall accuracy, higher source-class accuracy, lower attack success rate, and higher stability of the source class accuracy than several robust aggregation baselines [2207.01982]. Collectively, these results suggest that defenses against label flipping are most effective when they model feature-label inconsistency explicitly rather than assuming that poisoned examples are merely feature-space outliers.

## 5. Constructive and non-adversarial uses

A separate line of work treats label flipping as a useful operation rather than an attack. FlipDA argues that generating label-flipped data is more crucial to the performance than generating label-preserved data in few-shot natural language understanding [2108.06332]. The method first fine-tunes an initial classifier, then uses T5 with pattern-based cloze prompting to generate candidate texts, uses the classifier to select high-confidence candidates whose predicted label differs from the source label, and retrains on the union of original data, label-flipped data, and label-preserved data [2108.06332]. On ALBERT-xxlarge-v2 across eight SuperGLUE tasks, FlipDA improves the average score from \(71.20\) to \(74.63\) with MaxDrop \(0.0\); on DeBERTa-v2-xxlarge it improves the average from \(77.36\) to \(80.23\) with MaxDrop \(1.28\) [2108.06332]. The paper explicitly distinguishes this from adversarial label-flipping attacks: the text itself changes and the flipped label is validated by a classifier, so the new pair is intended to be semantically consistent [2108.06332].

In fairness research, iFlipper formulates label flipping as constrained repair. Given binary labels \(y_i\in\{0,1\}\) and a similarity matrix \(W\), it minimizes the number of flipped labels, \(\sum_i (y_i-y_i')^2\), subject to a total individual fairness violation constraint \(\sum_{ij} W_{ij}(y_i-y_j)^2 \le m\) [2209.07047]. The underlying optimization is NP-hard, so the method converts the problem into an ILP, relaxes it to an LP, proves that the LP optimum can be transformed into a \(\{0,\alpha,1\}\)-valued solution, then applies adaptive rounding and reverse greedy refinement while preserving feasibility [2209.07047]. Experiments on COMPAS, AdultCensus, Credit, and a large synthetic dataset show that iFlipper significantly outperforms pre-processing baselines in terms of individual fairness and accuracy on unseen test sets, and that it can be combined with in-processing techniques such as SenSR for further gains [2209.07047].

These constructive uses materially alter the semantics of the term. Here label flipping is not corruption of unchanged instances but either the generation of semantically changed counterexamples or the optimization of labels to satisfy a fairness criterion. This suggests that the phrase should always be interpreted relative to the surrounding objective: attack, augmentation, or repair.

## 6. Evaluation metrics, counterfactuals, and recurring misconceptions

One recurring misconception is that label flipping is adequately captured by ordinary accuracy. Several attack studies show the opposite. In URL detection, training accuracy under \(2\text{–}5\%\) poisoning remains \(95\text{–}98\%\) while ASR lies between approximately \(50\%\) and \(65\%\) [2403.02995]. In federated settings, global accuracy can also conceal strong source-class degradation or attack-specific failures, which is why source-class accuracy, attack success rate, and class-wise risk vectors recur across defenses [2207.01982][2311.05826]. In adversarial image evaluation, fooling rate only checks whether the predicted label changes and ignores the severity of the change; FR@K, QI-Wup, and QI-Vis were proposed precisely because mere label flipping does not distinguish dog-to-dog from dog-to-vehicle confusions [2004.12771].

A second misconception is that all label noise is alike. BadLabel defines a label-noise type crafted from a label-flipping attack so that the loss values of clean and noisy labels become indistinguishable [2305.18377]. Under BadLabel on CIFAR-10 at \(40\%\) corruption, DivideMix drops to \(58.44\%\) best accuracy and ProMix to \(48.36\%\), whereas the same methods stay above \(95\%\) under \(40\%\) symmetric noise [2305.18377]. The proposed robust LNL method perturbs labels adversarially at each epoch, then uses BayesGMM and semi-supervised learning to recover a mostly clean subset; ablations show that both label perturbation and filtering low-quality divisions are essential under BadLabel [2305.18377]. This indicates that the usual small-loss assumption is not a stable property of label noise, but a property of particular noise models.

A third misconception concerns counterfactual data augmentation. In this literature, label flipping is not the attack but the criterion for counterfactual validity: \(LFR=\frac{1}{N}\sum_{n=1}^{N}\mathds{1}(y'_k\neq y_k)\) [2505.13972]. Yet automatic evaluation is unstable: across two LLM-based generation methods, three datasets, five generator models, and fifteen judge models, independent, non-fine-tuned judges achieve the highest alignment ratio \(r_{m/l}=2.17\), but even the best judges differ on average by \(22.78\) percentage points in LFR from human evaluation [2505.13972]. With a user study of \(n=90\) and Cohen’s \(\kappa=0.55\), the paper concludes that a fully automated pipeline for CDA may be inadequate and requires human intervention [2505.13972].

Across these strands, label flipping is best understood as a family of operations on supervision rather than a single technique. In adversarial settings it is a poisoning mechanism that exploits the model’s trust in labels; in augmentation it is a way to generate informative counterexamples; in fairness it is a repair primitive; and in counterfactual evaluation it is a metric event. The shared technical core is the manipulation or detection of label-state transitions, but the surrounding objective determines whether the transition is harmful, beneficial, or merely diagnostic.

Source: https://www.emergentmind.com/topics/label-flipping