sfr-pyrca


Namesfr-pyrca JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/salesforce/PyRCA
SummaryPyRCA: A Python library for Root Cause Analysis
upload_time2023-06-27 02:27:46
maintainer
docs_urlNone
authorSalesforce Research Warden AIOps
requires_python>=3.7,<4
license3-Clause BSD
keywords aiops rca root cause analysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyRCA: A Python library for Root Cause Analysis
<div align="center">
  <a href="#">
  <img src="https://img.shields.io/badge/Python-3.7, 3.8, 3.9-blue">
  </a>
  <a href="https://pypi.python.org/pypi/sfr-pyrca">
  <img alt="PyPI" src="https://img.shields.io/pypi/v/sfr-pyrca.svg"/>
  </a>
  <a href="https://opensource.salesforce.com/PyRCA/">
  <img alt="Documentation" src="https://github.com/salesforce/PyRCA/actions/workflows/docs.yml/badge.svg"/>
  </a>
  <a href="https://pepy.tech/project/sfr-pyrca">
  <img alt="Downloads" src="https://pepy.tech/badge/sfr-pyrca">
  </a>
  <a href="https://arxiv.org/abs/2306.11417">
  <img alt="DOI" src="https://zenodo.org/badge/DOI/10.48550/ARXIV.2306.11417.svg"/>
  </a>
</div>

