Skip to content

Commit 753b6f9

Browse files
committed
Add mini-nn: Neural Network from scratch in Rust with 84.3% Titanic accuracy
- Complete neural network implementation in pure Rust - Tensor operations: matrix multiply, transpose, slicing - Activation functions: ReLU, Sigmoid, Tanh, Softmax, LeakyReLU - Loss functions: MSE, CrossEntropy, BinaryCrossEntropy - Optimizers: SGD, Momentum, Adam - Dense layers with Xavier/He initialization - Demo binaries: XOR (100%), layers, regression, Titanic (84.3%) - Neural network animation with forward/backward propagation visualization - Updated main README with new sections
1 parent b976077 commit 753b6f9

32 files changed

+8603
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ conv2d-animation/node_modules/
66
node_modules/
77
.history/*
88
mini-diffusion/target/
9+
mini-nn/target/release/*

.vite/deps/_metadata.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"hash": "d5668004",
3+
"configHash": "ab8df261",
4+
"lockfileHash": "e3b0c442",
5+
"browserHash": "4dc060ee",
6+
"optimized": {},
7+
"chunks": {}
8+
}

.vite/deps/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ npm run dev
3333
- [Algorithms & Data Structures](#algorithms--data-structures)
3434
- [Information Theory](#information-theory)
3535
- [Mini Diffusion (Rust)](#mini-diffusion-rust-implementation)
36+
- [Mini-NN (Rust)](#mini-nn-rust-implementation)
37+
- [Neural Network Animation](#neural-network-animation)
3638

3739
---
3840

@@ -971,6 +973,72 @@ See [mini-diffusion/README.md](mini-diffusion/README.md) for full documentation.
971973

972974
---
973975

976+
## Mini-NN (Rust Implementation)
977+
978+
A complete neural network implementation in pure Rust, built from first principles. No ML frameworks - just linear algebra with `ndarray`.
979+
980+
### 🏆 Results
981+
982+
Tested on the **Titanic Survival Prediction** dataset:
983+
984+
| Method | Accuracy |
985+
|--------|----------|
986+
| Logistic Regression | ~77% |
987+
| Random Forest | ~78% |
988+
| Gradient Boosting | ~80% |
989+
| sklearn Neural Network | ~79% |
990+
| Top Kaggle Submissions | ~83% |
991+
| **Our Mini-NN** | **84.3%**|
992+
993+
### Features
994+
995+
| Component | Description | Status |
996+
|-----------|-------------|--------|
997+
| Tensor Ops | Matrix multiply, transpose, slicing | ✅ Working |
998+
| Activations | ReLU, Sigmoid, Tanh, Softmax, LeakyReLU | ✅ Working |
999+
| Loss Functions | MSE, CrossEntropy, BinaryCrossEntropy | ✅ Working |
1000+
| Optimizers | SGD, Momentum, Adam | ✅ Working |
1001+
| Layers | Dense with Xavier/He init | ✅ Working |
1002+
| Training | Mini-batch, early stopping | ✅ Working |
1003+
1004+
### Quick Start
1005+
1006+
```bash
1007+
cd mini-nn
1008+
1009+
# Build
1010+
cargo build --release
1011+
1012+
# Run demos
1013+
cargo run --bin demo_xor --release # XOR problem (100% accuracy)
1014+
cargo run --bin demo_layers --release # Educational forward pass
1015+
cargo run --bin train_titanic --release # Titanic benchmark (84.3%)
1016+
```
1017+
1018+
See [mini-nn/README.md](mini-nn/README.md) for full documentation.
1019+
1020+
---
1021+
1022+
## Neural Network Animation
1023+
1024+
Interactive visualization of forward and backward propagation through a neural network.
1025+
1026+
![Neural Network Animation](screenshots/neural-network-animation.png)
1027+
1028+
- **Visualizes:** Forward propagation, backpropagation, gradient descent
1029+
- **Features:**
1030+
- Step-by-step forward pass with activation values
1031+
- Backward propagation with gradient visualization
1032+
- XOR problem demonstration
1033+
- Weight update visualization
1034+
- Mathematical formulas displayed
1035+
1036+
```bash
1037+
cd neural-network-animation && npm install && npm run dev
1038+
```
1039+
1040+
---
1041+
9741042
## Technologies Used
9751043

9761044
- **React**: UI and state management

0 commit comments

Comments
 (0)