train the example file error

Open
#53 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start in pyrca/applications/example/rca.py at the example.csv workflow and the engine.train_bayesian_network(dfs=[df]) call. Inspect how conn_pool is represented in the loaded data and how training reaches _refine_parameters, then reproduce the assertion with the provided example. Done means the example training flow no longer fails on conn_pool and its expected cardinality is verified.

Written by the indexing model from the issue text.

Description

use rca.py to train example file called example.csv
In the rca.py

  import dataset 
  df = dataset.load_data('data', 'example.csv')
    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()

error in the engine.train_bayesian_network statement:

Traceback (most recent call last):
  File "C:/PyCharm Community Edition 2022.2.1/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\PyCharm Community Edition 2022.2.1\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/1000260871/Desktop/root cause analysis/PyRCA-main/pyrca/applications/example/rca.py", line 286, in <module>
    bn = engine.train_bayesian_network(dfs=[df])
  File "C:/Users/1000260871/Desktop/root cause analysis/PyRCA-main/pyrca/applications/example/rca.py", line 152, in train_bayesian_network
    bayesian_network.train(dfs=dfs)
  File "C:\python\lib\site-packages\pyrca\analyzers\bayesian.py", line 132, in train
    self._refine_parameters(lower_bound=0.01)
  File "C:\python\lib\site-packages\pyrca\analyzers\bayesian.py", line 138, in _refine_parameters
    assert cpd.values.shape[0] == 2, f"The cardinality of the variable {cpd.variable} should be = 2."
AssertionError: The cardinality of the variable conn_pool should be = 2.

I checked the cpp.values, it is array([1.])

why it happens? I didn't change anything for example.csv file

Dominant language
Python
Stars
572
Forks
69
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from salesforce/PyRCA

All issues in salesforce/PyRCA

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.