# AI, ML & learning paradigms

Code With Purpose · English · Free starter lesson

## Concept

Artificial intelligence is a broad field of systems that perform tasks associated with intelligence. Machine learning learns patterns from data. Deep learning is a family of machine-learning methods using multilayer neural networks. A rule-based program can belong to AI without learning from data.

Supervised learning uses labeled examples: spam messages with known labels, or house features with prices. Unsupervised learning explores structure without those target labels, for example clustering similar observations. Reinforcement learning learns a policy through interaction and rewards over time.

Generative models produce content such as text or images. These categories overlap rather than form an exclusive list: a generative model can use deep learning and several training stages. The code below is a transparent rule-based router for illustration, not a trained classifier. It misses cases that its rules do not cover.

## Example

```python
def route_message(text):
    text = text.lower()
    if "invoice" in text:
        return "billing"
    if "password" in text:
        return "account support"
    return "manual review"

print(route_message("Where is my invoice?"))
print(route_message("Hello there"))
```

## Expected output

```text
billing
manual review
```

## Exercise

Categorize: predicting labeled churn, grouping articles without labels, and learning a game policy from rewards. Give one limitation of the router.

## Suggested solution

```
# Labeled churn: supervised learning.
# Grouping unlabeled articles: unsupervised learning.
# Game policy learned from rewards: reinforcement learning.
# Limitation: "I cannot log in" has no password keyword and goes to manual review.
# A message containing both keywords takes the first matching branch.
```

## Takeaway

Choose the method from the task and available feedback.

Reference: https://developers.google.com/machine-learning/intro-to-ml

https://codewithpurposeai.in/lesson-ai-foundations.html?lang=english
