> For the complete documentation index, see [llms.txt](https://docs.animl.camera/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.animl.camera/fundamentals/automation-rules.md).

# Automation Rules

Help Animl help you

Before you can process images in Animl, you need to set the *Automation Rules* that you want them processed by. Users can configure specific actions (e.g. *request machine learning prediction or send email alert*) and what triggers the action (e.g. *new image added or new label assigned*).This allows users to chain together automation rules to create inference pipelines using multiple ML models.

For example, the most common pipeline users configure in Automation Rules is to chain together at least two rules:

* **Rule 1**: When a new image is added to Animl, request a machine learning prediction, from an object detection model (most commonly MegaDetector)
* **Rule 2**: When a new label is added to an image by the object detection model, and that label = “animal”, request an additional machine learning prediction, from a species classification model.

In layman's terms, this pipeline will look for anything in an image, if it thinks it found an animal, it will then try to classify the species.

{% hint style="info" %}
**NOTE:** Newly created *Automation Rules* will apply to all images added to your *Project* going forward. They do not apply retroactively to images that are already stored in your *Project*.
{% endhint %}

## How to add automation rules and create your inference pipeline

To configure a similar pipeline as above, follow the below steps or videos:

#### **Rule 1: Object Detection**

1. Click the "Configure automation rules" icon (it looks like a robot) on the left sidebar
2. Click New Rule
3. Fill out the required information
   1. Provide a name for the rule (e.g. "Request Megadetector prediction")
   2. Trigger: "Image added"
   3. Action: "Request machine learning prediction"
   4. Model: your preferred object detection model
4. Click Save

{% embed url="<https://www.youtube.com/watch?v=bsaJvreelfo&list=PLSprRV1-SBDc&index=1>" %}

#### **Rule 2: Species Classification**

1. Navigate back to the "Configure Automation Rules" modal if needed (the robot icon on the left sidebar)
2. Click New Rule
3. Fill out the required information
   1. Provide a name for the rule (e.g. "Request species prediction")
   2. Trigger: "Label added"
   3. Label: "animal"
   4. Action: "Request machine learning prediction"
   5. Model: your preferred species classification model
4. Click Save

{% embed url="<https://www.youtube.com/watch?v=OsOzxv1Fjow&list=PLSprRV1-SBDc&index=2>" %}

{% hint style="info" %}
If you are using a model that has taxonomic-aware labels – such as SpeciesNet - you can use a higher-order taxon (e.g., "rattus", "rodentia", or "mammalia") to trigger events when any of its descendants are detected.
{% endhint %}

### Setting Alerts

You can also set a rule to send an alert when a specific Label is assigned to an object (i.e. when a model predicts a specific species)

To do so follow the below steps:

1. Navigate back to the "Configure Automation Rules" modal if needed (the robot icon on the left sidebar)
2. Click New Rule
3. Fill out the required information
   1. Provide a name for the rule (e.g. “Send alert”)
   2. Trigger: “Label added”
   3. Label: the species you’re interested in
   4. Action: “Send alert”
   5. To: the email address you want the alert sent to
      1. You can add multiple emails here separated by commas

{% embed url="<https://www.youtube.com/watch?v=I79fKIrpNhA&list=PLSprRV1-SBDc&index=3>" %}

## Advanced Automation Rules

#### **Confidence Thresholds**

You have the ability to adjust the Confidence Thresholds used for each model in your Automation Rules. When a model makes a prediction, it applies a confidence score (0 - 100) to that prediction. Animl will then only save predictions that have confidence scores above your desired Confidence Threshold for that class.

Adjusting the threshold up means that you are raising the bar that must be cleared for Animl to assign a prediction to an object (i.e. reduce false positives). Adjusting it down means you are lowering that bar (i.e. reduce false negatives).

Some real life examples are if you notice missing detections of a certain species, you would want to lower the Confidence Threshold for that class to reduce false negatives.

If you are seeing a lot of sticks or rocks get falsely labeled as "animal", you would want to raise the Confidence Threshold to minimize false positives.

{% hint style="info" %}
Different models have different sensitivities, and everyone's data are unique, so getting confidence thresholds dialed in may require a bit of experimentation. The default confidence thresholds are just intended to be starting points, and the defaults may vary from model to model.
{% endhint %}

**To adjust the confidence thresholds:**

1. Click the “Configure automation rules” icon on the left sidebar
2. Click the pencil icon to edit your desired rule.
3. Find your desired label/class.
4. Adjust the confidence threshold.
5. Click Save

{% embed url="<https://www.youtube.com/watch?v=bclyoQnH5xw&list=PLSprRV1-SBDc&index=4>" %}

It's in this same area that you can also "disable" the model from predicting specific labels. This is useful in places you do not expect certain classes, such as disabling the "vehicle" class if you're not expecting any vehicles.

**To disable a certain prediction class:**

1. Click the “Configure automation rules” icon on the left sidebar
2. Click the pencil icon to edit your desired rule.
3. Find your desired label/class
4. Uncheck the checkbox next to it
5. Click Save

{% embed url="<https://www.youtube.com/watch?v=JEKuQWx5MdA&list=PLSprRV1-SBDc&index=5>" %}

{% hint style="info" %}
You can also search for classes and disable them or bulk change the confidence thresholds.

For example, you can search "rodentia", which will return all members of that class, then drop the confidence threshold down to be more sensitive to all rodents.
{% endhint %}
