> For the complete documentation index, see [llms.txt](https://flexecosystem.gitbook.io/flex-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flexecosystem.gitbook.io/flex-docs/protocol/flex-validator-nodes/sentinel-layer.md).

# Sentinel Layer

This layer utilizes machine learning and real-time analytics to monitor network health and optimize performance.

**Node health classification:**

Node health is now classified using a multi-factor model:

$$
H(v)=w
1
​
U(v)+w
2
​
P(v)+w
3
​
S(v)+w
4
​
N(v)
$$

*where:*

* U(v) is the uptime of validator v
* P(v) is the performance score of validator v
* S(v) is the stake of validator v
* N(v) is the network contribution of validator v
* w1, w2, w3 and w4 are weight coefficients

**Anomaly detection:**

This sentinel layer employs an Isolation Forest algorithm to detect anomalies in validator behavior:

```python
Copy codefrom sklearn.ensemble import IsolationForest

def detect_anomalies(validator_metrics):
    clf = IsolationForest(contamination=0.1, random_state=42)
    clf.fit(validator_metrics)
    return clf.predict(validator_metrics)
```

{% hint style="info" %}
We invite developers, researchers, and enthusiasts to work with our contributors for this section. [Start contributing here.](https://app.deform.cc/form/21842244-e1c1-479f-a8b3-3877903ecd44)&#x20;
{% endhint %}
