📖 Chapter 9 of 12 · AI for New Learner- Senior 1 · Class 9
Capstone Build-It Projects
Three deeper builds. Ship at least one before your final exam. Each capstone is a 4-8 hour weekend project: real Python, real data, a trained model, an honest evaluation, and a public GitHub link. Finish ONE and you will have done more practical AI than 80% of Indian college freshers.
Capstone 1 — Word Similarity Tool (Linear Algebra)
Take any 5 Hindi/English words. Find their word vectors using a small pre-trained Indian language model. Compute cosine similarity between every pair. Print the matrix. Find the most-similar and least-similar pairs, and compare to your intuition.
💻 CODE LAB word_similarity.py
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
model = SentenceTransformer(
'sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')
words = ['maa', 'mother', 'roti', 'bread', 'car']
vecs = model.encode(words)
sims = cosine_similarity(vecs)
for i, w1 in enumerate(words):
for j, w2 in enumerate(words):
if i < j:
print(w1, '<->', w2, ':', round(sims[i,j], 3))
Capstone 2 — Quiz AI with Calibration (Probability)
Write a program that asks the user 10 maths questions. For each, ask (a) their answer and (b) how confident they are (0-100%). At the end, compare confidence to accuracy: are they OVER- or UNDER-confident? That is exactly how engineers measure calibration — if you say ‘90% sure’ on 10 questions and get 9 right, you are well-calibrated.
💻 CODE LAB quiz_calibration.py
questions = [('5 x 7', 35), ('17 + 28', 45), ('100 / 4', 25)]
score = 0
total_confidence = 0
for q, correct in questions:
user_ans = int(input(q + ' = '))
conf = int(input('Confidence (0-100%)? '))
total_confidence += conf
if user_ans == correct:
score += 1
accuracy = (score / len(questions)) * 100
avg_conf = total_confidence / len(questions)
print('Accuracy:', accuracy, '% Avg confidence:', avg_conf, '%')
print('OVERCONFIDENT!' if avg_conf > accuracy else 'WELL-CALIBRATED.')
Capstone 3 — Real Indian Dataset Classifier (sklearn)
Pick a CSV from data.gov.in or Kaggle’s Indian datasets. Clean it with pandas. Pick ONE clear question. Train a Decision Tree. Evaluate on a held-out test set. Save the model to a .pkl file. Write a README. Push to GitHub.
💻 CODE LAB indian_classifier.py — load, clean, train, save
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
import joblib
# 1. LOAD
df = pd.read_csv('your_dataset.csv')
# 2. CLEAN
df = df.dropna() # drop missing rows
df = df[df.price < df.price.quantile(0.99)] # drop outliers
# 3. CHOOSE X (features) and y (label)
X = df[['feature1', 'feature2', 'feature3']]
y = df['target_column']
# 4. SPLIT 80/20
X_tr, X_te, y_tr, y_te = train_test_split(
X, y, test_size=0.2, random_state=42)
# 5. TRAIN
model = DecisionTreeClassifier(max_depth=5)
model.fit(X_tr, y_tr)
# 6. EVALUATE
print('Test accuracy:', model.score(X_te, y_te))
# 7. SAVE
joblib.dump(model, 'my_first_real_model.pkl')
print('Saved! Push to GitHub now.')
Ship checklist — tick before the final exam
Code runs without errors · README.md explains the problem in 3 sentences · train and test accuracy both reported · model saved as a .pkl file · pushed to a public GitHub repo · one friend or teacher has seen it.