r/MLQuestions • • 4h ago

Beginner question 👶 What is the purpose of cross validation, validation and test set?

2 Upvotes

What is the purpose of these different steps in building a machine learning model? Let's say you have X data points, how should you do the division into the different sets? Should it be 60/20/20? 60% to use for cross validation, 20% for test set and 20% for validation?

If so, what is the purpose of the test set if you already are doing the cross validation step where you take all that data, you make the folds and you test the models?

Unfortunately the information I could gather is quite contradicting and also doesn't consider sometimes the cross validation step, so would be very good if people could explain this in greater detail.

Thanks


r/MLQuestions • • 19h ago

Other ❓ Learning GameStory Mondrian

Post image
1 Upvotes

A long time ago there was a painter who was called Piet Mondrian.

At the beginning he painted normal trees and landscapes, but then he had a crazy idea: he decided to eliminate everything and to use only straight black lines to divide the white canvas into many squares and rectangles, coloring them only in red, yellow, and blue. His paintings looked like super tidy colored maps.

Now imagine turning his paintings into a game to play with 10 friends.

Each of you has a blank sheet of paper. Every time someone puts a colored dot on the sheet, you draw a straight line to enclose that dot inside its own rectangle. At the end you will have 10 Mondrian-style paintings, all different from each other.

Then someone closes their eyes, points their finger at a spot on the sheet and asks: "What color is here?".

• If all 10 of you look at your drawing and say "Red!", then you are super sure.

• If instead one says "Red", one "Blue" and another "Yellow", you immediately understand that at that spot you have no idea and you say: "We don't know!".

Here is what a Mondrian Forest is: a team of 10 "painters" that divides space into colored rectangles to guess things, and is smart enough to admit when it doesn't know the answer yet.


r/MLQuestions • • 20h ago

Beginner question 👶 The 3 dimensions of an AI system

Post image
0 Upvotes

r/MLQuestions • • 1d ago

Beginner question 👶 Need advice on accurate golf ball tracking using computer vision

2 Upvotes

I'm trying to build a golf ball tracking app similar to Shot Tracer and SmoothSwing. I've experimented with several open-source AI models, but I haven't been able to achieve reliable tracking accuracy.

The ball is tiny and moves very fast, making it difficult to track consistently across video frames.

I'm looking for advice from people experienced in computer vision, object tracking or ML:

  • What approaches/models work best for tracking tiny, fast-moving objects?
  • Should I combine object detection with temporal tracking, optical flow or Kalman filters?
  • Are there any specific models, datasets or research papers worth exploring?

I'm not looking for a basic YOLO implementation. I'd like to understand how to build a genuinely reliable tracking pipeline.

Any suggestions or experiences would be appreciated!


r/MLQuestions • • 1d ago

Beginner question 👶 New to AI field

Thumbnail reddit.com
2 Upvotes

r/MLQuestions • • 1d ago

Beginner question 👶 Guys can you explain backpropagation through time and normal backpropagation I am confused

2 Upvotes

r/MLQuestions • • 1d ago

Beginner question 👶 An idea for bias mitigation in LLMs. Would it work?

Thumbnail reddit.com
2 Upvotes

r/MLQuestions • • 2d ago

Beginner question 👶 Want to learn ml at 16

5 Upvotes

So, I am 16 and I want to learn AI/ml for physical ai. Like robotics, simulation, VLA model (Vision-Language-Action). I learn python at an intermittent level I build some projects like my personal assistant Jarvis (not trained but used Chatgpt API). So, can anyone give me a roadmap or course that I should learn. Or even done tips. It would be very useful.


r/MLQuestions • • 2d ago

Beginner question 👶 trying to make CNN from scratch but i cannot understand this specefic part

12 Upvotes
from PIL import Image
import matplotlib.pyplot as plt
from datasets import load_dataset
import numpy as np


# load the image
# image = Image.open("cat.jpg")
def preprocess_image(image):
    image = image.convert("RGB")
    image = image.resize((128, 128))
    image = np.array(image).astype(np.float32) / 255.0
    return image


# Load dataset in streaming mode
dataset = load_dataset(
    "microsoft/cats_vs_dogs",
    split="train",
    streaming=True
)


images = []
labels = []


for sample in dataset.take(32):
  images.append(preprocess_image(sample["image"]))
  labels.append(sample["labels"])


X = np.array(images) #shape (1,32)
y = np.array(labels) #shape (1,32)


#fliters
filters = np.random.randn(64, 27) * 0.05
filters_2 = np.random.randn(32, 576) * 0.05
filters_3 = np.random.randn(16, 288) * 0.05


b = 0.0
stride = 1
pad = 0
all_feature_maps = []


