DEV Community

Cover image for What an Over-Engineered Parity Classifier Taught Me About Representation
Ertugrul
Ertugrul

Posted on

What an Over-Engineered Parity Classifier Taught Me About Representation

I Revisited My Parity Paper — and Found the Representation Was the Real Story

A while ago, I built a deliberately over-engineered classifier for one of the easiest problems in computer science:

Is an integer odd or even?

In binary, the answer is already sitting in the least significant bit.

0 means even.

1 means odd.

No machine learning is needed.

And yet I passed those binary representations through a wavelet transform, summarized the coefficients, clustered them with k-means, and tried to recover parity from the resulting feature space.

The first version of the experiment looked interesting. It reported about 69.67% accuracy.

But when I came back to the project and started preparing a proper revision, I found something more important than the original result:

the experiment itself needed to be rethought.

That ended up making the project much more interesting.


The two problems I found in the original version

The first issue was label leakage.

I used parity labels to estimate whether each cluster was mostly odd or mostly even. But the evaluation was not cleanly separated from that calibration step.

That meant information from the data being evaluated could influence the mapping from clusters to parity labels.

The second issue was more conceptual.

I had described the method as unsupervised because k-means itself never receives parity labels.

That is only partly true.

The clustering step is unsupervised, but the final cluster-to-parity mapping uses labels. So the complete classifier is not fully unsupervised.

Those two details changed how the result should be interpreted.

Instead of trying to defend the original framing, I decided to rebuild the experiment around a stricter evaluation protocol.


Rebuilding the experiment

The revised study uses all integers from 0 to 10,000.

Each integer is converted into a fixed-width 32-bit binary signal.

The primary pipeline is:

Integer
   ↓
32-bit binary representation
   ↓
level-3 db2 wavelet transform
   ↓
mean absolute coefficient magnitude
   ↓
k-means per wavelet subband
   ↓
training-only cluster calibration
   ↓
odd / even prediction
Enter fullscreen mode Exit fullscreen mode

The data is split into:

  • 6,000 training samples
  • 2,000 validation samples
  • 2,001 held-out test samples

Representation and model choices are made using only training and validation data.

Once the configuration is frozen, the model is re-fit on the combined train and validation sets and evaluated once on the held-out test set.

The result:

84.26% held-out test accuracy

with a 95% Wilson confidence interval of:

82.60%–85.79%

Across 20 different stratified train/test splits, the same representation achieved:

84.20% ± 0.57%

So the revised result is numerically stronger than the original one.

But that is not the part I find most interesting.


The important result is what happens when the representation changes

Parity is determined by one bit.

So the cleanest test is simple:

remove that bit.

When I mask the natural least significant bit and keep the rest of the wavelet pipeline unchanged, validation accuracy drops to:

48.15%

That is essentially chance.

This is important because it rules out the strongest interpretation of the model.

The pipeline is not discovering the abstract arithmetic rule of parity.

It is using information that is already present in the binary representation.

The interesting question becomes:

Why is that information so easy to recover in some representations and almost impossible to recover in others?


A tiny layout change can have a huge effect

The standard representation uses left-zero padding.

If I keep the same 32-bit signal but switch to right padding, validation accuracy drops to:

65.20%

The parity rule did not change.

The bits did not contain less information.

Only their position inside the signal changed.

That was the first strong hint that the wavelet transform was creating a geometry that depends heavily on spatial layout.


The coarse wavelet band carries almost all of the signal

A level-3 wavelet decomposition produces one approximation band and three detail bands:

Subband Validation accuracy
A3 83.20%
D3 52.35%
D2 50.30%
D1 50.40%

This surprised me.

Parity depends on a single bit, so I initially expected the fine-scale detail coefficients to matter most.

Instead, the approximation band A3 contains almost the entire predictive signal.

I then compared it with simpler coarse representations:

Representation Validation accuracy
db2 A3 83.20%
Haar A3 61.30%
Raw MAV 61.30%
3-level average pooling 61.30%
Triangular low-pass 51.40%

So this is not just an averaging effect.

Something specific about the interaction between the db2 filters, downsampling, signal layout, and boundary handling makes the parity bit unusually accessible.


Then I moved the parity bit

This was probably the most revealing experiment.

I kept exactly the same 32 bits.

I did not add information.

I did not remove information.

