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

# Machine Learning (ML)

## Theory

[Machine Learning](https://en.wikipedia.org/wiki/Machine_learning) is a subset of AI where systems learn patterns from data rather than being explicitly programmed with rules. \
ML algorithms learn from data by identifying patterns, trends, and anomalies through statistical techniques. This learned knowledge allows them to make predictions, classifications, or decisions when presented with new, unseen data.

ML is rapidly evolving and deeply integrated into security-critical systems. Unlike traditional software vulnerabilities, ML introduces attack vectors at the data level (poisoning), model level\
(adversarial examples), and output level (exploitation of generated content). Understanding how these systems learn helps you identify where and how to attack them.

ML can be categorized into three main types, each defined by the type of feedback available to the learning system:

#### Supervised learning

With [Supervised learning](https://en.wikipedia.org/wiki/Supervised_learning), the algorithm learns from **labeled data**, where each input is paired with its correct output. A "teacher" provides examples, and the model learns to map inputs to outputs.&#x20;

For instance, given thousands of images labeled "cat" or "dog," it learns distinguishing features (fur patterns, ear shapes, whiskers). When shown a new image, it predicts the label based on learned patterns.

Common applications:

* **Healthcare**: Disease diagnosis from medical scans
* **Cybersecurity**: Spam detection, malware classification
* **Finance**: Fraud detection, credit risk assessment
* **Computer Vision**: Image classification, facial recognition

#### Unsupervised learning

With [Unsupervised learning](https://en.wikipedia.org/wiki/Unsupervised_learning), the algorithm learns from **unlabeled data** without explicit guidance. It discovers hidden structure, patterns, and relationships independently.

Without predefined labels, the algorithm explores data to find natural groupings or reduce complexity. It can identify customer segments without being told what defines a segment, or detect\
anomalies by learning what "normal" looks like.

Common applications:

* **Marketing**: Customer segmentation, market basket analysis
* **Cybersecurity**: Anomaly detection, intrusion detection
* **Finance**: Fraud detection (identifying unusual patterns)
* **Data Science**: Dimensionality reduction, feature extraction

#### Reinforcement learning

With [Reinforcement learning](https://en.wikipedia.org/wiki/Reinforcement_learning), The algorithm learns through **trial and error** by interacting with an environment. It receives rewards for good actions and penalties for bad ones, learning to maximize cumulative rewards over time.

The system explores possible actions, observes outcomes, and adjusts its strategy. Like teaching a dog tricks with treats, it learns which actions lead to rewards. Through repeated interactions,\
it discovers optimal strategies for complex tasks.

Common applications:

* **Gaming**: AlphaGo, chess engines, Dota 2 bots
* **Robotics**: Manipulation, locomotion, warehouse automation
* **Transportation**: Autonomous driving, traffic optimization
* **Finance**: Algorithmic trading, dynamic pricing

### Deep Learning (DL) <a href="#deep-learning-dl" id="deep-learning-dl"></a>

Advances in the field of [deep learning](https://en.wikipedia.org/wiki/Deep_learning) have allowed [neural networks](https://en.wikipedia.org/wiki/Neural_network_\(machine_learning\)), a class of statistical algorithms, to surpass many previous machine learning approaches in performance.

These deep neural networks can automatically learn hierarchical representations from data. Instead of manually engineering features, the network discovers them through training, making them particularly powerful for tasks involving unstructured or high-dimensional data, such as images, audio, and text.

Key characteristics of DL include:

* `Hierarchical Feature Learning`: DL models can learn hierarchical data representations, where each layer captures increasingly abstract features. For example, lower layers might detect edges and textures in image recognition, while higher layers identify more complex structures like shapes and objects.
* `End-to-End Learning`: DL models can be trained end-to-end, meaning they can directly map raw input data to desired outputs without manual feature engineering.
* `Scalability`: DL models can scale well with large datasets and computational resources, making them suitable for big data applications.

Common types of neural networks used in DL include:

* `Convolutional Neural Networks` (`CNNs`): Specialized for image and video data, CNNs use convolutional layers to detect local patterns and spatial hierarchies.
* `Recurrent Neural Networks` (`RNNs`): Designed for sequential data like text and speech, RNNs have loops that allow information to persist across time steps.
* `Transformers`: A recent advancement in DL, transformers are particularly effective for natural language processing tasks. They leverage self-attention mechanisms to handle long-range dependencies.<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://red.infiltr8.io/ai-red-teaming/machine-learning-ml.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
