Machine learning (ML) is a way of building software that learns patterns from data instead of following hand-written rules. Give it examples – emails labelled spam or not, houses with prices – and it learns a function that makes predictions on new data.
What You Will Learn
- Traditional programming vs ML
- Key terms: features, labels, model, training
- The three types of ML
- A complete first model in 6 lines
- Where ML is used
Rules vs Learning
| Traditional programming | Machine learning | |
|---|---|---|
| Input | Data + rules | Data + answers (examples) |
| Output | Answers | Rules (a model) |
| Example | if “lottery” in email: spam | Learn spam patterns from 10,000 labelled emails |
| Best for | Clear, stable logic | Fuzzy patterns: images, language, behaviour |
Key Terms
| Term | Meaning | House-price example |
|---|---|---|
| Feature (X) | Input variable | Area, bedrooms, location |
| Label / target (y) | Value to predict | Price |
| Model | Learned function from X to y | A fitted regression |
| Training | Fitting the model to data | model.fit(X, y) |
| Inference | Predicting on new data | model.predict(new_house) |
| Generalisation | Doing well on unseen data | Measured on a test set |
Your First Model
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25,
random_state=42, stratify=y)
model = DecisionTreeClassifier(max_depth=3, random_state=0).fit(X_train, y_train)
print(round(model.score(X_test, y_test), 3))
0.944
Explanation: The model learned rules from 426 tumour records and correctly classifies 94.4% of 143 records it has never seen. That is the whole ML workflow: data → split → fit → evaluate.
Types of Machine Learning
| Type | Learns from | Examples |
|---|---|---|
| Supervised | Labelled data | Spam detection, price prediction |
| Unsupervised | Unlabelled data | Customer segments, anomaly detection |
| Reinforcement | Rewards from actions | Game playing, robotics |
Details: Types of Machine Learning.
Where ML Is Used
- Recommendations (YouTube, Amazon)
- Fraud detection in UPI and card payments
- Medical image analysis
- Speech recognition and translation
- Demand forecasting and dynamic pricing
- Large language models like ChatGPT – see Generative AI
Series
ML fundamentals series: What is ML · Types of ML · Train/Test Split · Overfitting & Bias-Variance · Regularization · Confusion Matrix · ROC & AUC · Cross-Validation · Ensembles · DBSCAN
Interview Questions
Q: What is machine learning?
Algorithms that learn patterns from data to make predictions or decisions without being explicitly programmed with rules.
Q: Feature vs label?
Features are inputs; the label is the output the model learns to predict.
Practice Exercises
- Change max_depth to 1 and 10 and compare the test score.
- List three problems at your college or job that ML could solve and what the label would be.
Summary
ML learns a model from examples instead of hand-written rules. Split data, fit, evaluate on unseen data – and remember that data quality matters most.
Machine Learning Tutorials, Courses and Certifications