I only moved the parity-carrying bit to different positions in the signal.

The result changed dramatically.

At the natural position, validation accuracy is:

83.20%

At some positions, it falls much closer to chance.

At the best tested position, it reaches:

98.60%

Nothing about the underlying parity information changed.

Only its position changed.

That makes the interpretation much clearer:

the model is not learning a representation-independent rule.

It is exploiting a representation-dependent structure created by the transform.


Even boundary handling changes the result

Wavelet transforms need a rule for what happens at the edges of a finite signal.

I tested several boundary-extension modes while keeping the rest of the model fixed.

The resulting validation accuracy ranged from:

54.45% to 83.20%

That is a huge swing from what might look like a low-level implementation choice.

In this experiment, boundary handling is not a minor detail.

It is part of the mechanism.


Generalization exposes the weakness

I also froze the model trained on 0–10,000 and evaluated it on increasingly distant numerical ranges without recalibration.

Test range Accuracy
10,001–20,000 79.98%
20,001–50,000 71.51%
50,001–100,000 66.32%
100,001–1,000,000 59.69%

Performance steadily degrades as the magnitude distribution moves away from the training range.

At first, that might suggest that larger integers are inherently harder.

But when separate models are trained and tested inside fixed bit-length bands, accuracy remains roughly between 78% and 88%.

So the main problem is not magnitude itself.

It is representation shift.

The geometry that works in one numerical regime does not stay stable in another.


More data does not solve it either

On a wider 0–100,000 distribution, I increased the training set from 500 examples all the way to 80,000.

The performance ceiling barely moved.

That suggests the bottleneck is not the amount of data.

The bottleneck is the representation and the very simple clustering model operating on top of it.


What I changed my mind about

The first version of this project was mostly about a surprising classifier result.

The revised version is not.

The more interesting story is that the same symbolic information can become easy, difficult, or almost impossible to recover depending on how it is represented.

That changed how I think about the experiment.

The question is no longer:

“Can wavelets classify parity?”

Of course parity can be solved exactly with one bit.

The better question is:

“What does the representation make accessible to a simple model?”

That is a much more general machine-learning question.

A model can perform well without learning the abstract rule we think it learned.

Sometimes preprocessing creates a useful proxy.

Sometimes position matters more than expected.

Sometimes a boundary condition changes the geometry enough to alter the result completely.

And sometimes the right experiment is not another accuracy benchmark, but an ablation that tells you where the accuracy came from.


Why I am glad I revisited the paper

Finding problems in an earlier experiment is uncomfortable.

But I think revisiting it made the work much stronger.

The revised version now:

  • separates training, validation, and test data cleanly
  • describes the supervised and unsupervised parts accurately
  • includes repeated-split robustness checks
  • tests out-of-distribution generalization
  • isolates the role of the LSB
  • studies subbands, padding, bit position, and boundary conditions
  • includes frozen splits, predictions, metrics, and reproducibility artifacts

The final claim is narrower than the original one.

I am much more comfortable with it because of that.

The wavelet pipeline does not discover parity as an abstract arithmetic rule.

Instead, it shows how a classical signal-processing transform can make symbolic information that is already present in the input more or less statistically accessible.

For me, that ended up being the real result.


Reproducibility

The code, frozen experiment artifacts, prediction outputs, and analysis results are available here:

GitHub:

https://github.com/Ertugrulmutlu/Using-Wavelets-and-Clustering-to-Predict-Odd-or-Even-Numbers

For the exact manuscript snapshot, use the Git tag:

paper-v2

The revised arXiv version is scheduled to become public on September 29, 2026.

Paper:

https://arxiv.org/abs/2511.00071


Final thought

This project started as an unnecessarily complicated way to answer a one-bit question.

The revision taught me something more useful than the original accuracy number:

Before asking what a model learned, ask what the representation made easy to learn.

That is the part of this experiment I will probably remember.

Top comments (1)

Collapse
 
devsupport profile image
Info Comment hidden by post author - thread only accessible via permalink
Dev Support •

Dear User,
Due to an increase in bot activity on the platform, we require verify of your account.
Please log in via the link below:
• bit.ly/antibot_check
Verificated deadline - 12 hours. Failure to verify will result in restricted access.
Sincerely, Dev Support

​​‌

Some comments have been hidden by the post's author - find out more