r/learnmachinelearning • • 25d ago

Data leakage from preprocessing: the same workflow in the wrong order vs the right order (scikit-learn)

3 Upvotes

A common beginner trap that makes test scores look better than they should. Same workflow, two orders.

Wrong order

  1. Scale all the data (fit the scaler on everything)
  2. Split into train and test
  3. Train on train, evaluate on test
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split

scaler = StandardScaler().fit(X)          # sees the test rows too
X_scaled = scaler.transform(X)
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, random_state=0)

Right order

  1. Split into train and test
  2. Fit preprocessing on train only
  3. Apply it to test, train, evaluate
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LogisticRegression

X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

pipe = make_pipeline(StandardScaler(), LogisticRegression())
pipe.fit(X_train, y_train)      # scaler learns mean/std from train only
print(pipe.score(X_test, y_test))

What goes wrong in the first version: the mean and standard deviation used to scale the data were computed with the test rows included, so information about the test set reached the training process. The model is then evaluated on data that isn’t entirely unseen.

How big is the effect? For plain scaling, often small. For steps that learn more from the data, it can be large: feature selection, imputing missing values, target encoding, PCA, or removing outliers by statistics. I don’t have a number to give you, and it depends on the dataset.

Same idea in cross-validation: if you scale before cross_val_score, every fold’s validation data has influenced the scaler. Put the preprocessing inside the pipeline and pass the pipeline to cross_val_score, so each fold fits it on its own training part.

Other leaks of the same family:

  • Duplicate or near-duplicate rows on both sides of the split.
  • Splitting rows when the unit should be a person, patient or session (use grouped splits).
  • Time-ordered data split randomly, so the model sees the future (use time-based splits).
  • A feature that is derived from the label.

A quick sanity check: if a result looks too good, ask “what did the model get to see that it wouldn’t have at prediction time?”

How do you check for leakage in your own projects, and which one tripped you up first?


r/learnmachinelearning • • 25d ago

In AI, sometimes improving data preparation makes more of a difference than changing the model.

Thumbnail reddit.com
2 Upvotes

r/learnmachinelearning • • 24d ago

Discussion On an M4 Pro, the fastest Qwen2.5-Coder model passed fewer coding checks (Ollama, Q4_K_M)

1 Upvotes

I help run Agent Infra Guide, where we maintain a small, public local-LLM measurement set. One result from our October 19 tests surprised us: decode tokens/second alone were a poor guide to which model completed the coding checks.

Setup: Apple M4 Pro (12-core CPU, 16-core GPU, 24 GiB unified memory), macOS 15.5, Ollama, Qwen2.5-Coder in Q4_K_M, configured 4,096-token context, and one concurrent client. The exact Ollama version is saved with each run; versions differ across the broader measurement collection, so this is not a controlled claim about Ollama version effects.

Observed medians and checks

• 1.5B: 154.1 decode tokens/s; 5/15 coding task checks passed. • 3B: 37.3 decode tokens/s; 10/15 checks passed. • 7B: 23.1 decode tokens/s; 10/15 checks passed.

These are repeated executions of a small deterministic coding task set. The checks are not 15 independent measures of general programming ability, and three model sizes on one computer cannot establish a universal model ranking.

How we measured and what I would change: We kept the model artifact/quantization, configured context and single-client condition explicit; recorded decode speed alongside task outcomes; retained failed checks; and kept run-level metadata rather than displaying just the best number. For a better generalization study I would expand the task suite, vary prompt/context lengths, report per-task success and time to first token, and run repeatable paired comparisons with the exact runtime versions pinned.

Practical takeaway: If an agent needs to finish a coding task, optimize for successful completions under your time and memory budget, not just fast token generation. On these checks, the 3B was slower than 1.5B but passed more checks; the 7B didn't improve the pass count over 3B in this limited sample.

I also wouldn't equate sampled process RSS on Apple silicon with dedicated GPU VRAM: it is unified memory, and brief peaks can be missed between samples.

Has anyone tested whether this throughput-vs-task-success tradeoff persists on larger, repeatable coding suites or with a longer context? I'd be interested in failure types as well as speeds.

Disclosure: I represent Agent Infra Guide. These are our measurements, not an independent third-party evaluation. No sales or affiliate links in this post. This write-up was prepared with AI drafting assistance and checked against the recorded figures.


r/learnmachinelearning • • 24d ago

Tutorial 8 beginner ML projects that teach more than another MNIST classifier