## Table of Contents
1. [Introduction](#introduction)
2. [Installation](#installation)
3. [Getting Started](#getting-started)
4. [Documentation](https://opensource.salesforce.com/PyRCA/)
5. [Tutorial](https://github.com/salesforce/PyRCA/tree/main/examples)
6. [Example](#application-example)
7. [Benchmarks](#benchmarks)
8. [How to Contribute](#how-to-contribute)

## Introduction

The adoption of microservices architectures is growing at a rapid pace, making multi-service applications 
the standard paradigm in real-world IT applications. Typically, a multi-service application consists of 
hundreds of interacting services, making it increasingly challenging to detect service failures and identify 
their root causes. Root cause analysis (RCA) methods typically rely on KPI metrics, traces, or logs monitored 
on these services to determine the root causes when a system failure is detected. Such methods can aid 
engineers and SREs in the troubleshooting process.

PyRCA is a Python machine-learning library designed to facilitate root cause analysis by offering various 
state-of-the-art RCA algorithms and an end-to-end pipeline for building RCA solutions. At present, PyRCA 
primarily focuses on metric-based RCA, including two types of algorithms: (1) identifying anomalous metrics 
in parallel with the observed anomaly through metric data analysis, such as ε-diagnosis, and (2) identifying 
root causes based on a topology/causal graph representing the causal relationships between the observed 
metrics, such as Bayesian inference and Random Walk. PyRCA also provides a convenient tool for building 
causal graphs from the observed time series data and domain knowledge, enabling users to develop graph-based 
solutions quickly. Furthermore, PyRCA offers a benchmark for evaluating various RCA methods, which is 
valuable for industry and academic research.

The following list shows the supported RCA methods in our library:
1. [ε-Diagnosis](https://dl.acm.org/doi/10.1145/3308558.3313653)
2. Bayesian Inference-based RCA (BI)
3. Random Walk-based RCA (RW)
4. [Root Casue Discovery method (RCD)](https://openreview.net/pdf?id=weoLjoYFvXY)
5. [Hypothesis Testing-based RCA (HT)](https://dl.acm.org/doi/10.1145/3534678.3539041)

We will continue improving this library to make it more comprehensive in the future. In the future, 
PyRCA will support trace and log-based RCA methods as well.

## Installation

You can install ``pyrca`` from PyPI by calling ``pip install sfr-pyrca``. You may install from source by
cloning the PyRCA repo, navigating to the root directory, and calling
``pip install .``, or ``pip install -e .`` to install in editable mode. You may install additional dependencies:

- **For plotting & visualization**: Calling ``pip install sfr-pyrca[plot]``, or ``pip install .[plot]`` from the
  root directory of the repo.
- **Install all the dependencies**: Calling ``pip install sfr-pyrca[all]``, or ``pip install .[all]`` from the
  root directory of the repo.

## Getting Started

PyRCA provides a unified interface for training RCA models and finding root causes. To apply
a certain RCA method, you only need to specify: 

- **The selected RCA method**: e.g., ``BayesianNetwork``, ``EpsilonDiagnosis``.
- **The method configuration**: e.g., ``BayesianNetworkConfig``, ``EpsilonDiagnosisConfig``.
- **Time series data for initialization/training**: e.g., A time series data in a 
  pandas dataframe.
- **Abnormal time series data in an incident window**: The RCA methods require the anomalous 
  KPI metrics in an incident window.

Let's take ``BayesianNetwork`` as an example. Suppose that ``graph_df`` is the pandas dataframe of
a graph representing the causal relationships between metrics (how to construct such causal graph
will be discussed later), and ``df`` is the pandas dataframe containing the historical observed time series 
data (e.g., the index is the timestamp and each column represents one monitored metric). To train a 
``BayesianNetwork``, you can simply run the following code:

```python
from pyrca.analyzers.bayesian import BayesianNetwork
model = BayesianNetwork(config=BayesianNetwork.config_class(graph=graph_df))
model.train(df)
model.save("model_folder")
```

After the model is trained, you can use it to find root causes of an incident given a list of anomalous
metrics detected by a certain anomaly detector (you can use the stats-based detector supported in PyRCA
or other anomaly detection methods supported by our [Merlion](https://github.com/salesforce/Merlion) library), 
e.g.,

```python
from pyrca.analyzers.bayesian import BayesianNetwork
model = BayesianNetwork.load("model_folder")
results = model.find_root_causes(["observed_anomalous_metric", ...])
print(results.to_dict())
```

For other RCA methods, you can write similar code as above for finding root causes. For example, if you want
to try ``EpsilonDiagnosis``, you can initalize ``EpsilonDiagnosis`` as follows:

```python
from pyrca.analyzers.epsilon_diagnosis import EpsilonDiagnosis
model = EpsilonDiagnosis(config=EpsilonDiagnosis.config_class(alpha=0.01))
model.train(normal_data)
```

Here ``normal_data`` is the historically observed time series data without anomalies. To identify root causes,
you can run:

```python
results = model.find_root_causes(abnormal_data)
print(results.to_dict())
```

where ``abnormal_data`` is the time series data collected in an incident window.

As mentioned above, some RCA methods such as ``BayesianNetwork`` require causal graphs as their inputs. To construct such causal
graphs from the observed time series data, you can utilize our tool by running ``python -m pyrca.tools``.
This command will launch a Dash app for time series data analysis and causal discovery.
![alt text](https://github.com/salesforce/PyRCA/raw/main/docs/_static/dashboard_gif.gif)

The dashboard enables users to experiment with different causal discovery methods, customize causal discovery 
parameters, add domain knowledge constraints (e.g., root/leaf nodes, forbidden/required links), and visualize 
the generated causal graphs. This feature simplifies the process of manually revising causal graphs based on 
domain knowledge. Users can download the graph generated by this tool if they are satisfied with it. The graph 
can then be used by the RCA methods supported in PyRCA.

Alternatively, users can write code to build such graphs instead of using the dashboard. The package 
``pyrca.graphs.causal`` includes several popular causal discovery methods that users can leverage. 
All of these methods support domain knowledge constraints. For instance, if users wish to apply the PC 
algorithm for building causal graphs on the observed time series data ``df``, the following code can be used:

```python
from pyrca.graphs.causal.pc import PC
model = PC(PC.config_class())
graph_df = model.train(df)
```

If you have some domain knowledge constraints, you may run:

```python
from pyrca.graphs.causal.pc import PC
model = PC(PC.config_class(domain_knowledge_file="file_path"))
graph_df = model.train(df)
```

The domain knowledge file has a YAML format, e.g.,

```yaml
causal-graph:
  root-nodes: ["A", "B"]
  leaf-nodes: ["E", "F"]
  forbids:
    - ["A", "E"]
  requires: 
    - ["A", "C"]
```

This domain knowledge file states that: 
1. Metrics A and B must the root nodes, 
2. Metrics E and F must be the leaf nodes,
3. There is no connection from A to E, and 
4. There is a connection from A to C. 

You can write your domain knowledge file based on this template for generating more reliable causal
graphs.

## Application Example

[Here](https://github.com/salesforce/PyRCA/tree/main/pyrca/applications/example) is a real-world example
of applying ``BayesianNetwork`` to build a solution for RCA, which is adapted from our internal use cases. 
The "config" folder includes the settings for the stats-based anomaly detector and the domain knowledge. 
The "models" folder stores the causal graph and the trained Bayesian network. The ``RCAEngine`` class in the "rca.py" 
file implements the methods for building causal graphs, training Bayesian networks and finding root causes 
by utilizing the modules provided by PyRCA. You can directly use this class if the stats-based anomaly detector 
and Bayesian inference are suitable for your problems. For example, given a time series dataframe ``df``, 
you can build and train a Bayesian network via the following code:

```python
from pyrca.applications.example.rca import RCAEngine
engine = RCAEngine()
engine.build_causal_graph(
    df=df,
    run_pdag2dag=True,
    max_num_points=5000000,
    verbose=True
)
bn = engine.train_bayesian_network(dfs=[df])
bn.print_probabilities()
```

After the Bayesian network is constructed, you can use it directly for finding root causes:

```python
engine = RCAEngine()
result = engine.find_root_causes_bn(anomalies=["conn_pool", "apt"])
pprint.pprint(result)
```

The inputs of ``find_root_causes_bn`` is a list of the anomalous metrics detected by the stats-based
anomaly detector. This method will estimate the probability of a node being a root cause and extract
the paths from a potential root cause node to the leaf nodes.

## Benchmarks

The following table summarizes the RCA performance of different methods on the simulated dataset.
How to generate the simulated dataset can be found [here](https://github.com/salesforce/PyRCA/blob/main/examples/DataGeneration.ipynb),
and how to test different RCA methods can be found [here](https://github.com/salesforce/PyRCA/blob/main/examples/Root%20Cause%20Analysis.ipynb).

<div align="center">

|                             |  Recall@1   |  Recall@3   |  Recall@5   |
:---------------------------:|:-----------:|:-----------:|:-----------:
|         ε-Diagnosis         | 0.06 ± 0.02 | 0.16 ± 0.04 | 0.16 ± 0.04 |
|             RCD             | 0.28 ± 0.05 | 0.29 ± 0.05 | 0.30 ± 0.05 |
|          Local-RCD          | 0.44 ± 0.05 | 0.70 ± 0.05 | 0.70 ± 0.05 |
|         Random Walk         | 0.07 ± 0.03 | 0.20 ± 0.04 | 0.24 ± 0.04 |
|      Random Walk (PC)       | 0.06 ± 0.02 | 0.17 ± 0.04 | 0.21 ± 0.04 |
|     Bayesian Inference      | 0.15 ± 0.04 | 0.35 ± 0.05 | 0.43 ± 0.05 |
|   Bayesian Inference (PC)   | 0.11 ± 0.03 | 0.30 ± 0.05 | 0.40 ± 0.05 |
|     Hypothesis-testing      | 1.00 ± 0.00 | 1.00 ± 0.00 | 1.00 ± 0.00 |
|   Hypothesis-testing (PC)   | 0.95 ± 0.02 | 1.00 ± 0.00 | 1.00 ± 0.00 |
|  Hypothesis-testing (ADJ)   | 0.95 ± 0.02 | 1.00 ± 0.00 | 1.00 ± 0.00 |
| Hypothesis-testing (ADJ-PC) | 0.77 ± 0.04 | 0.92 ± 0.03 | 0.92 ± 0.03 |

</div>

ε-Diagnosis and RCD are one-phase RCA methods, while the rest methods are two-phase RCA methods. 
Local-RCD denotes the RCD algorithm with localized learning. The Bayesian Inference algorithm 
computes the root cause scores by estimating each structural causal model. Hypothesis-testing (ADJ) denotes 
the hypothesis-testing algorithm with descendant adjustment. For the two-phase models, the algorithms 
without suffix indicate that the root cause localization algorithm use the true causal graph for model 
training. The algorithms with suffix "PC" indicate the causal graph is estimated via PC algorithm.

## How to Contribute

We welcome the contribution from the open-source community to improve the library!
Before you get started, clone this repo, run `pip install pre-commit`, and run `pre-commit install` 
from the root directory of the repo. This will ensure all files are formatted correctly and contain 
the appropriate license headers whenever you make a commit. 

To add a new RCA method into the library, you may follow the steps below:
1. Create a new python script file for this RCA method in the ``pyrca/analyzers`` folder.
2. Create the configuration class inheriting from ``pyrca.base.BaseConfig``.
3. Create the method class inheriting from ``pyrca.analyzers.base.BaseRCA``. The constructor for the new 
method takes the new configuration instance as its input.
4. Implement the ``train`` function that trains or initializes the new method.
5. Implement the ``find_root_causes`` function that returns a ``pyrca.analyzers.base.RCAResults`` 
instance for root cause analysis results.

To add a new causal discovery method, you may follow the following steps:
1. Create a new python script file for this RCA method in the ``pyrca/graphs/causal`` folder.
2. Create the configuration class that inherits from ``pyrca.graphs.causal.base.CausalModelConfig``.
3. Create the method class that inherits from ``pyrca.graphs.causal.base.CausalModel``. 
The constructor for the new method takes the new configuration instance as its input.
4. Implement the ``_train`` function that returns the discovered casual graph. The input parameters
of ``_train`` are the time series dataframe, the lists of forbidden and required links, and other
additional parameters.

## Contact Us
If you have any questions, comments or suggestions, please do not hesitate to contact us at pyrca@salesforce.com.

## License
[BSD 3-Clause License](LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/salesforce/PyRCA",
    "name": "sfr-pyrca",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4",
    "maintainer_email": "",
    "keywords": "AIOps RCA root cause analysis",
    "author": "Salesforce Research Warden AIOps",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/15/d3/90059935c2ef4cf79cbceb9ce2d5bd6eff386d615c14688d8b4e6c51147c/sfr-pyrca-1.0.1.tar.gz",
    "platform": null,
    "description": "# PyRCA: A Python library for Root Cause Analysis\n<div align=\"center\">\n  <a href=\"#\">\n  <img src=\"https://img.shields.io/badge/Python-3.7, 3.8, 3.9-blue\">\n  </a>\n  <a href=\"https://pypi.python.org/pypi/sfr-pyrca\">\n  <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/sfr-pyrca.svg\"/>\n  </a>\n  <a href=\"https://opensource.salesforce.com/PyRCA/\">\n  <img alt=\"Documentation\" src=\"https://github.com/salesforce/PyRCA/actions/workflows/docs.yml/badge.svg\"/>\n  </a>\n  <a href=\"https://pepy.tech/project/sfr-pyrca\">\n  <img alt=\"Downloads\" src=\"https://pepy.tech/badge/sfr-pyrca\">\n  </a>\n  <a href=\"https://arxiv.org/abs/2306.11417\">\n  <img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.48550/ARXIV.2306.11417.svg\"/>\n  </a>\n</div>\n\n## Table of Contents\n1. [Introduction](#introduction)\n2. [Installation](#installation)\n3. [Getting Started](#getting-started)\n4. [Documentation](https://opensource.salesforce.com/PyRCA/)\n5. [Tutorial](https://github.com/salesforce/PyRCA/tree/main/examples)\n6. [Example](#application-example)\n7. [Benchmarks](#benchmarks)\n8. [How to Contribute](#how-to-contribute)\n\n## Introduction\n\nThe adoption of microservices architectures is growing at a rapid pace, making multi-service applications \nthe standard paradigm in real-world IT applications. Typically, a multi-service application consists of \nhundreds of interacting services, making it increasingly challenging to detect service failures and identify \ntheir root causes. Root cause analysis (RCA) methods typically rely on KPI metrics, traces, or logs monitored \non these services to determine the root causes when a system failure is detected. Such methods can aid \nengineers and SREs in the troubleshooting process.\n\nPyRCA is a Python machine-learning library designed to facilitate root cause analysis by offering various \nstate-of-the-art RCA algorithms and an end-to-end pipeline for building RCA solutions. At present, PyRCA \nprimarily focuses on metric-based RCA, including two types of algorithms: (1) identifying anomalous metrics \nin parallel with the observed anomaly through metric data analysis, such as \u03b5-diagnosis, and (2) identifying \nroot causes based on a topology/causal graph representing the causal relationships between the observed \nmetrics, such as Bayesian inference and Random Walk. PyRCA also provides a convenient tool for building \ncausal graphs from the observed time series data and domain knowledge, enabling users to develop graph-based \nsolutions quickly. Furthermore, PyRCA offers a benchmark for evaluating various RCA methods, which is \nvaluable for industry and academic research.\n\nThe following list shows the supported RCA methods in our library:\n1. [\u03b5-Diagnosis](https://dl.acm.org/doi/10.1145/3308558.3313653)\n2. Bayesian Inference-based RCA (BI)\n3. Random Walk-based RCA (RW)\n4. [Root Casue Discovery method (RCD)](https://openreview.net/pdf?id=weoLjoYFvXY)\n5. [Hypothesis Testing-based RCA (HT)](https://dl.acm.org/doi/10.1145/3534678.3539041)\n\nWe will continue improving this library to make it more comprehensive in the future. In the future, \nPyRCA will support trace and log-based RCA methods as well.\n\n## Installation\n\nYou can install ``pyrca`` from PyPI by calling ``pip install sfr-pyrca``. You may install from source by\ncloning the PyRCA repo, navigating to the root directory, and calling\n``pip install .``, or ``pip install -e .`` to install in editable mode. You may install additional dependencies:\n\n- **For plotting & visualization**: Calling ``pip install sfr-pyrca[plot]``, or ``pip install .[plot]`` from the\n  root directory of the repo.\n- **Install all the dependencies**: Calling ``pip install sfr-pyrca[all]``, or ``pip install .[all]`` from the\n  root directory of the repo.\n\n## Getting Started\n\nPyRCA provides a unified interface for training RCA models and finding root causes. To apply\na certain RCA method, you only need to specify: \n\n- **The selected RCA method**: e.g., ``BayesianNetwork``, ``EpsilonDiagnosis``.\n- **The method configuration**: e.g., ``BayesianNetworkConfig``, ``EpsilonDiagnosisConfig``.\n- **Time series data for initialization/training**: e.g., A time series data in a \n  pandas dataframe.\n- **Abnormal time series data in an incident window**: The RCA methods require the anomalous \n  KPI metrics in an incident window.\n\nLet's take ``BayesianNetwork`` as an example. Suppose that ``graph_df`` is the pandas dataframe of\na graph representing the causal relationships between metrics (how to construct such causal graph\nwill be discussed later), and ``df`` is the pandas dataframe containing the historical observed time series \ndata (e.g., the index is the timestamp and each column represents one monitored metric). To train a \n``BayesianNetwork``, you can simply run the following code:\n\n```python\nfrom pyrca.analyzers.bayesian import BayesianNetwork\nmodel = BayesianNetwork(config=BayesianNetwork.config_class(graph=graph_df))\nmodel.train(df)\nmodel.save(\"model_folder\")\n```\n\nAfter the model is trained, you can use it to find root causes of an incident given a list of anomalous\nmetrics detected by a certain anomaly detector (you can use the stats-based detector supported in PyRCA\nor other anomaly detection methods supported by our [Merlion](https://github.com/salesforce/Merlion) library), \ne.g.,\n\n```python\nfrom pyrca.analyzers.bayesian import BayesianNetwork\nmodel = BayesianNetwork.load(\"model_folder\")\nresults = model.find_root_causes([\"observed_anomalous_metric\", ...])\nprint(results.to_dict())\n```\n\nFor other RCA methods, you can write similar code as above for finding root causes. For example, if you want\nto try ``EpsilonDiagnosis``, you can initalize ``EpsilonDiagnosis`` as follows:\n\n```python\nfrom pyrca.analyzers.epsilon_diagnosis import EpsilonDiagnosis\nmodel = EpsilonDiagnosis(config=EpsilonDiagnosis.config_class(alpha=0.01))\nmodel.train(normal_data)\n```\n\nHere ``normal_data`` is the historically observed time series data without anomalies. To identify root causes,\nyou can run:\n\n```python\nresults = model.find_root_causes(abnormal_data)\nprint(results.to_dict())\n```\n\nwhere ``abnormal_data`` is the time series data collected in an incident window.\n\nAs mentioned above, some RCA methods such as ``BayesianNetwork`` require causal graphs as their inputs. To construct such causal\ngraphs from the observed time series data, you can utilize our tool by running ``python -m pyrca.tools``.\nThis command will launch a Dash app for time series data analysis and causal discovery.\n![alt text](https://github.com/salesforce/PyRCA/raw/main/docs/_static/dashboard_gif.gif)\n\nThe dashboard enables users to experiment with different causal discovery methods, customize causal discovery \nparameters, add domain knowledge constraints (e.g., root/leaf nodes, forbidden/required links), and visualize \nthe generated causal graphs. This feature simplifies the process of manually revising causal graphs based on \ndomain knowledge. Users can download the graph generated by this tool if they are satisfied with it. The graph \ncan then be used by the RCA methods supported in PyRCA.\n\nAlternatively, users can write code to build such graphs instead of using the dashboard. The package \n``pyrca.graphs.causal`` includes several popular causal discovery methods that users can leverage. \nAll of these methods support domain knowledge constraints. For instance, if users wish to apply the PC \nalgorithm for building causal graphs on the observed time series data ``df``, the following code can be used:\n\n```python\nfrom pyrca.graphs.causal.pc import PC\nmodel = PC(PC.config_class())\ngraph_df = model.train(df)\n```\n\nIf you have some domain knowledge constraints, you may run:\n\n```python\nfrom pyrca.graphs.causal.pc import PC\nmodel = PC(PC.config_class(domain_knowledge_file=\"file_path\"))\ngraph_df = model.train(df)\n```\n\nThe domain knowledge file has a YAML format, e.g.,\n\n```yaml\ncausal-graph:\n  root-nodes: [\"A\", \"B\"]\n  leaf-nodes: [\"E\", \"F\"]\n  forbids:\n    - [\"A\", \"E\"]\n  requires: \n    - [\"A\", \"C\"]\n```\n\nThis domain knowledge file states that: \n1. Metrics A and B must the root nodes, \n2. Metrics E and F must be the leaf nodes,\n3. There is no connection from A to E, and \n4. There is a connection from A to C. \n\nYou can write your domain knowledge file based on this template for generating more reliable causal\ngraphs.\n\n## Application Example\n\n[Here](https://github.com/salesforce/PyRCA/tree/main/pyrca/applications/example) is a real-world example\nof applying ``BayesianNetwork`` to build a solution for RCA, which is adapted from our internal use cases. \nThe \"config\" folder includes the settings for the stats-based anomaly detector and the domain knowledge. \nThe \"models\" folder stores the causal graph and the trained Bayesian network. The ``RCAEngine`` class in the \"rca.py\" \nfile implements the methods for building causal graphs, training Bayesian networks and finding root causes \nby utilizing the modules provided by PyRCA. You can directly use this class if the stats-based anomaly detector \nand Bayesian inference are suitable for your problems. For example, given a time series dataframe ``df``, \nyou can build and train a Bayesian network via the following code:\n\n```python\nfrom pyrca.applications.example.rca import RCAEngine\nengine = RCAEngine()\nengine.build_causal_graph(\n    df=df,\n    run_pdag2dag=True,\n    max_num_points=5000000,\n    verbose=True\n)\nbn = engine.train_bayesian_network(dfs=[df])\nbn.print_probabilities()\n```\n\nAfter the Bayesian network is constructed, you can use it directly for finding root causes:\n\n```python\nengine = RCAEngine()\nresult = engine.find_root_causes_bn(anomalies=[\"conn_pool\", \"apt\"])\npprint.pprint(result)\n```\n\nThe inputs of ``find_root_causes_bn`` is a list of the anomalous metrics detected by the stats-based\nanomaly detector. This method will estimate the probability of a node being a root cause and extract\nthe paths from a potential root cause node to the leaf nodes.\n\n## Benchmarks\n\nThe following table summarizes the RCA performance of different methods on the simulated dataset.\nHow to generate the simulated dataset can be found [here](https://github.com/salesforce/PyRCA/blob/main/examples/DataGeneration.ipynb),\nand how to test different RCA methods can be found [here](https://github.com/salesforce/PyRCA/blob/main/examples/Root%20Cause%20Analysis.ipynb).\n\n<div align=\"center\">\n\n|                             |  Recall@1   |  Recall@3   |  Recall@5   |\n:---------------------------:|:-----------:|:-----------:|:-----------:\n|         \u03b5-Diagnosis         | 0.06 \u00b1 0.02 | 0.16 \u00b1 0.04 | 0.16 \u00b1 0.04 |\n|             RCD             | 0.28 \u00b1 0.05 | 0.29 \u00b1 0.05 | 0.30 \u00b1 0.05 |\n|          Local-RCD          | 0.44 \u00b1 0.05 | 0.70 \u00b1 0.05 | 0.70 \u00b1 0.05 |\n|         Random Walk         | 0.07 \u00b1 0.03 | 0.20 \u00b1 0.04 | 0.24 \u00b1 0.04 |\n|      Random Walk (PC)       | 0.06 \u00b1 0.02 | 0.17 \u00b1 0.04 | 0.21 \u00b1 0.04 |\n|     Bayesian Inference      | 0.15 \u00b1 0.04 | 0.35 \u00b1 0.05 | 0.43 \u00b1 0.05 |\n|   Bayesian Inference (PC)   | 0.11 \u00b1 0.03 | 0.30 \u00b1 0.05 | 0.40 \u00b1 0.05 |\n|     Hypothesis-testing      | 1.00 \u00b1 0.00 | 1.00 \u00b1 0.00 | 1.00 \u00b1 0.00 |\n|   Hypothesis-testing (PC)   | 0.95 \u00b1 0.02 | 1.00 \u00b1 0.00 | 1.00 \u00b1 0.00 |\n|  Hypothesis-testing (ADJ)   | 0.95 \u00b1 0.02 | 1.00 \u00b1 0.00 | 1.00 \u00b1 0.00 |\n| Hypothesis-testing (ADJ-PC) | 0.77 \u00b1 0.04 | 0.92 \u00b1 0.03 | 0.92 \u00b1 0.03 |\n\n</div>\n\n\u03b5-Diagnosis and RCD are one-phase RCA methods, while the rest methods are two-phase RCA methods. \nLocal-RCD denotes the RCD algorithm with localized learning. The Bayesian Inference algorithm \ncomputes the root cause scores by estimating each structural causal model. Hypothesis-testing (ADJ) denotes \nthe hypothesis-testing algorithm with descendant adjustment. For the two-phase models, the algorithms \nwithout suffix indicate that the root cause localization algorithm use the true causal graph for model \ntraining. The algorithms with suffix \"PC\" indicate the causal graph is estimated via PC algorithm.\n\n## How to Contribute\n\nWe welcome the contribution from the open-source community to improve the library!\nBefore you get started, clone this repo, run `pip install pre-commit`, and run `pre-commit install` \nfrom the root directory of the repo. This will ensure all files are formatted correctly and contain \nthe appropriate license headers whenever you make a commit. \n\nTo add a new RCA method into the library, you may follow the steps below:\n1. Create a new python script file for this RCA method in the ``pyrca/analyzers`` folder.\n2. Create the configuration class inheriting from ``pyrca.base.BaseConfig``.\n3. Create the method class inheriting from ``pyrca.analyzers.base.BaseRCA``. The constructor for the new \nmethod takes the new configuration instance as its input.\n4. Implement the ``train`` function that trains or initializes the new method.\n5. Implement the ``find_root_causes`` function that returns a ``pyrca.analyzers.base.RCAResults`` \ninstance for root cause analysis results.\n\nTo add a new causal discovery method, you may follow the following steps:\n1. Create a new python script file for this RCA method in the ``pyrca/graphs/causal`` folder.\n2. Create the configuration class that inherits from ``pyrca.graphs.causal.base.CausalModelConfig``.\n3. Create the method class that inherits from ``pyrca.graphs.causal.base.CausalModel``. \nThe constructor for the new method takes the new configuration instance as its input.\n4. Implement the ``_train`` function that returns the discovered casual graph. The input parameters\nof ``_train`` are the time series dataframe, the lists of forbidden and required links, and other\nadditional parameters.\n\n## Contact Us\nIf you have any questions, comments or suggestions, please do not hesitate to contact us at pyrca@salesforce.com.\n\n## License\n[BSD 3-Clause License](LICENSE)\n",
    "bugtrack_url": null,
    "license": "3-Clause BSD",
    "summary": "PyRCA: A Python library for Root Cause Analysis",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/salesforce/PyRCA"
    },
    "split_keywords": [
        "aiops",
        "rca",
        "root",
        "cause",
        "analysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "702cac9da81e22e998de3f77c1d3fe43759e2e66cf6130997ffb3ba3b808acab",
                "md5": "cbaf7be31219ca5438d3f459033911e2",
                "sha256": "994b09621ff1bc33bdc9ac6dcad64eb2f30d59f6ab6fa824ace0e8aa966b9458"
            },
            "downloads": -1,
            "filename": "sfr_pyrca-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cbaf7be31219ca5438d3f459033911e2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4",
            "size": 358297,
            "upload_time": "2023-06-27T02:27:44",
            "upload_time_iso_8601": "2023-06-27T02:27:44.257415Z",
            "url": "https://files.pythonhosted.org/packages/70/2c/ac9da81e22e998de3f77c1d3fe43759e2e66cf6130997ffb3ba3b808acab/sfr_pyrca-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15d390059935c2ef4cf79cbceb9ce2d5bd6eff386d615c14688d8b4e6c51147c",
                "md5": "440e55aede63ee34029c6d13f5701d0c",
                "sha256": "59f0559e96a400a4925c8fef8d590ae432d7ce8ad3b10eb084b90908cf53c1cd"
            },
            "downloads": -1,
            "filename": "sfr-pyrca-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "440e55aede63ee34029c6d13f5701d0c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4",
            "size": 292153,
            "upload_time": "2023-06-27T02:27:46",
            "upload_time_iso_8601": "2023-06-27T02:27:46.074847Z",
            "url": "https://files.pythonhosted.org/packages/15/d3/90059935c2ef4cf79cbceb9ce2d5bd6eff386d615c14688d8b4e6c51147c/sfr-pyrca-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-27 02:27:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "salesforce",
    "github_project": "PyRCA",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sfr-pyrca"
}
        
Elapsed time: 0.08098s