SCARF: Self-Supervised Contrastive Learning using Random Feature Corruption
Paper · 2021 · Dara Bahri, Heinrich Jiang, Yi Tay et al.
Summary
A table can contain useful patterns even when many of its rows lack labels. SCARF is a way to teach a neural network to recognize those patterns before asking it to predict a class. The method starts with an ordinary training row and makes a second version by changing some of its cells. Each replacement comes from the training values for the same column. The network learns to match each original row to its altered version among the altered versions of other rows. Because the training procedure creates the pairs, it can teach this matching task without class labels.
The network produces a vector for each row. During pretraining, a temporary component turns those vectors into outputs that can be compared by their direction. The matching task rewards a high similarity for the two versions of a row relative to the similarities with other rows in the same batch. After pretraining, the authors remove the temporary component, add a classifier, and update both the classifier and the original network using labeled data. This second stage is known as fine-tuning.
The authors test SCARF on 69 tabular classification datasets from OpenML-CC18. They compare training with all the original labels, training with only 25% of the training rows labeled, and training after selecting 30% of training rows for random label replacement. Across these settings, SCARF generally improves test accuracy over training the same classifier from scratch. The reported average relative accuracy gains over that control are 2.352% with full labeling, 3.692% with limited labeling, and 2.261% in the label replacement experiment. Each average includes only datasets that pass the paper’s statistical filter for that comparison. Pretraining also improves several methods already designed to handle scarce or unreliable labels.
The comparisons help explain which parts of the procedure matter. Reconstructing the original row from the same corruption generally gives smaller gains. Using the corruption solely as supervised data augmentation also performs worse. The authors find that drawing replacements separately from each column works well across the scaling methods they test, and that a clean original paired with a corrupted copy works better than corrupting both. The evidence concerns classification on these datasets. It shows that matching rows to partially altered copies can provide a useful starting point for classification, including when the downstream labels are imperfect.
Deep dive: SCARF: Self-Supervised Contrastive Learning using Random Feature Corruption
SCARF learns from unlabeled tables by replacing random feature values before training a classifier with clean, scarce, or noisy labels. · about 39 minutes to read
The problem and its context
What can a table teach before its rows have labels?
Supervised classification uses pairs of inputs and answers. For tabular classification, the input is a row of feature values and the answer is a class assigned to that row. Collecting the input may be easier than obtaining a trustworthy answer for every example, especially when labeling requires manual work. A classifier trained only on labeled examples can learn from the columns of those examples, but its supervised objective has no answer to compare with a prediction on an unlabeled row. Self-supervised learning supplies a different training signal from the inputs themselves.
The signal trains a representation, a numerical description that a later classifier can use. A network could learn a representation by predicting something deliberately hidden from an input, by recognizing a transformation, or by matching two versions of the same example. These tasks ask the network to pay attention to different properties. If it is asked to reconstruct the values of a row, its success is judged by how closely its predictions recover those values. If it is asked to match versions of a row, success depends on whether the two versions remain recognizable as a pair. SCARF studies the second kind of task for ordinary feature tables.
The design of the altered version matters because it defines what the network is encouraged to overlook. If almost everything stays the same, identifying a match may require little beyond recognizing an intact example. If the alterations remove too much information, the two views may have too little in common to make the match instructive. An effective intermediate task leaves evidence of the original row while changing enough of it to make the network use that evidence selectively. Even then, the class label plays no role in producing the pair. The downstream classification experiment determines whether the resulting representation helps with the task people actually care about.
Tables supply an obvious place to make a change, namely an individual column, but they offer little universal guidance about which changes preserve the meaning of a row. Some columns are numeric and others categorical. A numerical perturbation measured in the units of one column can be substantial in that column and negligible in another. A categorical column calls for a replacement category. Changes can also break relationships across columns, even when every cell on its own contains a value that appears in the data. The paper asks whether a generic rule for choosing replacements is useful despite these differences.
How earlier work constructed a learning signal
The paper situates SCARF alongside self-supervised techniques for images and text. In vision, earlier work learned representations from generated images or by solving tasks such as predicting pixels and recovering color. Such tasks exploit the structure of images. An image has a spatial layout, and its colors or regions can be manipulated while keeping identifiable parts of the scene. The paper also discusses contrastive image learning, in which the source image supplies the identity of a pair. Random crops, color changes, and blur can produce related views for that purpose. The closest example in the authors’ account is SimCLR.
In a contrastive task, the designated matching examples form a positive pair. Other examples supply negative pairs. The word “negative” here identifies which examples the procedure treats as nonmatches. It carries no information about whether the two examples actually share a downstream class. This distinction allows the pair assignments to come from unlabeled data. It also explains why changing the input and specifying the objective are separate decisions. The transformation creates a pair that may share useful information. The objective determines how the network is rewarded for recognizing that relationship.
In text, earlier work could mask chosen tokens and use the hidden tokens as targets. The paper discusses this approach in connection with BERT. It also describes denoising techniques that recover an input after alterations such as masking, deletion, or filling spans with substitute material. A related example in its account is BART. Other work used replacements to construct contrasting examples or used the relationship between neighboring sentences. The common point is that properties of the input make it possible to formulate a prediction problem without asking a person to label each training example.
The choice of alterations consequently depends on what the input represents. A token has a role in a sequence, and a crop is meaningful because pixels are arranged in space. The columns of a table can represent unrelated kinds of measurements or categories. Neighboring columns need not have a relationship analogous to neighboring words or image regions. SCARF uses the observed values of each column to decide what can be inserted there. The rule requires examples of the feature itself and works without a hand-designed transformation for every dataset.
The paper identifies earlier contrastive work on large-scale recommendations as another close comparison. Yao and colleagues used correlated masking of features and dropout for categorical inputs. SCARF instead builds its corrupted view with random selections of columns and separate draws from the selected columns’ value distributions. The distinction concerns both the positions chosen for alteration and the values inserted. It matters in a table because a view can keep the same columns intact across examples, or it can give each example a different pattern of retained information. It can also copy a correlated group of values together, or replace each value independently.
The closest tabular comparison
VIME already used the same kind of tabular corruption, so the replacement rule has a precedent within the setting SCARF studies. As the paper describes it, VIME trained an encoder to solve two problems from a corrupted input. One head estimated which positions had been selected for corruption. Another tried to recover the original input values. In the later semisupervised stage, VIME combined supervised training with a reconstruction objective and updated the task head while keeping the encoder fixed. The authors cite results for VIME on genomics and clinical datasets.
SCARF changes what pretraining asks the encoder to learn. Its training target is the identity of the matching row within a batch. The network receives a clean row and an altered counterpart, and the loss depends on how their similarity compares with the similarities to the other candidates. Predicting a corruption mask would teach the network to notice evidence that a cell had been modified. Predicting the original values would teach it to recover specific measurements or categories. Matching views allows the network to use whatever surviving evidence suffices to recognize a pair, subject to the demands of the other comparisons in the batch.
The later training procedure differs as well. SCARF uses the class labels to update the encoder along with the new classifier, and the supervised stage uses the classification objective alone. A representation learned through matching can therefore change in response to the class labels. The comparison with VIME clarifies the scope of SCARF’s contribution. The paper is testing a combination of a tabular view construction, a contrastive loss, and a particular transfer to supervised classification. Its reconstruction baselines help isolate the loss choice within that combination.
The method, step by step
Turning a column into a source of replacements
Start with the part of a dataset reserved for training. Each row supplies values in a fixed set of columns. For every column, SCARF uses the values seen there as a source of possible replacements. To alter a categorical cell, it draws a category that the same feature takes in the training data. To alter a numeric cell, it draws a value observed for that numeric feature. Frequently occurring values can be drawn more often because the distribution comes from the column’s occurrences across training rows.
This is an empirical marginal distribution. “Empirical” means it is built from observed data. “Marginal” means that it describes a single feature, considered separately from the other features. A numeric replacement follows the distribution of the column even if the column has a skewed or irregular range. Choosing a value for that cell does not involve estimating a normal distribution or finding the value most plausible given the rest of the recipient row.
The procedure selects a fixed number of distinct positions for each row, then samples their replacement values separately. The positions are resampled for each training example. The untouched positions retain their original values. A draw can produce the same value that was already in a selected cell, particularly if that value is common, so the number of positions selected for replacement is the quantity controlled by the corruption rate. The number of cells whose values visibly change can differ.
The resulting row is a mixture of retained values and columnwise draws. For instance, consider a row with both a categorical feature and a numerical measurement selected for replacement. The new category comes from the training column for that category, and the new measurement comes from the training column for that measurement. The two donors can be different rows. The resulting category and measurement may never have appeared together in the original table. Their purpose is to construct an alternative view of a known source row for matching.
Categorical replacement takes place before one-hot encoding in SCARF. One-hot encoding represents a category by activating the coordinate for that category within the feature’s group of coordinates. Sampling the category first means the corrupted view still has a valid encoding for that column. Independent substitution in individual coordinates of the encoded group would permit a different set of alterations, including combinations that cease to specify a single category. The paper’s distinction between SCARF and most of its alternative corruptions matters when comparing their behavior on categorical data.
From unlabeled rows to a tabular classifier
The steps in order.
Defining the corruption precisely
Let X be the collection of unlabeled training inputs. The row x contains M features, and xⱼ denotes its value in feature column j. The algorithm uses Xⱼ for the observed values of the j-th feature and builds the replacement distribution Pⱼ from them.
Pⱼ = Uniform(Xⱼ)
Here Pⱼ is the empirical distribution used to sample from column j. Uniform(Xⱼ) means choosing uniformly from the training occurrences in that column. Xⱼ contains the xⱼ values for rows x in X. A value that occurs in multiple rows can be obtained through any of those occurrences. The feature index j points to the same column in the donor data and the row undergoing corruption.
q = ⌊c · M⌋
Here q is the number of feature positions selected for replacement in each row, c is the corruption rate, and M is the number of input features in the algorithm. The centered dot denotes multiplication. The floor brackets round the product down to an integer so the procedure can choose exactly q positions.
For the row at batch position i, the algorithm samples a subset Iᵢ of size q uniformly from the feature indices. Every subset of the required size has the same chance of being chosen. This procedure sets the size of the mask while allowing the mask itself to differ from row to row. The view is then defined by a rule for the value at each position.
x̃ᵢⱼ = { xᵢⱼ if j ∉ Iᵢ
{ v ∼ Pⱼ if j ∈ Iᵢ
Here x̃ᵢⱼ is the value of feature j in the corrupted version of the i-th row, and xᵢⱼ is its value in the original. The symbol ∉ indicates that j falls outside the selected subset Iᵢ, so the cell is retained. The symbol ∈ indicates membership in that subset. In the replacement case, v is the sampled value and ∼ Pⱼ means that it is drawn from the column’s empirical distribution Pⱼ. Each selected feature gets its own draw.
A shared donor row would define a different operation. It would preserve the relationship between the donor’s values in the selected columns, even as those values are attached to the retained cells of the recipient. The default rule only preserves the distribution of each replacement column individually. The paper compares those choices because a contrastive task can exploit patterns introduced by its construction. Matching could depend on interactions between retained and inserted values, on how many original entries survive, or on features that the corruption seldom makes ambiguous.
Passing both views through shared networks
SCARF uses an encoder f to turn a row into a vector. A pretraining head g takes that vector and produces the output used in the matching task. The original and corrupted rows follow the same path through both networks. There is a single set of encoder parameters and a single set of head parameters. Improvements to either component can affect the representation of both views.
(zᵢ, z̃ᵢ) = (g(f(xᵢ)), g(f(x̃ᵢ)))
Here xᵢ is the original row at batch position i, and x̃ᵢ is its corrupted view. The function f is the shared encoder and g is the shared pretraining head. The outputs for the original and corrupted rows are zᵢ and z̃ᵢ, respectively. Parentheses show that the encoder runs first and its output is passed to the head. The ordered pair collects the two outputs for the same source row.
The pretraining head normalizes its outputs by their Euclidean length. Normalized vectors lie on the unit hypersphere, the set of vectors with unit length in the output space. The network can change the directions of those vectors as it learns. Because their lengths are fixed, increasing a vector’s magnitude offers no way to make a pair more similar under the comparison that SCARF uses.
sᵢⱼ = (zᵢ · z̃ⱼ) / (‖zᵢ‖₂ · ‖z̃ⱼ‖₂)
Here sᵢⱼ is the cosine similarity between the embedding zᵢ of original row i and the embedding z̃ⱼ of the corrupted view of row j. The dot in the numerator is the vector dot product. The factors in the denominator are the Euclidean lengths of the two vectors, indicated by ‖ ‖₂. Dividing by their product makes the similarity depend on the angle between the vectors. The normalized outputs already have unit length, so their dot product gives the same comparison.
The authors compute these similarities for all original and corrupted views in a batch. If the originals index the rows of a matrix and the corrupted views index its columns, a matching pair appears on the diagonal. Each off-diagonal entry compares an original with a view made from another source row. The batch positions give the procedure this distinction for free. Even if a pair of different source rows has the same class label, their cross-comparison remains off the diagonal.
The clean original serves as the reference in the loss as written. Each such reference is compared with a set of corrupted candidates, among which there is a designated match. An original and its corrupted copy can be similar in absolute terms yet difficult to identify as a pair if several other copies are just as similar. The candidate set therefore matters alongside the geometry of the positive pair.
Learning to pick the matching view
The paper uses InfoNCE, a contrastive objective also used in Contrastive Predictive Coding. For each original row, the objective gives greater credit when the score of its own corrupted copy is high relative to the scores of the candidates. It aggregates this contribution over the original rows in a batch. The paper writes the denominator as an average of exponentiated scores.
Lcont = (1/N) · Σᵢ₌₁ᴺ [−log(exp(sᵢᵢ/τ) / ((1/N) · Σₖ₌₁ᴺ exp(sᵢₖ/τ)))]
Here Lcont is the contrastive loss, N is the number of rows in the batch, and i indexes original rows. The index k runs over the corresponding set of corrupted candidates. The score sᵢᵢ belongs to the matched pair, while sᵢₖ is the similarity to candidate k. The temperature τ scales the scores before exp takes their exponentials. The summation sign Σ adds the indicated terms over the index range. The factor 1/N outside the outer sum averages the losses of the original rows. The one inside the logarithm averages the exponentiated scores of the candidates. log is the natural logarithm, and its leading minus sign makes greater relative support for the positive pair correspond to a lower loss.
Replacing the inner average with a sum would shift the loss by a constant for a fixed batch size. The average in the paper’s expression leaves the gradients for the comparison unchanged relative to that version. Intuitively, if the matching copy and the other candidates have similar scores, the procedure has little evidence for the designated match. If the matching copy scores more highly, the relative term improves. Temperature controls how sharply differences between scores affect the comparison. Lower temperature gives high-scoring candidates more influence over the loss.
There are two ways to improve the comparison for any given original. Its corrupted counterpart can come to resemble it more closely in the output space, or other candidates can become less similar to it. Both pressures matter when the network parameters are shared. A representation that sends all rows to the same direction would make all views agree, but the matching candidate would then be indistinguishable from the others. The competing candidates make that solution unhelpful for the objective.
The general algorithm updates f and g by stochastic gradient optimization on successive batches. In the experiments the authors implement the updates with Adam, using a learning rate of 0.001. The batches are sampled and their corrupted examples are generated during training. Accordingly, a row can be encountered with different feature subsets or replacement values as training proceeds. The representation is exposed to a family of possible changes rather than being trained against a permanent altered counterpart for each row.
Choosing when to stop and switching to classification
The authors use a separate validation procedure to decide how long to pre-train. They cycle through the validation inputs and generate original and corrupted pairs with the training procedure. In their default setup this construction runs for 10 epochs. An epoch is a pass through the relevant data. Once the validation set of pairs has been built, it is held fixed. Changes in its loss can then be interpreted against the same comparison task throughout pretraining, even as the training batches continue to receive fresh corruptions.
They monitor validation InfoNCE, normally with an early-stopping patience of 3 and a cap of 1000 pretraining epochs. Patience allows an interval without improvement before training is stopped. The cap supplies an upper bound even if the validation criterion continues to improve. Pretraining uses the validation inputs and their constructed pairs without needing validation class labels for the matching task. The authors also describe a fixed pretraining schedule as possible, with the required duration depending on the dataset and network.
Once pretraining ends, the learned encoder moves into classification. The authors remove g and attach a new head, h, whose input is the encoder output. The classifier is trained on the task’s labeled examples with cross-entropy, a loss that penalizes assigning low probability to the observed class. Its training updates both h and f. The new head learns to make class predictions, and the encoder can adapt its row representation to the supervised task.
The separation between the heads defines what transfers. The contrastive output is useful for making comparisons during pretraining. The classifier consumes the earlier encoder representation, which has been shaped by those comparisons and remains trainable. Nothing in the matching procedure supplies the class names or determines which separation in the representation will best serve the classifier. That information arrives through the labeled examples.
In the experiments, the encoder and both heads use rectified linear units, described as ReLUs, and a hidden dimension of 256. The encoder has 4 layers. The pretraining head and classification head each have 2 layers. The usual batch size is 128 for both stages. SCARF’s default corruption rate is 0.6 and its default temperature is 1. The supervised stage uses the same validation split and early-stopping patience as pretraining, monitors classification error, and has a maximum of 200 epochs. Thus the two stages use different evidence to stop even though they share the dataset partition.
Experiments and results
The benchmark and its training conditions
The authors use OpenML-CC18, a curated collection of 72 real-world classification datasets. They exclude CIFAR10, Fashion-MNIST, and MNIST because their question concerns tables. The remaining 69 datasets make it possible to ask whether the procedure helps across a collection of tasks with different features and prediction problems. The repeated evaluation on each task also lets the authors distinguish a change that recurs over different splits from one that appears in a particular split.
Each trial uses a 70%/10%/20% division into training, validation, and test data. The division changes across trials, and competing methods use the same splits. The authors repeat each run 30 times with different splits. During training, validation guides early stopping. Test accuracy measures how frequently the resulting classifier assigns the correct class on the held-out test data. The paper reports per-dataset test accuracies averaged across the trials, along with summaries of comparisons across datasets.
Preprocessing includes removing any feature column that is entirely missing. For a categorical feature with some missing values, the authors use its most common category, computed over the full dataset. They use the mean to fill missing numeric values. Most numeric features are scaled by subtracting the column mean and dividing by its standard deviation, a procedure known as z-score scaling. The authors compare that default with other scaling choices and leave numeric features unscaled on datasets 4134, 28, and 1468, where the supervised control performed best without scaling.
The fully labeled experiment keeps the original labels for the training rows. The authors still run SCARF pretraining with the labels ignored, then use those labels for fine-tuning. This condition asks whether the initial matching task improves the final classifier even when supervised training can already use the labels of all the training examples.
In the limited-label experiment, 25% of training rows keep their labels and the remaining 75% are available as unlabeled inputs. The training split still contains those rows, so pretraining has access to their feature values. The condition separates a shortage of labels from a shortage of examples. Methods such as self-training and tri-training can also use the unlabeled portion, through their own procedures. The validation and test split sizes stay the same.
In the label-noise experiment, the authors select 30% of the training rows at random and assign each selected row a uniformly sampled class. The original class is eligible to be drawn, so 30% measures the rows selected for label replacement. The feature values are unaffected, and validation and test labels stay clean. SCARF pretraining can use the same inputs without using the unreliable labels. Fine-tuning then has to learn from the labels that the experiment has left in the training split.
What the baselines test
The plain supervised network serves as the control. It supplies a reference for asking what is gained by initializing the encoder through pretraining. The authors also add pretraining to other supervised procedures. That design helps distinguish a gain over a plain classifier from a gain that remains when a classifier already uses regularization, modified targets, or a method meant for a particular labeling problem.
The reconstruction baselines include a classical autoencoder, an autoencoder trained to denoise inputs with additive Gaussian noise, and an autoencoder that receives the same kind of corruption as SCARF. An autoencoder tries to reproduce the input through a learned representation. In these experiments the reconstruction head emits as many output values as the input has features, and the loss is mean squared reconstruction error. Comparing SCARF with the autoencoder that shares its corruption tests what changes when matching replaces reconstruction as the task used to train the encoder. The clean and Gaussian variants provide reference points for changing the corruption within reconstruction.
The discriminative SCARF baseline also uses the proposed replacement rule. Its pretraining head has a final linear projection, and its binary logistic loss teaches the network to tell original inputs from corrupted ones. The pretraining validation decision for this variant uses classification error, which the authors found slightly better than logistic loss for that purpose. This comparison tests whether the main benefits can be obtained by detecting that a row has been altered. It retains the corruption while removing the obligation to identify which original belongs with a particular corrupted view.
Other baselines modify supervised learning more directly. Label smoothing assigns some attention to classes beyond the observed target, with a smoothing weight of 0.1 in the paper. Standard dropout uses a rate of 0.04 on all layers in this comparison. Both can be combined with the learned starting point provided by SCARF. The authors include the approach described in Dropout.
The experiments also use mixup, with α set to 0.2. Mixup constructs training examples by blending inputs and their targets. Self-distillation instead trains an initial predictor on labeled examples, then uses its output probabilities as soft targets for a final training round on the labeled and unlabeled examples. Those probabilities provide a distribution over classes for each example. The authors relate this baseline to knowledge distillation.
For noisy labels, the authors include Deep k-NN and the bi-tempered loss. Deep k-NN enters the comparison as a method designed for label noise, with the number of neighbors k set to 50. The bi-tempered baseline changes the classification loss. The paper uses 5 iterations and temperature settings of 0.8 and 1.2 for its parameters t₁ and t₂. Adding pretraining to these configurations tests whether the initialization helps after a dedicated label-noise procedure has already been introduced.
For scarce labels, self-training starts with the labeled examples, learns a classifier, and adds predictions that pass a confidence threshold to the examples used as supervision. The paper uses a softmax prediction threshold of 0.75 and runs the process for 10 iterations before training the final classifier on the resulting set. A pseudo-label in this procedure is the predicted class assigned to an originally unlabeled input. The paper traces this approach in part to Yarowsky’s self-training work.
Tri-training uses bootstrap samples of the labeled data to initialize separate classifiers. Each classifier gets new pseudo-labeled examples when the other two agree on their class. The authors use the same hyper-parameters as for self-training. Pretraining can operate before this use of pseudo-labels because its task depends on row identities and feature values. These combinations examine two different ways an unlabeled row can influence training, through the representation and through an inferred class target.
Reading wins and gains across datasets
The authors summarize the benchmark in two ways. A win matrix counts how frequently a comparison yields a statistically significant victory or defeat for each method. Its entries are fractions with the wins as the numerator and the decisive comparisons as the denominator. An accuracy difference is decisive in this analysis when it passes Welch’s unequal-variance t-test at the paper’s threshold of 0.05. Datasets with a statistical tie are left out of the fraction for that pair.
Wᵢⱼ = (Σᵈ₌₁⁶⁹ 𝟙[method i beats method j on dataset d]) / (Σᵈ₌₁⁶⁹ (𝟙[method i beats method j on dataset d] + 𝟙[method i loses to method j on dataset d]))
Here Wᵢⱼ is the win-matrix entry for method i compared with method j, and d indexes the 69 OpenML-CC18 datasets used in the study. Σ adds the contributions from the indicated datasets. The indicator 𝟙 contributes one when the condition in its brackets holds and zero otherwise. A win or loss requires a statistically significant direction of difference in mean accuracy under the paper’s test. The plus sign in the denominator combines the comparisons decided in either direction.
Keeping the denominator visible gives the ratio context. The paper uses 0/1 and 0/69 to illustrate this for the benchmark. The first records a single decisive comparison, which was a loss. The second records a loss on every dataset and consequently conveys a very different pattern. The matrix also gives each method’s minimum win ratio across its comparisons. This is a measure of how it fared against its least favorable comparator under that reporting rule.
The other summary describes the size of the changes. The authors compute relative improvements in test accuracy over a reference and show their distribution across datasets with box plots. For this analysis they retain datasets where the comparison passes a threshold of 0.20. They explain that the more permissive threshold provides enough observations for the box plots of methods whose comparisons would otherwise be sparse. Their table of mean relative gains uses the same filter. A reported gain is therefore relative to the reference accuracy on the qualifying datasets for that comparison. Different pairings can qualify on different subsets of the benchmark.
The two summaries answer different questions. A win matrix can show that a method improves accuracy on many decisive comparisons even when the gains themselves are small. A mean relative gain gives a sense of effect size after filtering and can reflect a subset of tasks where the difference is especially pronounced. Per-dataset absolute accuracies show what happened on a named task across the trial splits without requiring either cross-dataset summary.
Fully labeled training
Across the fully labeled benchmark, the authors report improvements from the pretraining approaches over the plain control in the win matrix, with SCARF showing the strongest overall outcome. Its average relative accuracy gain over the control is 2.352%. The denoising autoencoder that receives the same input corruption is close in that particular comparison at 2.244%. Their proximity shows that reconstruction can also benefit from the replacement rule under full supervision. SCARF’s lead is clearer over the autoencoder using Gaussian noise, the autoencoder trained on clean inputs, and the original-versus-corrupted discriminator.
Pre-training gains over the control on OpenML-CC18 with fully labeled training
SCARF gives the largest filtered mean relative gain, closely followed by reconstruction with the same corruption.
The numbers
| System or setting | Mean relative test accuracy gain % |
|---|---|
| SCARF (this paper) | 2.352 |
| Autoencoder with SCARF corruption | 2.244 |
| Autoencoder with additive noise | 1.559 |
| Autoencoder without noise | 1.107 |
| Discriminative SCARF | 0.574 |
The authors also measure what happens when the same pretraining is added to supervised baselines. SCARF adds a filtered mean relative test accuracy gain of 1.609% to dropout and 1.72% to mixup. The gain over label smoothing is 1.522%, and the gain over self-distillation is 2.392%. Each value compares a baseline with and without the added pretraining in the fully labeled setting. The authors interpret the improvements across these procedures as evidence that the pretraining contributes something beyond the behavior already induced by the supervised procedure. The experiments measure the added accuracy directly. The explanation in terms of different mechanisms remains an interpretation of that pattern.
An absolute result gives the gains a concrete scale. On Phonemes, dataset 1489, the trial-averaged test accuracy in the fully labeled condition is 85.25% for the control and 87.55% for SCARF. The autoencoder with the same corruption obtains 85.84%. The per-dataset numbers help show how a summary across the suite relates to the accuracies a practitioner would see when comparing fixed training procedures on one task.
Training with label replacements
The noisy-label comparison evaluates classification on clean test labels after supervised training on labels subject to random replacements. The authors report that SCARF improves the baselines collectively in this setting. Over the plain control, the filtered mean relative test accuracy gain is 2.261%. The corresponding gain is 1.988% for the autoencoder trained with the same corruption. The discriminator yields a negative mean relative change against the control in this condition, despite using the same procedure to generate its pretraining inputs.
Pre-training gains over the control on OpenML-CC18 with label replacement
SCARF gives the largest filtered mean relative gain, while discrimination between clean and corrupted rows trails the control.
The numbers
| System or setting | Mean relative test accuracy gain % |
|---|---|
| SCARF (this paper) | 2.261 |
| Autoencoder with SCARF corruption | 1.988 |
| Autoencoder with additive noise | 1.612 |
| Autoencoder without noise | 0.914 |
| Discriminative SCARF | -1.408 |
For the dedicated noisy-label methods, the filtered mean relative accuracy gain from adding SCARF is 2.001% over Deep k-NN and 2.68% over the bi-tempered baseline. The comparison with the autoencoder is worth reading by reference method. With the bi-tempered loss, the autoencoder with SCARF corruption gives a filtered relative gain of 2.915% in the same condition. That pairing is a case where the reconstruction variant has the larger mean gain. The broad advantage for SCARF concerns the overall pattern of comparisons and allows such exceptions.
On Phonemes, the control’s mean test accuracy is 83.29% in the label replacement condition, compared with 85.39% for SCARF. The autoencoder that uses SCARF corruption obtains 84.16%. The numbers describe the downstream classifier under unreliable training supervision. They leave open how individual corrupted labels affected its decisions. Pretraining had access to feature values throughout this experiment, and the benefit is measured after those representations have been adapted to the task.
Training with limited labels
When only 25% of training examples retain labels, the filtered mean relative gain over the supervised control is 3.692% for SCARF. The autoencoders can also use the unlabeled rows, so the comparison concerns what their pretraining objectives learn from them. Among the reconstruction approaches, the autoencoder using SCARF corruption has a gain of 1.702% over the control, and the one using additive noise has a gain of 1.662%. In this comparison, gaining access to the same inputs through reconstruction yields smaller improvements than gaining access through matching.
Pre-training gains over the control on OpenML-CC18 with limited labels
SCARF delivers the largest filtered mean relative gain when most training rows provide features alone.
The numbers
| System or setting | Mean relative test accuracy gain % |
|---|---|
| SCARF (this paper) | 3.692 |
| Autoencoder with SCARF corruption | 1.702 |
| Autoencoder with additive noise | 1.662 |
| Autoencoder without noise | 0.777 |
| Discriminative SCARF | 0.233 |
Adding SCARF to self-training gives a mean relative test accuracy gain of 3.839% on the datasets passing the filter. Adding it to tri-training gives 3.549%. Both baselines already exploit unlabeled inputs by proposing class targets. The improvement with pretraining shows that the unlabeled data can help through the learned encoder even when it also enters the training process through pseudo-labels. The study measures the result of combining the procedures, leaving the quality of intermediate pseudo-labels outside these reported comparisons.
The absolute accuracies vary across datasets. On Phonemes, the control obtains 81.95% and SCARF obtains 84.81% with limited labels. On dataset 50, SCARF obtains 79.2% and the control obtains 72.63%, but the same-corruption autoencoder reaches 86.85%. Those figures illustrate why the aggregate gains and the individual results belong together. A strong average for a pretraining objective leaves room for other choices to be better on a specific task.
The gradient-boosted tree comparison
The appendix also reports test accuracies for a gradient-boosted decision tree baseline using XGBoost. The authors use version 0.6 of the Python interface with a maximum depth of 3, 100 estimators, and a learning rate of 0.1. This comparison differs from the experiments that turn SCARF pretraining on or off within shared neural architectures. It gives a point of reference from a different family of tabular classifiers.
The per-dataset results include cases on both sides. In the fully labeled setting, SCARF obtains 95.75% on dataset 6, compared with 94.69% for the neural control and 88.01% for XGBoost. On dataset 1497, the same comparison gives 93.65% for SCARF, 88.73% for the control, and 99.69% for XGBoost. In the latter case the pretraining improves the neural classifier while the tree baseline still attains the higher accuracy. The paper’s central experimental question concerns the value added by SCARF within neural training. The tree results show why that question is distinct from choosing the best classifier for a particular table.
What the ablations show
Which changes make a useful view?
The corruption ablations hold the contrastive procedure fixed and replace the rule that produces the altered view. This keeps attention on what the encoder sees during pretraining. The comparisons include a view identical to the original, several rules that substitute or perturb a selected cell, and rules that preserve more structure among replacements. The appendix generally evaluates these choices with fully labeled, noiseless downstream training, so the accuracies measure how pretraining choices affect a common classification setting.
With no corruption, the positive pair consists of the same input passed through the same networks. Its cosine similarity is already at its maximum. The task can still reward distinguishing different examples by moving their outputs away from one another. The authors connect this case to a view of contrastive learning with two pressures. Alignment brings views of an example together. Uniformity spreads examples across the representation space. With identical views the first pressure has little work to do, and the authors suggest that the task may mainly encourage spreading examples over the hypersphere. Its weaker results indicate that the corruption contributes something beyond separating intact examples.
Replacing a feature with its column mean is another way to remove its original information. It inserts a constant for that column each time it is selected. Feature dropout replaces selected values with zero. The missing-feature variant assigns each column a learnable value to use when the procedure hides a particular entry. These options expose the encoder to a recurring substitute for each selected feature. Marginal sampling supplies a changing value taken from that feature’s observed distribution. For a column whose values vary widely, repeated corruption can therefore yield views with different observed values in that position.
The additive-noise alternative perturbs a value with an independent Gaussian draw. The paper specifies this noise as follows.
ε ∼ 𝒩(0, 0.5²)
Here ε is the perturbation added to a feature, ∼ means it is drawn from the indicated distribution, and 𝒩 denotes a Gaussian distribution. Its mean is 0 and its variance is given by the square of 0.5. The draws are independent and follow the same distribution. This rule defines an amount of noise in the units of the input it receives, so the effect of the same settings can change when the data are rescaled.
Joint sampling chooses a donor row and uses that row’s values in all the selected positions of the recipient. It keeps the donor’s internal relationships across those positions. SCARF samples the replacements from their columns independently. This comparison addresses a plausible reason to preserve more structure during corruption. A group of values copied together can form a more coherent fragment of a real row. The experiments favor separate marginal draws overall among the alternatives the authors test. They leave open which relationships within a particular table make one construction more useful than another.
What scaling changes
The authors study these corruption rules with different numeric feature scaling. Scaling changes the numerical values presented to the networks and, for some corruption rules, changes what a replacement means. In the following formulas, the prime marks a transformed value and avoids using the same symbol for the original input and its scaled version.
x′ⱼ = (xⱼ − mean(Xⱼ)) / std(Xⱼ)
Here x′ⱼ is the z-score-scaled version of the original feature value xⱼ in column j. Xⱼ denotes the observations for that column. mean(Xⱼ) is their arithmetic mean and std(Xⱼ) is their standard deviation. The numerator centers the value by subtracting the column mean, and the denominator expresses that centered value in units of standard deviation.
x′ⱼ = (xⱼ − min(Xⱼ)) / (max(Xⱼ) − min(Xⱼ))
Here x′ⱼ is the min-max-scaled value of xⱼ for column j, and Xⱼ contains that column’s observations. min(Xⱼ) and max(Xⱼ) are the smallest and largest observed values. The subtraction in the numerator measures the distance from the minimum. The subtraction in the denominator gives the range of the column.
x′ⱼ = (xⱼ − mean(Xⱼ)) / (max(Xⱼ) − min(Xⱼ))
Here x′ⱼ is the value after mean scaling, and xⱼ is its original value in column j. The function mean(Xⱼ) gives the arithmetic mean of the column observations, while max(Xⱼ) and min(Xⱼ) give their upper and lower endpoints. The transformation subtracts the mean and divides by the range.
Marginal replacement generally performs better than the alternatives under z-score and min-max scaling, and it remains competitive under mean scaling. The authors point out that a sampled value can be expressed in whichever units the feature currently uses. If the column is rescaled, the possible replacements rescale with it. The noise distribution in the Gaussian alternative has a fixed width in the chosen units. Rescaling the feature while leaving that width alone changes how large a perturbation is relative to the feature’s spread.
This property concerns the replacement operation. The neural network and the training process as a whole can still respond to the numerical scale of inputs. The ablation shows that the preference for marginal corruption held across the scaling choices investigated. It also reflects the specific alternatives as implemented. Most corruptions in this comparison operate on one-hot encoded inputs. SCARF samples categorical values before encoding. Thus the comparison takes into account the actual ways the rules handle feature representation as well as their effect on numeric columns.
How much information should the views share?
The authors try corrupting both views independently. This makes each branch see altered data, so any given pair can contain different retained columns on the two sides. Performance is better with the default of an original and a corrupted view. The authors suggest that at the 60% corruption rate used in this comparison, independently altering both sides leaves fewer positions that carry the same original information. The explanation fits the construction of the task. The experiment measures downstream accuracy, and the proposed change in shared information explains why making the matching problem harder can be counterproductive.
They also compare per-row selection of the corrupted positions with a selection shared across an entire mini-batch. The shared mask performs slightly worse. With an independently sampled mask for each row, the same feature can be helpful in recognizing one pair and unavailable in another. A mask shared across the batch produces the same pattern of intact feature positions for all the candidates. The measured difference favors varying the available evidence across examples in the matching task.
The fixed-size subset has a close alternative. The authors try choosing whether to corrupt each feature with a separate Bernoulli draw at probability c, ensuring that at least one feature is selected. The number of selected positions then varies from row to row. It performs about as well as the default that sets the number in advance. The result suggests that the exact choice between those two ways of controlling how many features get selected is less consequential in these experiments than some other aspects of the view construction.
A further variant draws one donor example for the whole mini-batch and uses its entries wherever replacements are needed. This is a stronger sharing of replacement information than sampling a donor independently for each row. The crossed views then repeatedly expose the encoder to values from the same donor during a matching comparison. That version performs worse. Together with the shared-mask result, it favors a construction that varies the corruption across the examples the network must distinguish.
Batch size, corruption rate, and temperature
Batch size controls how many candidates the matching task presents. Enlarging the batch gives each original row more negative comparisons. The authors had reason to test this because earlier contrastive work found benefits from large batches. In SCARF’s tabular experiments, increasing the batch size past 128 yields no significant improvement. They suggest that tasks with more difficulty or networks with more capacity might gain more from additional negatives. The measured result concerns the configurations used here.
Changing the corruption rate changes how much of the original row is available to recognize a match. The authors find fairly stable downstream performance from 50% to 80% in the tested setting and recommend 60% as the default. This is consistent with a task that can tolerate substantial variation in the number of altered features while keeping one clean view. The comparison with corrupting both sides shows why the rate needs to be interpreted together with the way the two views are constructed.
Temperature changes how strongly the contrastive loss responds to differences in cosine similarity. The authors find the tested procedure relatively stable with respect to that setting. A temperature of 1 works well and is their default. It leaves the cosine similarities at their original scale before they are exponentiated. It’s useful to consider the two tests together because each shapes how candidates compete: batch size determines how many candidates are in the running, and temperature controls how much their score differences matter.
Whether the objective and its timing matter
The authors replace InfoNCE with Barlow Twins and with a loss combining alignment and uniformity. Barlow Twins performs similarly to InfoNCE in the reported comparison. The alignment and uniformity combination performs worse. The Barlow Twins run uses the paper’s hyper-parameter setting of 5e-3. The authors try different relative weights on alignment and uniformity, with equal weighting giving the strongest performance of the settings they study. That version still trails InfoNCE. These experiments show that other representation objectives can learn from the same views, with no improvement over the default in the reported setting.
The study also considers putting the contrastive objective into the same training stage as the supervised objective. In this setup, the classification and view-matching objectives are optimized together.
Lco-train = Lsupervised + λcont · Lcont
Here Lco-train is the objective for joint training, Lsupervised is the supervised classification loss, and Lcont is the InfoNCE loss defined for SCARF. The coefficient λcont controls the contribution of the contrastive term. The dot denotes multiplication, and the plus sign adds the resulting term to the classification objective.
Pretraining followed by supervised fine-tuning beats joint training across the range of contrastive weights the authors test. They also find an advantage for pretraining in the corresponding comparison with additive-noise autoencoders. The sequential procedure first lets the encoder improve on the input-derived task and then lets the class labels shape it. In joint training the encoder receives both signals at once, with the coefficient controlling their relative contributions. The findings favor the sequential schedule within the setups evaluated.
Using the corruption solely for data augmentation during supervised training performs considerably worse than SCARF pretraining. In that version, the altered row is supplied as input during classification training. The setup asks the network to learn a class from views that may have lost class-relevant values. SCARF’s matching stage instead uses the clean original as a reference and asks whether the altered view can be associated with it among other candidates. The comparison shows that the corruption by itself, when inserted into supervised training this way, gives a weaker result than using it to define the pretraining task.
Which validation signal to use
The paper compares validation InfoNCE with a discrete matching error. For each original, the discrete measure counts a mistake if the most similar corrupted candidate is an off-diagonal entry in the similarity matrix. It treats a narrowly correct choice and a confidently correct choice the same way. The loss remains sensitive to changes in the positive score relative to the other candidate scores. Early stopping based on the loss yields better downstream accuracy in the authors’ comparison.
The Phonemes curves for dataset 1489 illustrate how the monitored losses behave. Both training and validation loss drop quickly at first and then decrease more slowly. The training curve fluctuates more because its corruptions keep changing. The fixed validation pairs give a smoother record. This example clarifies what the authors are monitoring when they choose a stopping point. The ablation then evaluates the consequence of that choice on the classification objective that follows.
Limitations
Limits the authors state
The authors flag the possibility that pretraining can reinforce biases present in the input data. The training signal depends on patterns in actual rows and on the observed values used for replacements. Learning to recognize those patterns can preserve regularities that are undesirable in a downstream application. The paper raises mitigation during training as a direction for future research. Its reported outcomes concern classification accuracy, so the potential bias is a concern identified by the authors whose size and consequences are outside their measurements.
The authors also qualify their conclusions about how long to pre-train and how much a larger batch might help. They tie pretraining duration to the network and dataset, which motivates their use of validation loss. They offer network capacity and task difficulty as possible explanations for why a larger batch could behave differently in another experiment. The defaults come from the reported tabular setup, and the relative stability shown in the ablations is evidence for the ranges and conditions investigated there.
Limits of the experimental setup
The labels are scarce or unreliable in controlled ways. In the limited-label condition the training rows are still available and the experiment removes labels from the split. Real missing labels can be concentrated among hard cases or among examples with particular attributes. The design demonstrates how SCARF behaves at the tested availability of labels with the feature inputs still present. It does not measure the effects of a labeling process that systematically excludes types of rows, of a different test population, or of having very few examples of a class in the table at all.
The label-noise condition uses uniform class draws for randomly selected training rows, with clean validation and test labels. In practice, mislabeling can depend on the input features, occur largely between similar classes, or affect the validation data used to select a classifier. The reported improvement addresses the paper’s random replacement setup. A source of strongly patterned errors could change how fine-tuning uses the representation. The experiments also examine limited labels and noisy labels as separate settings, leaving their joint effect unmeasured.
The routine that handles missing data uses information beyond an individual training split for at least part of preprocessing. In particular, the categorical imputation value is computed over the full dataset. That can let held-out feature observations influence the prepared inputs even though held-out labels are reserved for their stated roles. The methods share the preprocessing, so the question is how well these comparisons transfer to a pipeline in which all imputation choices are fit on the training partition alone. The reported experiments do not estimate that sensitivity.
The use of significance filters matters when interpreting both headline metrics. Win ratios exclude comparisons judged to be ties, and the mean relative gains use a different statistical threshold to decide which datasets enter each average. A mean can reflect different datasets for different methods. The ratios also summarize significance a dataset at a time, so they do not directly give uncertainty for the entire benchmark-wide comparison. The absolute test accuracies provide a separate view. They display the variation across tasks that a single filtered mean can conceal.
The same design bounds claims about alternative methods. The same-corruption autoencoder isolates an important difference between matching and reconstruction, but a reconstruction head and a contrastive head have different output requirements and training signals. The comparison tests the specified mean squared error reconstruction procedure. It does not establish how every reconstruction objective would perform. Similarly, the paper describes VIME’s fuller semisupervised procedure and its fixed encoder separately. A comparison against an autoencoder with matched corruption cannot stand in for an evaluation of that complete procedure.
SCARF’s marginal sampling can create a row whose values are individually observed and whose combination is implausible for the application. The matching objective tolerates such constructed examples by design. The appendix compares independent replacements with some ways of reusing donor values, but it does not establish the integrity of every generated row or whether a particular augmentation preserves a downstream class. The reported results show that the constructed pairs are useful on average for the tested classification tasks. They cannot identify which original feature relationships are preserved in the encoder or how those relationships contribute to each improvement.
The appendix’s XGBoost comparisons use one specified configuration. They provide a reference from outside neural training, with individual datasets favoring different classifier families. The study consequently does not settle the relative performance of extensively tuned tree and neural approaches. Nor does it establish improvements for regression or other tasks that use table representations, since the outcome measured throughout is classification accuracy. Confidence in a neural classifier’s probabilities, subgroup performance, and behavior under deployment shifts remain outside that outcome.
There is also a cost distinction between reaching the end of fine-tuning and reaching the end of the full procedure. The appendix gives average fine-tuning epoch counts for the fully labeled setting. On Phonemes, for instance, the control uses 13.84 epochs and SCARF uses 12.52. The latter classifier has already undergone pretraining before those epochs are counted. Those figures therefore measure the duration of one training stage in epochs, with no estimate of the end-to-end time saved on that dataset. The authors report about one million CPU core hours for the experimental campaign as a whole. That describes the scale of the evaluation, including repeated runs and comparisons, rather than the cost of applying SCARF to a single table.
What came after
The subsequent use of SCARF is undocumented here. The paper closes with an open research question about reducing the risk that self-supervised representations reinforce biases already present in their inputs. It presents mitigation as a direction for research and leaves its effectiveness unresolved.
Cite
Cite as Dara Bahri, Heinrich Jiang, Yi Tay and Donald Metzler. 2021. SCARF: Self-Supervised Contrastive Learning using Random Feature Corruption. arXiv (Cornell University).
@misc{bahri2021scarf,
title = {{SCARF: Self-Supervised Contrastive Learning using Random Feature Corruption}},
author = {Dara Bahri, Heinrich Jiang, Yi Tay and Donald Metzler},
year = {2021},
doi = {10.48550/arxiv.2106.15147},
eprint = {2106.15147},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2106.15147}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/bahri-2021-scarf-self-supervised-contrastive-learning/