Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
10cafd7
Add mermaid diagram for DPG
rzfzr Mar 4, 2026
49d7e59
Reorder tree structure in diagram
rzfzr Mar 4, 2026
f5918e8
Replace dots with ellipses in diagram
rzfzr Mar 4, 2026
96d1199
Add mermaid diagram initialization
rzfzr Mar 4, 2026
38287d2
Add output nodes to diagram
rzfzr Mar 4, 2026
1f40db2
Fix diagram edge connections
rzfzr Mar 4, 2026
746b5d7
Remove unused output nodes
rzfzr Mar 4, 2026
c0a4a33
Group F1 predicates in diagram
rzfzr Mar 4, 2026
3964dea
Change diagram node styles
rzfzr Mar 4, 2026
25a722d
Adjust diagram rank spacing
rzfzr Mar 4, 2026
780f76c
Fix diagram node style transparency
rzfzr Mar 4, 2026
54c5bc4
Adjust diagram node spacing
rzfzr Mar 4, 2026
318d886
Change plot argument handling
rzfzr Mar 4, 2026
e8107ac
Add SVG export functionality
rzfzr Mar 4, 2026
511c98d
Add multiple DPG plot options
rzfzr Mar 4, 2026
44f850f
Enhance DPG argument handling
rzfzr Mar 4, 2026
2f3e9d4
Using svg for readme
rzfzr Mar 4, 2026
2988025
Fix image link in README
rzfzr Mar 4, 2026
b63dfc5
Add pyvis dependency
rzfzr Mar 4, 2026
eea514d
Add HTML export functionality
rzfzr Mar 4, 2026
8f2ef5c
Add HTML export option to plots
rzfzr Mar 4, 2026
1b65fe6
Add HTML export option
rzfzr Mar 4, 2026
6e5f5ee
Swaping svg with html
rzfzr Mar 4, 2026
621c77f
Add Mermaid export option
rzfzr Mar 4, 2026
1502699
Add DOT keywords filtering
rzfzr Mar 4, 2026
835d5b2
Add detailed Mermaid diagram
rzfzr Mar 4, 2026
d188853
Consolidate export options to format
rzfzr Mar 4, 2026
8cbe8c2
Add error handling for user input
rzfzr Mar 4, 2026
4ab71fa
Add export format option
rzfzr Mar 4, 2026
61cca32
Using the same l2 custom mermaid
rzfzr Mar 4, 2026
b5d7697
Sequential ci steps
rzfzr Mar 4, 2026
d555dbe
Enhance mermaid styles for clarity
rzfzr Mar 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 77 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,57 @@ on:
pull_request:

jobs:
test:
test-3_10:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest

- name: Run tests
run: pytest -q

test-3_11:
needs: test-3_10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest

- name: Run tests
run: pytest -q

test-3_12:
needs: test-3_11
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: "3.12"
cache: 'pip'

- name: Install dependencies
Expand All @@ -28,5 +66,38 @@ jobs:
pip install pytest

- name: Run tests
run: pytest -q

docs:
needs: test-3_12
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install system dependencies
run: sudo apt-get install -y graphviz

- name: Install package + docs dependencies
run: pip install ".[docs]"

- name: Build Sphinx docs
run: |
pytest -q
sphinx-build --keep-going -b html docs/ docs/_build/html 2>&1 | tee /tmp/sphinx_out.txt
# Fail if any WARNING line is present that is NOT the benign placeholder one
if grep -v "Unknown type: placeholder" /tmp/sphinx_out.txt | grep -q "^WARNING:"; then
echo "Unexpected Sphinx warnings found:"
grep -v "Unknown type: placeholder" /tmp/sphinx_out.txt | grep "^WARNING:"
exit 1
fi

- name: Upload HTML docs as artifact
uses: actions/upload-artifact@v4
with:
name: html-docs
path: docs/_build/html/
retention-days: 7
46 changes: 0 additions & 46 deletions .github/workflows/docs.yml

This file was deleted.

245 changes: 239 additions & 6 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dpg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class_feature_predicate_counts,
class_lookup_from_target_names,
classwise_feature_bounds_from_communities,
export_dpg_html,
plot_dpg,
plot_dpg_class_bounds_vs_dataset_feature_ranges,
plot_dpg_constraints_overview,
Expand All @@ -18,6 +19,7 @@
"DecisionPredicateGraph",
"DPGExplainer",
"DPGExplanation",
"export_dpg_html",
"plot_dpg",
"plot_dpg_reg",
"plot_dpg_constraints_overview",
Expand Down
4 changes: 4 additions & 0 deletions dpg/explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def plot(
pdf_dpi: int = 600,
show: bool = True,
export_pdf: bool = False,
export_html: bool = False,
) -> None:
"""Render a standard DPG plot."""
if explanation is None:
Expand All @@ -165,6 +166,7 @@ def plot(
pdf_dpi=pdf_dpi,
show=show,
export_pdf=export_pdf,
export_html=export_html,
)

def plot_communities(
Expand All @@ -182,6 +184,7 @@ def plot_communities(
pdf_dpi: int = 600,
show: bool = True,
export_pdf: bool = False,
export_html: bool = False,
community_threshold: float = 0.2,
) -> None:
"""Render a community-colored DPG plot."""
Expand All @@ -206,6 +209,7 @@ def plot_communities(
pdf_dpi=pdf_dpi,
show=show,
export_pdf=export_pdf,
export_html=export_html,
)

def plot_lrc_importance(
Expand Down
45 changes: 41 additions & 4 deletions dpg/sklearn_dpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def test_dpg(datasets: str,
clusters_flag: bool = False,
threshold_clusters: Optional[float] = None,
class_flag: bool = False,
seed:int = 160898) -> Optional[Tuple[Any, Any]]:
seed:int = 160898,
export_format: str = "svg") -> Optional[Tuple[Any, Any]]:

"""
Unified function to train models and extract DPG for both standard and custom datasets.
Expand Down Expand Up @@ -193,7 +194,40 @@ def test_dpg(datasets: str,
if '.' in datasets else datasets
)
plot_name += f"_{model_name}_l{n_learners}_pv{perc_var}_t{decimal_threshold}_{seed}"


# 1. Basic (plain) DPG
plot_dpg(
plot_name,
dot,
df,
df_edges,
save_dir=save_plot_dir,
class_flag=class_flag,
export_format=export_format,
)

# 2. One plot per node-metric attribute
node_attributes = [
"Degree",
"In degree nodes",
"Out degree nodes",
"Betweenness centrality",
"Local reaching centrality",
]
for attr in node_attributes:
if attr in df.columns:
plot_dpg(
plot_name,
dot,
df,
df_edges,
save_dir=save_plot_dir,
attribute=attr,
class_flag=class_flag,
export_format=export_format,
)

# 3. Communities plot
if communities:
plot_dpg_communities(
plot_name,
Expand All @@ -203,18 +237,21 @@ def test_dpg(datasets: str,
save_dir=save_plot_dir,
class_flag=class_flag,
df_edges=df_edges,
export_format=export_format,
)
else:

# 4. Clusters plot
if clusters is not None:
plot_dpg(
plot_name,
dot,
df,
df_edges,
save_dir=save_plot_dir,
attribute=attribute,
clusters=clusters,
threshold_clusters=threshold_clusters,
class_flag=class_flag,
export_format=export_format,
)

return df, df_edges, df_dpg, clusters, node_prob, confidence
Loading