> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/artificial-intelligence/machine-learning-ml.md).

# Machine Learning (ML)

**Machine Learning (ML)** is a subfield of Artificial Intelligence that focuses on developing algorithms and statistical models. This allows computer systems to learn patterns from data and make decisions or predictions without being explicitly programmed for each task.

In traditional programming, a developer writes fixed rules to solve a problem. In Machine Learning, instead of writing rules, we provide data to the system, and it automatically discovers patterns and relationships within that data.

***

### Types of Machine Learning

Traditional ML algorithms usually perform best on **structured/tabular data**.

Machine Learning is broadly classified into three main types:

1. Supervised Learning
2. Unsupervised Learning
3. Reinforcement Learning

***

## Supervised Learning

In **Supervised Learning**, the model is trained using **labeled data**, meaning each input has a corresponding correct output.

Supervised learning primarily solves two major types of problems:

1. Classification Problems
2. Regression Problems

### Classification Problems

In classification, the output variable is **categorical** (class labels).

#### Types of Classification

1. **Binary Classification**
2. **Multi-Class Classification**

#### Classification Algorithms

* Linear Classifiers
* Logistic Regression
* K-Nearest Neighbours (KNN)
* Support Vector Machine (SVM)
* Random Forest
* XGBoost

### Regression Problems

In regression, the output variable is **continuous (numerical value)**.

Example:

* Predicting house price
* Predicting temperature

#### Common Regression Algorithms

* Linear Regression
* Lasso Regression
* Multiple (Multivariate) Linear Regression
* Ridge Regression

***

## Unsupervised Learning

In **Unsupervised Learning**, the model works with **unlabeled data**. There is no predefined output. The goal is to discover hidden patterns or structures in the data.

Unsupervised learning mainly solves two major problems:

1. Clustering Problems
2. Association Problems

### Clustering Problems

Clustering involves grouping similar data points together.

The goal is to map unlabeled data into multiple clusters based on similarity.

**Types of Clustering**

1. **Partition-based Clustering**
2. **Hierarchical Clustering**
3. **Density-based Clustering**

### Association Problems

Association learning seeks to identify relationships among variables or entities in large datasets.

Example:

* Market basket analysis (Customers who buy bread often buy butter)

#### Common Unsupervised Algorithms

* K-Means
* Hierarchical Clustering
* DBSCAN
* Principal Component Analysis (PCA) (Used for dimensionality reduction)

***

## Reinforcement Learning

In **Reinforcement Learning**, an agent learns by interacting with an environment.

The agent:

* Takes an action
* Receives a reward or penalty
* Adjusts its behaviour to maximise total reward

It learns through trial and error, similar to training a dog:

* Correct action → Reward
* Wrong action → Penalty

#### Reinforcement Learning Algorithms

* Q-Learning
* Deep Q Networks (DQN)
* Policy Gradient Methods
* Proximal Policy Optimisation (PPO)

***

#### Reference:

* [https://www.ibm.com/think/topics/artificial-intelligence](<&#xA;&#xA;https://www.ibm.com/think/topics/artificial-intelligence&#xA;&#xA;https://www.youtube.com/watch?v=D1eL1EnxXXQ\&t=2286s>)
* [https://www.youtube.com/watch?v=D1eL1EnxXXQ\&t=2286s](<&#xA;&#xA;https://www.ibm.com/think/topics/artificial-intelligence&#xA;&#xA;https://www.youtube.com/watch?v=D1eL1EnxXXQ\&t=2286s>)
