learning_path_2_intermediate.md
July 15, 2025 · View on GitHub
🏃♂️ AI4R Learning Path #2 – Intermediate Track
From “I can run a model” to “I can tune, extend, and build smart stuff that actually works.”
You’ve trained your first models, tweaked some clusters, maybe even backprop’ed a neural net. Nice.
Now it’s time to go deeper: tune ensembles, shape rewards, mess with distance functions, evolve a Sudoku solver—and crack open a Transformer like it’s no big deal. Let’s go.
🛠️ Prerequisites
- You’ve finished the Beginner Track (or already speak fluent
require 'ai4r') - You’ve cloned the repo and can run tests with
bundle exec rake - You’re cool with Git (or brave enough to fake it)
🌳 Module 1 – Forests, Boosting & the Art of Tuning
🧠 Learn: tree ensembles are overpowered—and totally tunable.
- Read through
random_forest.rbandgradient_boosting.rb. - Copy
compare_all.rbtoforest_vs_boost.rb. - Play with
num_trees,max_depth,learning_rate, etc. - Graph accuracy vs. hyperparameters—bonus points for pretty colors.
✅ You now understand:
- Why RandomForest works out of the box
- Why GradientBoosting can beat it—with tuning
🔬 Module 2 – Distance is a Choice, Not a Fact
🧠 Learn: the way your model measures similarity changes everything.
- Add
chebyshevtolib/ai4r/proximity.rb - Swap it into KMeans or DBSCAN in
kmeans_vs_dbscan.rb - Watch clusters shift dramatically—even though the data didn’t
✅ You now understand:
- How distance metrics control clustering
- That Euclidean isn't always right
🧬 Module 3 – Roll Your Own Genetic Algorithm
🧠 Learn: if you can encode a problem, you can evolve a solution.
- Peek at
tsp_chromosome.rb. - Build a new chromosome (e.g., 4x4 Sudoku)
- Plug it into the GA engine and evolve till solved
- Mutation rate too high? Watch it crash. Too low? It stalls.
✅ You now understand:
- Chromosome design = creative encoding
- Mutation & crossover = controlled chaos
🎮 Module 4 – Q-Learning, but Make It Smarter
🧠 Learn: shaping rewards teaches agents faster than yelling “wrong!”
- Start with the grid-world in
docs/reinforcement_learning.md - Add:
- Negative reward for each step
- Big bonus for early success
- Compare convergence speed (how many episodes to learn)
✅ You now understand:
- Rewards aren’t just feedback—they’re a strategy
- Agents learn what you incentivize, not what you want
🤖 Module 5 – A Tiny Transformer That You Can Actually Read
🧠 Learn: break down attention, multi-heads, and sequence scaling—line by line.
- Open
transformer.rb—yes, read the whole thing - Copy the inline example to
mini_transformer.rb - Tweak:
- Sequence length (10 vs 50)
- Head count (2 vs 4)
- Watch parameter count, runtime, and output patterns shift
✅ You now understand:
- Why attention is expensive
- What multi-head actually means in code
📊 Module 6 – Metrics That Matter
🧠 Learn: building your own metric is the most honest way to evaluate.
- Check out
bench/common/metrics.rb - Add a
balanced_accuracyorf_betafunction - Re-run a classifier bench and print your custom metric
- Push it to your fork—you’re officially contributing
✅ You now understand:
- Metrics shape how models are judged
- “Accuracy” alone isn’t enough
🏁 Capstone – Mix & Match Time
Pick a real dataset (UCI, Kaggle, or scrape your own). Then:
- Train a boosted classifier
- Cluster users or records
- Recommend an action policy using Q-Learning
- Tune, measure, iterate—then ship your notebook or
.rbfile
Document your decisions like this:
- What you’re solving
- What you tried
- What worked (and didn’t)
- What you learned
✅ You’ve combined multiple AI techniques into a single project. Boom.
🥈 You’ve Leveled Up
You now:
- Know how to tune tree-based models
- Customize core behavior (metrics, distances, fitness)
- Build your own problem encodings
- Understand RL reward design
- Actually get Transformers
- Can extend and contribute to AI4R itself
Next stop: Advanced Track — Hidden Markov Models, Monte Carlo Tree Search, custom benchmarks, and serious optimization.
Ready to break things?