Step 11 of 15
Interactive Notebook 3: Machine Learning from Examples & Recommendations
Hands-on Python experiments discovering decision boundaries from labelled data and calculating nearest neighbor recommendations.
Welcome to Step 11! In Chapter 4, you explored the core paradigm shift of Machine Learning: instead of humans handcrafting rigid `if-else` instructions, computers learn decision boundaries from labelled data. This notebook lets you witness and control that exact learning process.
Learning Decision Boundaries from Labelled Examples
In Experiment 1, you give the computer a small dataset of numbers labelled `small` or `big` by a person. Notice that you do not program any threshold yourself.
The Python code calculates the group averages and finds the optimal decision boundary automatically. Try changing the training numbers to see how the learned boundary shifts in real time!
Nearest Neighbors (`k-NN`) Recommendation Engine
In Experiment 2, you build a practical Nearest Neighbors (`k-NN`) recommendation system tailored to agricultural needs.
Given the soil moisture and sunlight numbers of your field, the computer calculates Euclidean distances across traditional crop profiles (`Khejri pods`, `Bajra`, `Moong`, `Guar`) and recommends the exact neighbor whose requirements best match your soil.
How to Open and Run Notebook 3
There are two easy ways to run the notebook: on your own computer if Jupyter is installed, or free in the browser with Google Colab, where nothing needs to be installed. The steps for Google Colab:
- Download the notebook file with the button below.
- Open colab.research.google.com in your browser and sign in with a Google account.
- Click File, then Upload notebook, and choose the downloaded file loktech-notebook-1.ipynb.
- Read each text cell, and run each code cell by pressing the play button on its left (or Shift+Enter).
- Run the cells from top to bottom. Change the examples and run them again; nothing can break.
Download Notebook 3 - Machine Learning (.ipynb) Download Notebook 3 - Hindi (.ipynb) Open Google Colab ↗