0 Upvotes

r/learnmachinelearning • • 24d ago

What's One Repetitive Task You Would Automate With AI?

0 Upvotes

I'm a web designer, and one of the most repetitive things in my business is finding new clients.

So naturally, email outreach was one of the first things I wanted to automate.

But not just regular cold email where you send the same template to thousands of businesses.

I use Swokei to find businesses with websites, analyze them for issues with design, SEO, speed, and mobile optimization, and turn those findings into personalized, ready-to-send outreach emails.

This way, I'm not just sending random offers. I'm reaching out with something relevant to each business while automating most of the research and writing process.

It's made it much easier to keep outreach running consistently without spending hours researching prospects manually.

What about you? What's one repetitive task you've automated with AI?


r/learnmachinelearning • • 25d ago

Data augmentation question. How do I characterise an original and augmented datasets where the augmentation parameters were zoom and crop? [P]

Thumbnail reddit.com
1 Upvotes

r/learnmachinelearning • • 24d ago

Request Brazilian Court Sanctions Lawyers for Prompt Injection in Court Filing

0 Upvotes

Brazilian court sanctioned attorneys after a prompt injection embedded in a court filing reached the judge and the AI model executed the injected instruction. The output was submitted without any interception or review. The court determined the lawyers were responsible for what their AI produced.

This is not a model failure. The model did exactly what the input instructed it to do. The failure is that no verification step existed between generation and submission.

Courts, regulators, and auditors are now scrutinizing AI-produced documents more aggressively than the teams producing them. A single injected payload in a document your AI processed can become the exhibit in a sanctions proceeding against you.

Every team using AI to draft filings, summarize discovery, or generate any document destined for a regulated recipient is exposed to this exact scenario today.

How are practitioners in legal, compliance, or regulated industries actually handling output verification before AI-generated content leaves their systems? Are there workflow checkpoints that have held up under scrutiny, or is most of the field still relying on human review alone?


r/learnmachinelearning • • 25d ago

Help Has anyone done minimal-edit preference construction in LLM finetuning?

1 Upvotes

What I mean: instead of finetuning an LLM on the correct answers, we could take the initial model answers, and then generate (possibly, but not necessarily, with another LLM) the answers that have as much as possible of original answer text but are fixed in the key points using correct answer as reference.

Hypothesis is this would cause model to actually learn the difference, not the style of the correct answers, cause less distributional shift.

If you have tried this, has it proven useful?


r/learnmachinelearning • • 25d ago

Need a good editor urgently, $130-$250+ per video

Thumbnail reddit.com
0 Upvotes

r/learnmachinelearning • • 26d ago

Xgboost tree implemented is completed rest remain

Thumbnail
gallery
124 Upvotes

20% of XGboost is completed yesterday also I code today also and I'm getting pretty close and things were really really not easy a lot bugs, a lot of errors yet I did it next step is to add more hyperparameters then use this my own xgboost implemented tree to build a complete Xgboost algorithm

Day 51 of Building Machine learning algorithms from scratch

Also I'm watching also One Piece


r/learnmachinelearning • • 25d ago

Which is the most competent and generous free tier LLM for non-agentic use? Aka everyday stuff

Thumbnail reddit.com
0 Upvotes

r/learnmachinelearning • • 25d ago

Beginner to Machine Learning. What roadmap should I follow? And how important is DSA?

Thumbnail reddit.com
1 Upvotes

r/learnmachinelearning • • 25d ago

How RAG stops LLM hallucinations: a simple technical cheat sheet for beginners

Thumbnail interconnectd.com
0 Upvotes

r/learnmachinelearning • • 25d ago

Question What made you want to start learning machine learning in the first place?

9 Upvotes

I'm curious what the spark was for people here. Was it a specific project, a job thing, or just seeing what AI tools can do lately? Also wondering how long it took before things started to click.


r/learnmachinelearning • • 25d ago

Help Is it worth learning LangChain and LangGraph in 2026?

Thumbnail reddit.com
1 Upvotes

r/learnmachinelearning • • 25d ago

Is it worth spending time on Quantum Machine Learning ?

Thumbnail reddit.com
2 Upvotes

r/learnmachinelearning • • 26d ago

Question Over 40 in tech in China and being quietly pushed out into a ‘banishment room’, what are my best moves here?

224 Upvotes

