1.1 Overview of Machine Learning
Machine learning is a subfield of artificial intelligence focused on models that learn from data to make predictions without being explicitly programmed for every case. It is used in healthcare, finance, marketing, autonomous systems, cybersecurity, education, agriculture, and entertainment.
Core idea: ML is one part of a broader data workflow that includes collecting, cleaning, transforming, modelling, and evaluating data.
1.2 Modeling
A model represents relationships between variables. In ML, the model learns those relationships from data and can improve as more data becomes available.
- Business model: profit from revenue and expenses.
- Recipe model: servings linked to ingredient quantities.
- Poker model: probability of winning based on revealed cards.
1.3 Types of Machine Learning
The guide separates machine learning by the nature of the available data and output.
SupervisedLabeled data: classification or regression
UnsupervisedNo labels: clusters or anomalies
ReinforcementRewards and penalties from an environment
1.4 Overfitting and Underfitting
Underfitting happens when a model is too simple to capture the real pattern. Overfitting happens when a model is so complex that it learns noise instead of the underlying pattern.
| Problem |
Training performance |
Unseen-data performance |
Typical fix |
| Underfitting |
Poor |
Poor |
Use richer features or a more flexible model. |
| Overfitting |
Very strong |
Poor |
Simplify, regularize, prune, or add more data. |
| Good generalization |
Strong enough |
Strong enough |
Balance complexity and error. |
1.5 Correctness
Correctness is not just accuracy. The guide uses the confusion matrix to separate prediction outcomes into true positives, false positives, false negatives, and true negatives.
- Precision: of the predicted positives, how many were correct?
- Recall: of the actual positives, how many were found?
- F1 score: harmonic mean that balances precision and recall.
Scenario logic: In medical diagnosis, high recall may matter most because false negatives are dangerous. In spam detection, high precision may matter because false positives can hide important mail.
1.6 The Bias-Variance Tradeoff
Bias is error from a model being too simple. Variance is error from a model being too sensitive to training-data fluctuations. A good model balances both so it generalizes to new data.
Reduce variance: simplify the model, increase training data, or use regularization such as L1/L2 penalties.
1.7 Feature Engineering
Feature extraction transforms raw data into usable numerical representations. Feature selection identifies the most relevant features so the model avoids unnecessary complexity.
- Extraction: text to vectors, image pixels or edges to numeric features.
- Selection: statistical filter methods, wrapper methods, recursive feature elimination, forward selection.
1.8 Real-World Applications
The guide lists ML uses in healthcare, finance, retail, transportation, manufacturing, cybersecurity, NLP, education, agriculture, and entertainment.
Memory hook: ML is valuable when large volumes of data can reveal patterns that improve prediction, automation, personalization, or anomaly detection.
1.9 Introduction to Python ML Libraries
The guide introduces NumPy for arrays and numerical computing, Pandas for DataFrame-based dataset work, Scikit-learn for ML models, and Matplotlib for visualizations.
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
df = pd.read_csv("iris.csv")
X = df.drop(columns=["species"])
y = df["species"]
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42
)
model = LogisticRegression()
model.fit(X_train, y_train)
print(model.score(X_test, y_test))