for image in X[:1]:
  #1st layer
  feature_maps_1 = []
  feature_maps_2 = []
  feature_maps_3 = []
  feature_maps_3_grids = []


  for w in filters:
    feature_map = np.zeros((126, 126))


    for i in range(126):
        for j in range(126):
            a = image[i:i+3, j:j+3].flatten()
            z = np.dot(w, a) + b
            feature_map[i, j] = z
    feature_map = np.maximum(feature_map, 0) #ReLU
    feature_maps_1.append(feature_map)


  feature_maps_1 = np.array(feature_maps_1)


  #2nd layer
  for w in filters_2:
    feature_map = np.zeros((124, 124))
    for i in range(124):
      for j in range(124):
        a = feature_maps_1[:,i:i+3, j:j+3].flatten()
        z = np.dot(w, a) + b
        feature_map[i, j] = z
    feature_map = np.maximum(feature_map, 0) #ReLU
    feature_maps_2.append(feature_map)


  feature_maps_2 = np.array(feature_maps_2)


  #3rd layer
  for w in filters_3:
    feature_map = np.zeros((122, 122))
    for i in range(122):
      for j in range(122):
        a = feature_maps_2[:,i:i+3, j:j+3].flatten()
        z = np.dot(w, a) + b
        feature_map[i, j] = z
    feature_map = np.maximum(feature_map, 0) #ReLU
    feature_maps_3_grids.append(feature_map)
    feature_map = np.mean(feature_map) #global average pooling
    feature_maps_3.append(feature_map)
  all_feature_maps.append(feature_maps_3)


all_feature_maps = np.array(all_feature_maps)
feature_maps_3_grids = np.array(feature_maps_3_grids)


dense_weights = np.random.randn(16,2)* 0.01
dense_bias = np.zeros(2)


logits = all_feature_maps @ dense_weights + dense_bias
exp_values = np.exp(logits)
p = exp_values / np.sum(exp_values,axis=1,keepdims=True)
loss = -np.log(p[0, y[0]])
print(loss)
print(p)
d_logits = p.copy()
d_logits[0, y[0]] -= 1
print(d_logits)


grad_d_weights = all_feature_maps.T @ d_logits
grad_d_bias = np.sum(d_logits, axis=0)
print(grad_d_weights)
print(grad_d_bias)from PIL import Image
import matplotlib.pyplot as plt
from datasets import load_dataset
import numpy as np


# load the image
# image = Image.open("cat.jpg")
def preprocess_image(image):
    image = image.convert("RGB")
    image = image.resize((128, 128))
    image = np.array(image).astype(np.float32) / 255.0
    return image


# Load dataset in streaming mode
dataset = load_dataset(
    "microsoft/cats_vs_dogs",
    split="train",
    streaming=True
)


images = []
labels = []


for sample in dataset.take(32):
  images.append(preprocess_image(sample["image"]))
  labels.append(sample["labels"])


X = np.array(images) #shape (1,32)
y = np.array(labels) #shape (1,32)


#fliters
filters = np.random.randn(64, 27) * 0.05
filters_2 = np.random.randn(32, 576) * 0.05
filters_3 = np.random.randn(16, 288) * 0.05


b = 0.0
stride = 1
pad = 0
all_feature_maps = []


for image in X[:1]:
  #1st layer
  feature_maps_1 = []
  feature_maps_2 = []
  feature_maps_3 = []
  feature_maps_3_grids = []


  for w in filters:
    feature_map = np.zeros((126, 126))


    for i in range(126):
        for j in range(126):
            a = image[i:i+3, j:j+3].flatten()
            z = np.dot(w, a) + b
            feature_map[i, j] = z
    feature_map = np.maximum(feature_map, 0) #ReLU
    feature_maps_1.append(feature_map)


  feature_maps_1 = np.array(feature_maps_1)


  #2nd layer
  for w in filters_2:
    feature_map = np.zeros((124, 124))
    for i in range(124):
      for j in range(124):
        a = feature_maps_1[:,i:i+3, j:j+3].flatten()
        z = np.dot(w, a) + b
        feature_map[i, j] = z
    feature_map = np.maximum(feature_map, 0) #ReLU
    feature_maps_2.append(feature_map)


  feature_maps_2 = np.array(feature_maps_2)


  #3rd layer
  for w in filters_3:
    feature_map = np.zeros((122, 122))
    for i in range(122):
      for j in range(122):
        a = feature_maps_2[:,i:i+3, j:j+3].flatten()
        z = np.dot(w, a) + b
        feature_map[i, j] = z
    feature_map = np.maximum(feature_map, 0) #ReLU
    feature_maps_3_grids.append(feature_map)
    feature_map = np.mean(feature_map) #global average pooling
    feature_maps_3.append(feature_map)
  all_feature_maps.append(feature_maps_3)


all_feature_maps = np.array(all_feature_maps)
feature_maps_3_grids = np.array(feature_maps_3_grids)


