๐Ÿง  ownsandbox ยท AI Builder Week 5-6
scikit-learn ยท Decision Trees

๐Ÿง  How AI Learns

Train a REAL classifier. See HOW it decides. Not magic โ€” maths.

0
Trained On
0%
Accuracy
0
Spam Found
0
Not Spam
๐Ÿ“š Training Data
The AI learns from these โ€” add your own!
๐Ÿ“Š Feature Importance
Which words trigger spam?
๐Ÿ“Š Confusion Matrix
Accuracy breakdown
๐Ÿ” Test the Classifier
Type any email โ€” AI classifies it live
๐Ÿฑ๐Ÿ• Describe an Animal โ€” AI Guesses
Move sliders โ€” prediction changes in real-time
๐Ÿง  How AI Decided
Decision path
๐Ÿ“Š Feature Weights
๐ŸŒณ Visual Decision Tree โ€” Spam Filter
See EXACTLY how an AI makes decisions step by step
๐Ÿงช Build Your Own Decision Tree
Answer questions โ€” get classified!
๐Ÿ“– How Machine Learning Works
Not magic. Maths + patterns + data.
1๏ธโƒฃ
Step 1: Collect Data โ€” Get 100 emails. Label each: SPAM or NOT SPAM. More data = smarter AI.
2๏ธโƒฃ
Step 2: Extract Features โ€” Turn text into NUMBERS. Count exclamation marks, "FREE", links, ALL CAPS. Each = a feature.
3๏ธโƒฃ
Step 3: Find Patterns โ€” Algorithm finds rules: "3+ exclamations AND 'FREE' = spam 95% of the time." Decision tree.
4๏ธโƒฃ
Step 4: Test It โ€” Give it UNSEEN emails. Correct answers = accuracy. 90% = 9 out of 10 right.
5๏ธโƒฃ
Step 5: Improve โ€” Add data, add features, try algorithms. 85% โ†’ 92% โ†’ 97%. That's learning.
๐Ÿ The Actual Code (10 lines!)
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split

# Load data
X = [[3,1,1,0], [0,0,0,1], ...]
y = ["spam", "ok", ...]

# Train
model = DecisionTreeClassifier()
model.fit(X_train, y_train)

# Predict
model.predict([[5,1,1,0]]) # โ†’ "spam"
๐Ÿ’ก
10 lines. That's all. The student imports scikit-learn, trains a model, and predicts. The library does the maths โ€” the student understands the LOGIC.