o
odin.langpkg.dev
packages / library / odin-ML

odin-ML

dfbdbfflibrary

Exploring Machine Learning at a low level. Implementing algorithms from scratch in Odin, one Sunday at a time.

No license ยท updated 10 months ago

Odin-ML ๐Ÿง โšก

Machine Learning from scratch in Odin.
This is a personal side project I work on Sundays only while pursuing my MSc in AI.

The goal:

  • Learn ML internals by implementing algorithms from the ground up
  • Explore Odin as a low-level systems language for numerical computing
  • Document the journey for others who want to go beyond Python/NumPy
  • Explore both supervised and unsupervised learning algorithms over time

Roadmap

Month 1: Foundations

  • Vector type + basic ops (add, sub, scalar mul, dot product)
  • Matrix type + basic ops (add, mul, transpose)
  • Small numeric tests

Month 2: Linear Regression

  • Implement y = Wx + b
  • Mean Squared Error loss
  • Gradient Descent optimizer
  • Train/test on toy dataset

Month 3: Logistic Regression

  • Sigmoid activation
  • Binary classification
  • Cross-entropy loss

Month 4: Softmax Regression

  • Softmax function
  • Multi-class classification

Month 5: Neural Networks

  • Feedforward (1 hidden layer)
  • Backpropagation
  • Train on XOR

Month 6: Optimization & Performance

  • Momentum optimizer
  • Mini-batch training
  • Matrix multiplication optimizations

Month 7โ€“8: Real Dataset Experiments

  • CSV loader
  • Multilayer perceptron (MLP)
  • MNIST (or subset)

Project Structure

odin-ml/
โ”œโ”€โ”€ main.odin           # entry point (demo runner)
โ”œโ”€โ”€ core/               # basic building blocks
โ”‚   โ”œโ”€โ”€ vector.odin
โ”‚   โ”œโ”€โ”€ matrix.odin
โ”‚   โ”œโ”€โ”€ math_utils.odin
โ”‚   โ””โ”€โ”€ notes.md
โ”œโ”€โ”€ models/             # ML algorithms
โ”‚   โ”œโ”€โ”€ linear_reg.odin
โ”‚   โ”œโ”€โ”€ logistic_reg.odin
โ”‚   โ”œโ”€โ”€ nn.odin
โ”‚   โ””โ”€โ”€ notes.md
โ”œโ”€โ”€ datasets/           # toy datasets & loaders
โ”‚   โ”œโ”€โ”€ csv_loader.odin
โ”‚   โ””โ”€โ”€ notes.md
โ”œโ”€โ”€ optim/              # optimization algorithms
โ”‚   โ”œโ”€โ”€ gradient_descent.odin
โ”‚   โ”œโ”€โ”€ momentum.odin
โ”‚   โ””โ”€โ”€ notes.md
โ””โ”€โ”€ tests/              # unit tests
    โ”œโ”€โ”€ test_matrix.odin
    โ””โ”€โ”€ notes.md

Each directory includes a notes.md file where I jot down design decisions, bugs, and future ideas for that module.


Running

Clone the repo and run:

odin run .

Notes

I only code on Sundays, so progress will be slow but steady.

The purpose is learning, not building a production-grade ML framework.

Expect bugs, incomplete features, and lots of iteration.

notes.md files track my thought process inside each module.

Why Odin?

I don't know ๐Ÿคท๐Ÿฟโ€โ™‚๏ธ

I just want to learn Odin

Rarely used in ML โ†’ great opportunity to explore.


Future Work

Beyond the roadmap above, I plan to explore:

  • Unsupervised learning algorithms (clustering, PCA, dimensionality reduction)
  • Reinforcement learning experiments
  • Small-scale neural network experiments beyond one hidden layer
  • Performance optimizations and possible GPU/parallelism exploration(Maybe I am overthinking but I am willing to explore this.)

License

MIT โ€“ free to use, learn from, and contribute.