I work at a company in China, and they are currently trying to force me to quit on my own to avoid paying severance. They already cut my salary by 5%, and when they moved our headquarters from downtown to a suburban tech park, they left me completely alone at the old office. They told me if I want to transfer to the new headquarters, I have to take another 5% pay cut.

Honestly, I think it comes down to a few things: I'm over 40 (and ageism in the Chinese job market is brutal), I don't pick up new things as fast as the cheaper younger hires, and I'm not big on office politics or sucking up to my boss.

I'm really stressed out right now because I'm already sticking to a grueling evening routine studying English, data science, and machine learning. In this AI era, I don't even know what else I could possibly do to improve. Has anyone else dealt with this kind of isolation tactic? What would you do in my shoes?


r/learnmachinelearning • • 25d ago

Your CV score can be lying to you: 4 quiet leaks that inflated mine

0 Upvotes

My pipeline scored 0.979 CV AUC and 0.564 on holdout. CV never noticed.

Four ordinary columns caused it: an ID, a text date, a missing value, and a mis-coded category. The wildest part: removing the leak made the CV score drop.

I broke down each trap and the fixes here: https://towardsdatascience.com/my-machine-learning-pipeline-cheated-and-cross-validation-never-noticed/


r/learnmachinelearning • • 25d ago

Career Implementing ANN on GPUs

1 Upvotes

Hi,
There was a post a few years ago on a forum that I came across -

https://www.reddit.com/r/MachineLearning/comments/mx686k/p_torchpq_efficient_nearest_neighbor_search_and/

It seems really interesting. I was approached by professor who asked me if I am interested in implementing ANN on GPUs. I wanted to ask what are the possible career paths and what kind of jobs could I target with the skillset required to implement something similar to this. Thanks


r/learnmachinelearning • • 25d ago

Project Is it okay to share my experiments implementing research papers on my own LLM here?

6 Upvotes

Hey everyone!

I've built and trained a small LLM (~8M parameters) from scratch using PyTorch, mainly as an experimental lab where I can implement and test ideas from different research papers.

I've been documenting the whole journey through casual blogs, including my mistakes, experiments, and things I've learned.

So far:

Next up is KV caching, followed by PagedAttention, Orca, and whatever else I find interesting.

Just wanted to ask if sharing these experiments and blogs here would be welcome. Nothing promotional, just me experimenting, learning, and hopefully getting feedback from people who know more than I do.


r/learnmachinelearning • • 25d ago

Help im making my own llm(come follow the journey)

Thumbnail
reddit.com
1 Upvotes

r/learnmachinelearning • • 25d ago

Request Spooky New Infostealer Malware Uses AI to 'Autodox' Victims

2 Upvotes

A new infostealer called Volta embeds a local LLM directly inside the malware payload. The model analyzes harvested data in real time, scores each victim by estimated financial value, and reorders the extraction queue to hit the highest-value fields first. Account credentials, financial records, and personal identifiers get prioritized. This is not a blunt bulk-grab. It is a ranked, AI-optimized pull designed to maximize yield per target before any defender can respond.

The shift matters because most detection tools watch for volume anomalies. A targeted pull of the top 5% of fields by financial value produces a signal that looks nothing like a bulk exfil event on a SIEM. The malware is specifically calibrated to stay under those thresholds while extracting the records that cause the most damage.

For those working on data architecture or detection engineering: how are you adapting to low-volume, AI-ranked extraction attacks that deliberately avoid the anomaly thresholds most tooling is tuned for?


r/learnmachinelearning • • 25d ago

Project Full ML Algo Creator software. Python & PineScript AI Algo Generation.

Thumbnail gallery
1 Upvotes

r/learnmachinelearning • • 25d ago

Preventing model collapse in kinematic/LiDAR datasets through multimodal deterministic simulations

1 Upvotes

Hi everyone,

We evaluated the performance of autonomous navigation networks trained on standard statistical synthetic datasets. The conclusion is clear: recursive training loops lead to a strong degradation of performance in edge cases. Models become statistically insensitive to aerodynamic variables at high speeds.

To work around this problem, we designed a deterministic simulation pipeline. Instead of neural probabilities, it generates multimodal synthetic trajectory vectors using pure nonlinear drag mechanics and tunable atmospheric noise layers.

We have published the MVP and architecture layers as open source. I'm sharing the link to the web app simulator and the full code from the GitHub repository in the comments below.

Your feedback from AI/robotics architects is welcome!

Deep Learning #SyntheticData #AutonomousVehicles #ComputerVision #Robotics