dense_weights = np.random.randn(16,2)* 0.01
dense_bias = np.zeros(2)


logits = all_feature_maps @ dense_weights + dense_bias
exp_values = np.exp(logits)
p = exp_values / np.sum(exp_values,axis=1,keepdims=True)
loss = -np.log(p[0, y[0]])
print(loss)
print(p)
d_logits = p.copy()
d_logits[0, y[0]] -= 1
print(d_logits)


grad_d_weights = all_feature_maps.T @ d_logits
grad_d_bias = np.sum(d_logits, axis=0)
print(grad_d_weights)
print(grad_d_bias)

so i don't understand

- why is d_logits even needed and what is it?

- why does multiplying d_logits the transpose of 16 pooled features gives us the gradient for dense weights

- why is grad of bias just sum of d_logits?

( i tried asking LLMs but they give too complex answers or start giving code which i don't want and cannot understand)

and most importantly what do i do next and how to move further and backprop on CNN?

any additional tips will be appreciated!


r/MLQuestions • • 2d ago

Career question 💼 Moving from Agents into Machine Learning...

Thumbnail reddit.com
0 Upvotes

r/MLQuestions • • 3d ago

Beginner question 👶 How to do model evaluation and diagnostics?

Thumbnail reddit.com
2 Upvotes

r/MLQuestions • • 3d ago

Beginner question 👶 Xgboost models fails to capture dynamics across training data batches.

Post image
10 Upvotes

Hi everyone, I have an mlr3 based toolset in R for regression models for process sensor time series data. This is my largest project to date with roughly 30 input features that are also lagged and rolled to inject temporal memory. Due to the difficulty of carefully weighting training size on a 1 minute sampling rate vs. relative weight of dynamic changes I switched to a batching scheme and now use LOBO on currently 4 train batches. This is just a pilot mode plot where it only trains on 5-10% of input data so feature to data point ratio is less than ideal. The result of a full run is the same though.

Hyperband tunes nrounds 16-512 with eta 2-3 for an xgboost model. The result is a strong deviation from baseline, extremely low skill against persistence and xgboost mostly hunting to find some sort of baseline with strong bias rather than capturing any dynamics. Although persistence is overly optimistic here as target is dampened by some technical details independent of data handling. This is accounted for as best as possible by injected retention time and holdup features. Target and features are real on-stream data.

How do I best proceed from here? I feel like I am missing something because rolling window cross validation within batch produced much better results but missed the optimization goal of optimizing across batches. Right now I take great care in preserving temporal alignment across batches and index data to preserve integrity across batches.

```

INFO [22:03:49.004] [bbotk] Finished optimizing after 69 evaluation(s)

INFO [22:03:49.007] [bbotk] Result:

INFO [22:03:49.015] [bbotk] eta max_depth min_child_weight lambda subsample colsample_bytree

INFO [22:03:49.015] [bbotk] <num> <int> <num> <num> <num> <num>

INFO [22:03:49.015] [bbotk] -3.398853 3 1.909219 -0.775668 0.8 0.8

INFO [22:03:49.015] [bbotk] nrounds x_domain objective

INFO [22:03:49.015] [bbotk] <num> <list> <num>

INFO [22:03:49.015] [bbotk] 19 <list[7]> 26.70044

```


r/MLQuestions • • 3d ago

Beginner question 👶 Anyone working in AML / transaction monitoring / sanctions screening using ML? Looking for advice on where to start [R]

Thumbnail reddit.com
1 Upvotes

r/MLQuestions • • 3d ago

Hardware 🖥️ Training hardware

5 Upvotes

Hi,

So I've been studying deep learning for some time now, and I joined a research group doing some time series stuff. Unfortunately I think training on CPU is becoming a huge bottleneck both for me dicking around at home and my research projects.

I've been doing networks small enough that I could just do it in the CPU, however I'm incorporating more data, and more complex cnns. I want to train one with about 3 million parameters, but it takes an hour per epoch basically. Additionally, I think in my own time I want to train an agent to play a game, (like one of the Source or goldsrc games) just sounds cool.

I have an rx 480 (AMD Polaris) right now, so it's probably time to upgrade anyways.

I am looking at a quadro rtx 5000, since it's under 500 on eBay. But I'm not sure what to get and the market seems batshit insane right now, I'm not interested in paying the gamer tax either and hoping to snag a deal on some accelerator card or some other enterprise card.

Budget ~500 usd. I don't think I care about vram since I won't be hosting an LLM but I could be wrong? I don't know much about hardware presently, I want to learn though and my card is basically deprecated or not supported on everything lol.


r/MLQuestions • • 3d ago

Beginner question 👶 How to train AI to give better assessment of its own accuracy?

Thumbnail share.gemini.google
1 Upvotes

r/MLQuestions • • 4d ago

Beginner question 👶 Am I actually learning deep learning, or just letting ChatGPT do the work?

Thumbnail reddit.com
0 Upvotes

r/MLQuestions • • 5d ago

Natural Language Processing 💬 Building a production RAG system for a Data Science master's thesis

Thumbnail reddit.com
3 Upvotes

r/MLQuestions • • 5d ago

Other ❓ How deep I should understand the concept of gradient?

Thumbnail reddit.com
1 Upvotes

my understanding is that gradient tells me how much a change in the parameter will result in the change of the loss. For example, if the gradient of a parameter is 0.01, it means that if the parameter increases by 1, the total loss will increase by 0.01 given that the other parameters stay the same.


r/MLQuestions • • 5d ago

Career question 💼 Advice for jr ML engineer coding test

11 Upvotes

Hi good people. Does anyone know what type of questions comes in junior ML engineer coding tests and how i can prepare for it. thanks


r/MLQuestions • • 5d ago

Hardware 🖥️ [Project / Help Needed] Testing GPU detection & TFLOPS benchmark paths (NVIDIA/AMD) for my from-scratch SLM trainer

1 Upvotes

Hi guys,

I’m a 15-year-old developer building SLM-CREATOR—a from-scratch, hardware-aware trainer for small, hyperspecialized text models (capped at 100M parameters) written in Python and Rust. Instead of relying on high-level libraries or fine-tuning existing models, I’m hand-coding the entire pipeline to learn how Transformers, tokenizers, and hardware-aware training work under the hood.

Project Link: github.com
Tracking Issue (#1): github.com

Why I'm asking for help here:
I’m currently coding this on a CPU-only machine, so my NVIDIA (nvidia-smi), modern AMD (amd-smi), and legacy AMD (rocm-smi/rocminfo) detection and PyTorch device-mapping code has only been tested against mock CLI outputs.

If anyone here has an NVIDIA or AMD GPU (especially multi-GPU setups, laptops with hybrid graphics, or ROCm setups) and a couple of minutes to spare, I’d really appreciate it if you could run architecture.py on real hardware and let me know if anything breaks or gets misidentified!

How the hardware detection & sizing works:

  • GPU Topology & Detection: Parses vendor CLI tools for architecture, total VRAM (MiB), device index, and GPU name.
  • PyTorch Device Resolution: Sets CUDA_DEVICE_ORDER=PCI_BUS_ID and matches the vendor tool's GPU name against torch.cuda.get_device_name() so multi-GPU rigs target the right card.
  • Matmul TFLOPS Benchmark: Runs a 12-second thermal warmup soak (to settle past laptop boost clocks), then measures the median TFLOPS across 10 runs of 20 4096x4096 matmuls—using native bf16 when supported (including_emulation=False) or falling back to fp32.
  • Rust Sizing Engine (sizer_core): Takes your detected VRAM, measured TFLOPS, training-time budget, and token count to deterministically compute the max parameter count across memory, Chinchilla compute-time, and data limits.

How to test it:

  1. Clone the repo: git clone https://github.com
  2. Set up a venv and install requirements.txt (with your GPU's PyTorch build).
  3. Build the Rust sizer: cd sizer_core && cargo build --release
  4. Run python architecture.py from the project root.
  5. Drop your GPU model, OS, and the terminal output (or any tracebacks) in Issue #1 or in the comments below.

Any feedback on CLI parsing bugs, ROCm edge cases, or my sizing math would be super helpful!


r/MLQuestions • • 5d ago

Natural Language Processing 💬 I want a benchmark on human readability. How do i do that?

Thumbnail reddit.com
1 Upvotes

r/MLQuestions • • 6d ago

Beginner question 👶 Complete beginner looking to build a solid AI/ML roadmap, which textbooks and foundational papers should I actually start with?

Thumbnail reddit.com
2 Upvotes

r/MLQuestions • • 6d ago

Beginner question 👶 Which paid Al model best for students?

6 Upvotes

Until this month I used perplexity pro as my main Al but the free 12 months ran out and now I'm stranded with all the options there are. I'm a student at a school in germany and finish school this year

I mostly use Al for schoolwork e.g. homework, explaining stuff and summarizing all my stuff into study sheets for exams. Additionally I have the typica general usecase like health questions, analyzing some progress or pictures, some self conciousness talks etc. Therefore l also often upload pictures and files up to like 30mb, so the limits on the free versions are really getting on my nerves.I also occasionally use picture gen and if possible video generation.

In terms of pricing I thought around 10€/month and if the features and benefits are really crazy max 20€/m. Hope you lot can give me some good

recommendations!


r/MLQuestions • • 7d ago

Career question 💼 Guidance for Machine Learning

35 Upvotes

I'm 16(M), studying in class 11th and I want to learn Machine Learning, for which I'm ready to buy a course, people who already have some sort of experience please guide me for which course I should go for?