Skip to content

Checking git conflict#72

Open
daehyun99 wants to merge 42 commits into
Refactor/2385/Graphs-1from
Refactor/2385/PDAG-1
Open

Checking git conflict#72
daehyun99 wants to merge 42 commits into
Refactor/2385/Graphs-1from
Refactor/2385/PDAG-1

Conversation

@daehyun99
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces version 1.1.0, featuring a comprehensive documentation overhaul, a refactored PDAG class, and a reimplemented GES causal discovery algorithm. It also adds causal statistics to get_stats, supports fixed-edge counts in random graph generation, and updates instructions for AI agents. Review feedback focuses on optimizing the new GES implementation by removing redundant acyclicity checks, replacing inefficient path searches with reachability tests, and deferring expensive graph conversions to improve execution speed.

Comment thread pgmpy/causal_discovery/GES.py
Comment thread pgmpy/causal_discovery/GES.py Outdated
Comment thread pgmpy/causal_discovery/GES.py
Comment thread pgmpy/causal_discovery/GES.py Outdated
Comment thread pgmpy/causal_discovery/GES.py Outdated
@daehyun99 daehyun99 force-pushed the Refactor/2385/PDAG-1 branch from ad7b1a8 to 7cb464b Compare April 27, 2026 16:54
ankurankan and others added 25 commits April 28, 2026 15:08
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
…mpy#3293)

**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [x] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [x] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [x] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [x] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [x] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

Didn't use any AI for this PR

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

I ran the doctests multiple times locally

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

Not applicable

### Issue number(s) that this pull request fixes
- Fixes pgmpy#3219 

### List of changes to the codebase in this pull request
- Used load_model where were needed to load the model from blearn/asia
to convert to asia.net and run the test
- Updated doctests to use:
`# doctest: +NORMALIZE_WHITESPACE` for formatting consistency

---------

Co-authored-by: Ankur Ankan <ankurankan@gmail.com>
- Add missing pandas import in sample() docstring example
- Fix TypeError by converting dtype string to torch.dtype using getattr
- Update expected output to match current numpy/torch versions

Fixes pgmpy#3154

**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [yes] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [yes] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [yes] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [yes] Are you able to fully explain your changes? We expect you to
fully understand the algorithm and take full responsibility for any
changes in this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

I used Claude (an AI assistant) as a learning coach to help me
understand the error and navigate the codebase. It helped me understand
what getattr does and why torch.as_tensor needs a torch.dtype object
instead of a string. I wrote and ran all the commands myself.

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?
I ran python3 -m doctest pgmpy/factors/hybrid/FunctionalCPD.py -v and
confirmed 13 tests pass. I also ran the sample function manually in a
Python script to verify the output is correct.
- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?
No. This PR fixes doctest examples that already existed. I did not
generate any new tests.
### Issue number(s) that this pull request fixes
- Fixes pgmpy#3154

### List of changes to the codebase in this pull request
- pgmpy/factors/hybrid/FunctionalCPD.py

---------

Co-authored-by: Ankur Ankan <ankurankan@gmail.com>
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
Auto-generated by the nightly CI workflow. Merging this will improve
test split balancing.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [x] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [x] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [x] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [x] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [x] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

I have used claude opus 4.7 for generating parts of the PR. I first
asked claude to run a line profiler to identify the most expensive
operations. This pointed me towards the structure score computation and
the state counts methods. This was similar to the optimization I had
done for power divergence tests. I asked claude to apply a similar
optimization. The tests were run to verify that the results are exactly
the same as before.

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

The test results are exactly the same as  before.

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

Yes, I have compressed them.

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
pgmpy#3383)

…mpy OLS

