ML
## 1. Introduction & Machine Learning Basics## What is Machine Learning?
* Machine learning is a subset of Artificial Intelligence (AI).
* It allows computers to learn from data without being explicitly programmed.
* Tom Mitchell's Definition: A computer program learns from experience $E$, with respect to some class of tasks $T$ and performance measure $P$, if its performance at tasks in $T$, as measured by $P$, improves with experience $E$.
* Example: A spam filter learns from past emails ($E$), to flag spam ($T$), measured by accuracy ($P$).
## Designing a Learning System
Building an ML system follows a specific step-by-step pipeline:
1. Choose the Training Experience: Determine the type of data available (e.g., historical prices, labeled images).
2. Choose the Target Function: Define exactly what needs to be learned (e.g., a function $f: \text{house attributes} \rightarrow \text{price}$).
3. Choose a Representation: Decide how to represent the target function (e.g., a linear equation or a decision tree).
4. Choose a Learning Algorithm: Select the method that will adjust the system's weights or rules based on the training data.
## Perspectives and Issues in ML
* Data Quality: Models fail if data has noise, missing values, or bias.
* Scalability: Algorithms must handle growing amounts of data efficiently.
* Interpretability: Some models (like decision trees) are easy to explain, while others (like deep learning) act as "black boxes."
* Computational Cost: Training large models requires heavy processing power and time.
------------------------------
## 2. Types of Learning & Comparisons
Machine learning is split into four primary types based on how the algorithm learns.
┌───────────────────────────────┐
│ Types of Machine Learning │
└───────────────┬───────────────┘
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Supervised │ │ Unsupervised │ │ Reinforcement │
│ (Labeled Data) │ │ (Unlabeled Data) │ │(Reward/Penalty) │
└──────────────────┘ └──────────────────┘ └──────────────────┘
## Supervised Learning
* Concept: The algorithm learns from labeled training data (input-output pairs).
* Goal: Predict outcomes for new, unseen data.
* Subtypes:
* Regression (predicting a continuous number, like house prices).
* Classification (predicting a category, like "Spam" or "Not Spam").
## Unsupervised Learning
* Concept: The algorithm receives unlabeled data and must find hidden patterns or structures on its own.
* Goal: Group or compress data.
* Subtypes:
* Clustering (grouping similar items together, like customer segments).
* Dimensionality Reduction (simplifying data without losing key info).
## Ensemble Learning
* Concept: Strategically combining multiple ML models to solve a single problem.
* Goal: Improve prediction accuracy and reduce errors compared to a single model.
* Techniques: Bagging (e.g., Random Forests) and Boosting (e.g., Gradient Boosting).
## Reinforcement Learning
* Concept: An agent learns to make decisions by interacting with an environment.
* Goal: Maximize a cumulative reward over time through trial and error.
* Mechanism: The agent receives a positive reward for good actions and a penalty for bad actions (used in robotics and video games).
## Comparison Matrix
| Feature | Supervised Learning | Unsupervised Learning | Ensemble Learning | Reinforcement Learning |
|---|---|---|---|---|
| Data Input | Labeled data | Unlabeled data | Labeled or Unlabeled | No preset data (Environment) |
| Feedback | Direct (correct answers) | No feedback | Combined model outputs | Delayed (rewards/penalties) |
| Core Task | Predict target values | Discover hidden patterns | Boost accuracy of weak models | Learn a sequence of actions |
------------------------------
## 3. Foundational ML Concepts## Hypothesis Space and Inductive Bias
* Hypothesis Space ($H$): The set of all possible models or functions that the learning algorithm can choose from to solve the problem.
* Inductive Bias: The set of assumptions the learning algorithm uses to predict outputs for unseen data. Without bias, a model cannot generalize beyond the exact data it has already seen.
* Example: Linear regression assumes that the relationship between variables is a straight line. This assumption is its inductive bias.
## Overfitting
* Definition: Overfitting occurs when a model learns the training data too well, memorizing its noise and random fluctuations.
* Result: The model performs perfectly on training data but fails terribly on new, unseen test data.
* Fixes: Use more training data, simplify the model, or apply regularization techniques.
## Evaluation and Cross-Validation
To know if a model works, it must be evaluated on data it has never seen before.
* Train/Test Split: Splitting the dataset into two parts: a training set (e.g., 80%) to build the model, and a test set (e.g., 20%) to evaluate it.
* Cross-Validation (K-Fold): A robust method to evaluate model performance:
1. Split the dataset into $K$ equal parts (folds).
2. Train the model on $K-1$ folds and test it on the remaining 1 fold.
3. Repeat this process $K$ times so every fold acts as the test set exactly once.
4. Average the performance scores to get the final evaluation.
------------------------------
## 4. Core Algorithms of Unit 1## Linear Regression
* Purpose: Used to predict a continuous numerical value based on independent input features.
* How it works: It finds the "line of best fit" through the data points by minimizing the distance between the actual data points and the line.
* Equation: $Y = mX + c$ (where $Y$ is the output, $X$ is the input, $m$ is the slope/weight, and $c$ is the intercept).
## Decision Trees
* Purpose: Used for both classification and regression tasks.
* How it works: It breaks down a dataset into smaller subsets while building an associated tree structure. It looks like an upside-down tree with decision nodes and leaf nodes.
* Logic: At each node, the tree asks a "Yes/No" question about a feature (e.g., "Is income > $50k?"). It splits the data based on the answer until it reaches a final prediction at a leaf node.
* Risk: Unpruned decision trees are highly prone to overfitting because they can keep creating branches until they memorize every single data point.
------------------------------
## 5. Feature Engineering & Applications## Feature Engineering
Data in its raw form is rarely ready for an ML model. Feature engineering is the process of using domain knowledge to transform raw data into informative features that make ML algorithms work better.
* Imputation: Handling missing values by replacing them with the mean, median, or mode.
* One-Hot Encoding: Converting categorical text data (like "Red", "Green", "Blue") into numerical binary format ($0$ or $1$) so algorithms can process it.
* Feature Scaling: Normalizing or standardizing numerical features so they share a similar scale (e.g., bringing both "Age" [0–100] and "Salary" [0–100,000] into a range of 0 to 1).
* Feature Selection: Removing irrelevant or redundant features to simplify the model and reduce training time.
## Applications of Machine Learning
* Healthcare: Predicting diseases from medical scans, drug discovery.
* Finance: Fraud detection, credit scoring, algorithmic stock trading.
* E-commerce: Personalized product recommendation engines (like Amazon or Netflix).
* Autonomous Systems: Self-driving cars, route optimization in maps.
------------------------------
If you'd like to test your understanding, let me know:
* If you want a quick practice quiz on these specific concepts
* If you want to see the Python code for Linear Regression or a Decision Tree
Comments
Post a Comment