### List of changes to the codebase in this pull request
- Changes getting log-likelihood from statsmodels to doing a simple
numpy OLS fit and computing it.
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [x ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [x ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [x ] Are all the GitHub Actions checks passing? If not, mark your PR
as draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [x ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [x ] Are you able to fully explain your changes? We expect you to
fully understand the algorithm and take full responsibility for any
changes in this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

I used Antigravity to help with the heavy lifting of the migration. My
workflow was pretty straightforward- I first read through the issue
myself and spent some time going through the sphinxcontrib-bibtex docs
to get a feel for how it works before touching anything.
Once I had a clear picture, I asked Antigravity to help me write a
script to do the bulk work: parsing the existing docs/references.rst,
pulling out all the plaintext references, and turning them into proper
BibTeX @misc entries with keyword fields for the category grouping. The
same script handled scanning through the Python source files and
replacing the old .. [1] Author et al. markers with :cite:p: roles.
From there it was mostly me - I went through the diffs carefully, made
sure each substitution actually made sense in context, and caught things
like the special character issues (&, % in titles) that needed manual
fixing.

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

Ran ruff check pgmpy/ - all clean. Then pytest pgmpy/tests/test_metrics/
-36/36 passed.
Beyond the standard checks, I wrote a small script to make sure every
:cite:p: key actually has a matching entry in references.bib. Didn't
want any dangling keys slipping through across 92 files, and thankfully
there were none.
I also went through the BibTeX file manually for special characters
since those can silently break rendering. Found 27 bare & and % in title
fields and escaped them all.
The test_fisher_z and test_pearsonr failures looked alarming at first
but I checked git status on both files - neither was touched in this PR,
so those are pre-existing and unrelated.

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

No new tests were generated. This PR is a documentation-only migration.
No library logic or algorithms were changed, so no new tests are needed.

### Issue number(s) that this pull request fixes
- Fixes pgmpy#3271

### List of changes to the codebase in this pull request
-Added sphinxcontrib-bibtex to the docs dependencies in pyproject.toml
Turned on the sphinxcontrib.bibtex extension in docs/conf.py and pointed
it to references.bib
Created docs/references.bib -113 entries, each with a keyword field so
they can be filtered by category
Rewrote docs/references.rst to use .. bibliography:: with :filter: so
the grouping is dynamic instead of hardcoded
Updated 92 Python files to replace the old .. [N] Author text style with
proper :cite:p: roles

---------

Co-authored-by: Nitin Portfolio Builder <nitin-portfolio@example.com>
Co-authored-by: Ankur Ankan <ankurankan@gmail.com>
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
- equal model is exist. I believe that it is occur on pgmpy#2232 PR's
mistake.
- https://github.com/pgmpy/pgmpy/blob/dev/pgmpy/inference/LinearModel.py
-
https://github.com/pgmpy/pgmpy/blob/dev/pgmpy/estimators/LinearModel.py
Added prompts for AI tool usage and workflow description.
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [x] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [x] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [x] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [x] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.
- "I used an AI assistant (Antigravity) to identify the specific doctest
errors (such as invalid arguments like return_type and output format
mismatches). The AI also helped me run the tests locally to find the
correct deterministic outputs by adding seed=42. I have manually
reviewed all the changes and confirmed they are correct.

"I ran the doctests locally using python -m doctest
pgmpy/sampling/Sampling.py and verified that they all passed after the
fixes."

"No, I did not use AI for generating tests. I only fixed existing
doctests."

### Issue number(s) that this pull request fixes
- Fixes pgmpy#3155 

### List of changes to the codebase in this pull request
-
ankurankan and others added 16 commits May 14, 2026 14:44
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [x] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [x] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [x] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [x] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [x] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

I have used claude code opus 4.7 for refactoring parts of the code. The
original implementation was provided by @srhmm . I have refactored the
code to be faster, easier to read, and improved documentation.

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

A simulation-based test case has been used to verify that the algorithm
is able to recover the true graph.

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

No

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-

---------

Co-authored-by: Sarah Mameche <sarah.mameche@cispa.de>
Co-authored-by: nimish <nimishpurohitn@gmail.com>
Co-authored-by: Nimish Purohit <90456805+Nimish-4@users.noreply.github.com>
Updated the description of Causal Inference to focus on interventional distributions.
Auto-generated by the nightly CI workflow. Merging this will improve
test split balancing.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ankur Ankan <ankurankan@gmail.com>
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [x] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [x] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [x] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [x] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [x] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

I used both Claude and ChatGPT as learning and support tools while
working on this task. I first went through the existing code of
TreeSearch myself and tried to understand how to refractor using the
examples of the `ExpertInLoop`, `ExpertKnowledge` and `GES` refractoring
and what is needed to be changed to make it sklearn compatible. I
refactored the TreeSearch class to make it follow a sklearn-style design
instead of the old pgmpy estimator pattern. Earlier, the class stored
the data inside `__init__` and used an estimate() method that directly
returned the graph. I changed this by removing data from `__init__` and
keeping only hyperparameters there, and moved the learning logic into a
`_fit(X)` method that takes the data as input. Instead of returning the
graph, the model now stores results as attributes like causal_graph_ and
adjacency_matrix_. I also made sure not to modify input parameters like
root_node during fitting by using a local variable, so the behavior
stays consistent across multiple runs. Along with this, I updated the
tests and examples to use .fit() and access results through attributes,
and adjusted static method usage to be called directly from the class. I
did not change implementation of the algorithm rather just copy pasted
it into the new file. Also added the warning message in
`pgmpy/estimators/TreeSearch.py`

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

Kept consistency in the structure by comparing it with other refractored
estimators. Also copy pasted the logic from
`pgmpy/estimators/TreeSearch.py` so there is minimum errors from my side
which can be introduced by an AI. Also added the doctests needed and
validated them.

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

Didnt use AI to generate any tests, the tests were already present in
`tests/test_estimators/test_TreeSearch.py`. Earlier, the tests were
creating the model with data in the constructor and calling estimate()
to get the result. I changed this to first initialize the model with
parameters, then call .fit(data), and access the learned graph using
est.causal_graph_.

### Issue number(s) that this pull request fixes
- Fixes pgmpy#2575
- Fixes pgmpy#3298 

### List of changes to the codebase in this pull request
- Refractored TreeSearch Algorithm into sklearn compatible 
- Also refractored the tests and added them
- Added the warning in `pgmpy/estimators/TreeSearch.py`
- Added in doctest_modules.txt

---------

Co-authored-by: Ankur Ankan <ankurankan@gmail.com>
**The following checklist is mandatory**

Your PR will be closed if you remove the checklist. Use of LLMs is
**strictly forbidden** for any part of this checklist (including for
improving language), and will result in a **ban** if we find any use of
LLMs.

### Your checklist for this pull request

- [ ] Have you followed all the steps from our [Contributing
Guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)?
- [ ] Does the PR fully address the linked issue and is within its
defined scope? If you are still working on the PR, mark it as draft.
- [ ] Are all the GitHub Actions checks passing? If not, mark your PR as
draft while you fix it.

If you have used AI/LLMs for any assistance, please answer the following
questions. Please refer
[pgmpy#2622](pgmpy#2622) for an example of the
level of detail we expect:

- [ ] Have you reviewed our [AI usage
policy](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md#ai-usage-policy)?
- [ ] Are you able to fully explain your changes? We expect you to fully
understand the algorithm and take full responsibility for any changes in
this PR.

- Please list the AI tool(s) used, along with the model and its version
used.

[Please replace this with your answer]

- Please describe in **detail** how and what you used AI assistance for?
Please outline your whole workflow with the AI tool.

[Please replace this with your answer]

- What steps have you taken to verify that the changes correctly address
the issue? What edge cases have you considered? Other than running
tests, what else have you verified?

[Please replace this with your answer]

- Have you used AI for generating tests? Can you compress them into a
smaller number of tests without losing coverage?

[Please replace this with your answer]

### Issue number(s) that this pull request fixes
- Fixes #

### List of changes to the codebase in this pull request
-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants