Skip to content

non-parametric bicops (tll, fastKDE); examples#38

Merged
TY-Cheng merged 38 commits intomainfrom
dev_tll
May 28, 2025
Merged

non-parametric bicops (tll, fastKDE); examples#38
TY-Cheng merged 38 commits intomainfrom
dev_tll

Conversation

@TY-Cheng
Copy link
Owner

No description provided.

TY-Cheng and others added 30 commits April 28, 2025 11:33
poetry -> uv
bicop.BiCop
vinecop.VineCop
examples/*cop.ipynb
==================
TODO:
bicop: fastkde.pdf
vinecop: rosenblatt
examples: app jupyterNB

Co-Authored-By: Thibault Vatter <thibault.vatter@gmail.com>
uv for cuda user:
uv sync --extra cu126 -U
* `pdf_at_points()` is potentially slow relative to `pdf()` cuz it does not take advantage of the inverse FFT for transforming from Fourier space to data space;
* num_step_grid has to be a power of 2;
* padding/trimming incurred;
util.kdeCDFPPF1D: a small class, fit at init time; stored inside VineCop.marginals
apply marginal cdf if user is giving obs (conditional simulation)
if top lv then marginal cdf, else nothing happen (quantile regression for experienced users)
experiments: randomsearch, more data/alpha/repeats/pipelineparaspace
fit/sample/pdf on cpu/cuda
examples/vinecop monotonic tests;
examples/bicop range tests;
examples/num_hfunc fig;
minor tidying.
commit a9f6811f44fbbcebd908e5595241e4f0258c4365
Merge: 4688a0d 5ac1502
Author: Tuoyuan Cheng <tuoyuan.cheng@gatech.edu>
Date:   Tue May 20 13:31:31 2025 +0800

    Merge branch 'pr/34' into dev_ian

commit 4688a0d
Author: Tuoyuan Cheng <tuoyuan.cheng@gatech.edu>
Date:   Mon Apr 28 10:05:55 2025 +0800

    WIP

    poetry -> uv
    many parametric bicops: parameter as torch.Tensor

commit 5ac1502
Author: gagrawal009 <g.agrawal009@gmail.com>
Date:   Sat Jan 11 14:32:29 2025 +0530

    par changed to torch.tensor

commit c7bfedc
Author: gagrawal009 <g.agrawal009@gmail.com>
Date:   Sat Jan 11 14:03:00 2025 +0530

    par changed to torch.tensor

commit 1dddbfb
Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
Date:   Tue Jan 7 14:02:19 2025 +0800

    Dev ian (#33)

    * par changed to torch.tensor

    ---------

    Co-authored-by: gagrawal009 <g.agrawal009@gmail.com>

commit ef95b6f
Author: gagrawal009 <g.agrawal009@gmail.com>
Date:   Sat Jan 4 21:58:52 2025 +0530

    par changed to torch.tensor

commit 311d196
Author: gagrawal009 <g.agrawal009@gmail.com>
Date:   Fri Jan 3 23:56:10 2025 +0530

    par changed to torch.tensor

commit 976e040
Author: gagrawal009 <g.agrawal009@gmail.com>
Date:   Fri Jan 3 23:47:11 2025 +0530

    par changed to torch.tensor

commit 7ee503a
Author: gagrawal009 <g.agrawal009@gmail.com>
Date:   Fri Jan 3 16:46:26 2025 +0530

    par changed to torch.tensor

commit f5a8d0e
Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
Date:   Wed Jan 1 13:55:33 2025 +0800

    main branch only: publish-package and static

commit 814be0b
Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
Date:   Wed Jan 1 13:04:04 2025 +0800

    rm in-place ops

commit 81301d2
Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
Date:   Sun Dec 22 18:25:50 2024 +0800

    ruff

commit 4d059ff
Merge: bf0d8a1 a7b356f
Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
Date:   Sun Dec 22 18:23:11 2024 +0800

    Merge branch 'main' into dev_ian

commit bf0d8a1
Author: ian <tycheng@nus.edu.sg>
Date:   Thu Dec 5 13:53:25 2024 +0800

    _EPS: abc, bb1678

commit c4fad3d
Author: ian <tycheng@nus.edu.sg>
Date:   Mon Dec 2 23:57:37 2024 +0800

    tawn1,2; bb1678 par2tau

commit bb89a0b
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Nov 26 21:18:32 2024 +0800

    BiCopExtremeValue (bb5); BiCopArchimedean (bb1,6,7,8); solve_ITP_vectorize for hinv1_0

commit 5b8ab4c
Author: ian <tycheng@nus.edu.sg>
Date:   Thu Nov 7 22:28:08 2024 +0800

    archimedean: par2tau_0, numint by Simpson's rule

commit a98436e
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Nov 5 17:37:50 2024 +0800

    bb1: hinv newton, tau2par quasi mle

    TODO: test refactoring, abc hinv1_num invert_f

commit 5f8149e
Author: ian <tycheng@nus.edu.sg>
Date:   Mon Nov 4 23:21:49 2024 +0800

    solve_ITP; bb1: cdf, pdf, l_pdf, hfun1

    TODO: hinv1, tau2par, par2tau

commit 0b64f8e
Merge: 8346878 7fa729b
Author: ian <tycheng@nus.edu.sg>
Date:   Mon Nov 4 17:30:53 2024 +0800

    Merge remote-tracking branch 'forked_repo/feature/bb1' into dev_ian

commit 7fa729b
Author: Sai Kiran Reddy Poreddy <saikiranreddy.saikiran@gmail.com>
Date:   Mon Nov 4 17:23:04 2024 +0800

    Bb1 Test resolution

commit 8346878
Merge: 7aa9508 c3a4776
Author: ian <tycheng@nus.edu.sg>
Date:   Mon Nov 4 16:39:20 2024 +0800

    Merge branch 'main' into dev_ian

commit 7aa9508
Merge: 67457bb aff8a9d
Author: ian <tycheng@nus.edu.sg>
Date:   Wed Oct 23 09:57:13 2024 +0800

    Merge remote-tracking branch 'origin/benchmark_tvc_pvc' into dev_ian

commit aff8a9d
Author: Thibault Vatter <thibault.vatter@gmail.com>
Date:   Tue Oct 22 16:50:24 2024 +0200

    Proper simulation study

commit 8a788fa
Author: Thibault Vatter <thibault.vatter@gmail.com>
Date:   Tue Oct 22 15:21:08 2024 +0200

    benchmarking notebook

commit 67457bb
Merge: aaf91f2 41bacc9
Author: ian <tycheng@nus.edu.sg>
Date:   Thu Oct 17 00:20:12 2024 +0800

    Merge branch 'main' into dev_ian

commit a2972d6
Author: Sai Kiran Reddy Poreddy <saikiranreddy.saikiran@gmail.com>
Date:   Wed Oct 16 23:25:31 2024 +0800

    Support bb1 bicop

commit aaf91f2
Author: ian <tycheng@nus.edu.sg>
Date:   Wed Oct 16 21:05:33 2024 +0800

    gh-pages branch for docs (Sai); Dvine one set empty

commit 9385803
Merge: d5121e0 1532674
Author: ian <tycheng@nus.edu.sg>
Date:   Wed Oct 16 19:35:32 2024 +0800

    Merge remote-tracking branch 'forked_repo/main' into dev_ian

commit 1532674
Author: Sai Kiran Reddy Poreddy <saikiranreddy.saikiran@gmail.com>
Date:   Wed Oct 16 15:09:10 2024 +0800

    Remove html files

commit 18aad45
Author: Sai Kiran Reddy Poreddy <saikiranreddy.saikiran@gmail.com>
Date:   Wed Oct 16 15:07:27 2024 +0800

    Ignore html files

commit 6902e6f
Author: Sai Kiran Reddy Poreddy <saikiranreddy.saikiran@gmail.com>
Date:   Wed Oct 16 15:06:57 2024 +0800

    Add clean option

commit 034c4ab
Author: Sai Kiran Reddy Poreddy <saikiranreddy.saikiran@gmail.com>
Date:   Wed Oct 16 15:06:28 2024 +0800

    Use sphinx_pyproject for config

commit dd9b534
Author: Sai Kiran Reddy Poreddy <saikiranreddy.saikiran@gmail.com>
Date:   Wed Oct 16 15:05:05 2024 +0800

    commit to gh-pages

commit d5121e0
Merge: c451e67 ad544de
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Oct 8 11:52:19 2024 +0800

    Merge branch 'main' into dev_ian

commit c451e67
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Oct 8 11:17:54 2024 +0800

    dvine: s_first can be in the middle! sim: sobol seq

    dvine: TSP with precedence constraints or clustered TSP
    cvine/rvine: min heap
    DataBiCop.sim: is_sobol
    DataVineCop.sim: is_sobol

commit 11566f1
Merge: 9c26242 687c4bb
Author: TYCheng <cty120120@gmail.com>
Date:   Wed Sep 25 20:17:00 2024 +0800

    Merge branch 'main' into dev_ian

commit 9c26242
Author: TYCheng <cty120120@gmail.com>
Date:   Wed Sep 25 20:14:05 2024 +0800

    update source files

commit db1fd00
Author: TYCheng <cty120120@gmail.com>
Date:   Wed Sep 25 20:13:09 2024 +0800

    Squashed commit of the following:

    commit 687c4bb
    Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
    Date:   Fri Aug 23 18:03:40 2024 +0800

        sampling order (tpl_sim) and vcp_from_sim (#25)

        * Update python-package.yml
        util.__init__ : ref_count_hfunc() to greedily find tpl_sim with min hfunc calls
        vinecop._data_vcp : one visit() for both hfunc and hinv in sim
        vinecop._factory_vcp: code refactoring to include the above

        * pyproject.toml, stdtr/stdtrit, README
        drop torch dependency for user customization

        * Update .yml
        pytest ./tests
        matrix.os

        * README, test_vinecop

        * sampling order, simplified

commit 7a713c2
Author: TYCheng <cty120120@gmail.com>
Date:   Wed Sep 25 20:10:33 2024 +0800

    _data_vcp: sim, is_antithetic

commit a587c0a
Author: TYCheng <cty120120@gmail.com>
Date:   Wed Sep 25 20:04:51 2024 +0800

    Squashed commit of the following:

    commit 687c4bb
    Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
    Date:   Fri Aug 23 18:03:40 2024 +0800

        sampling order (tpl_sim) and vcp_from_sim (#25)

        * Update python-package.yml
        util.__init__ : ref_count_hfunc() to greedily find tpl_sim with min hfunc calls
        vinecop._data_vcp : one visit() for both hfunc and hinv in sim
        vinecop._factory_vcp: code refactoring to include the above

        * pyproject.toml, stdtr/stdtrit, README
        drop torch dependency for user customization

        * Update .yml
        pytest ./tests
        matrix.os

        * README, test_vinecop

        * sampling order, simplified

commit b62dfa4
Author: ian <tycheng@nus.edu.sg>
Date:   Thu Aug 29 10:20:08 2024 +0800

    _data_vcp: sim, antithetic variates

commit 8acf040
Author: ian <tycheng@nus.edu.sg>
Date:   Fri Aug 23 17:48:18 2024 +0800

    sampling order, simplified

commit 25646ba
Merge: ea8f5c1 ac42d78
Author: ian <tycheng@nus.edu.sg>
Date:   Fri Aug 23 17:46:32 2024 +0800

    Merge branch 'main' into dev_ian

commit ea8f5c1
Merge: c9559cf f932d88
Author: ian <tycheng@nus.edu.sg>
Date:   Wed Jul 17 23:03:29 2024 +0800

    Merge branch 'main' into dev_ian

commit c9559cf
Author: ian <tycheng@nus.edu.sg>
Date:   Wed Jul 17 23:03:23 2024 +0800

    README, test_vinecop

commit 64ec149
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Jul 16 11:30:55 2024 +0800

    Update .yml

    pytest ./tests
    matrix.os

commit 203dd87
Merge: 2576acc a8de187
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Jul 16 11:30:38 2024 +0800

    Merge branch 'main' into dev_ian

commit 2576acc
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Jul 16 11:08:36 2024 +0800

    pyproject.toml, stdtr/stdtrit, README

    drop torch dependency for user customization

commit acfc50e
Merge: 33022c0 20dece8
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Jul 2 21:43:48 2024 +0800

    Merge branch 'main' into dev_ian

commit 33022c0
Author: ian <tycheng@nus.edu.sg>
Date:   Tue Jul 2 21:15:36 2024 +0800

    v2024.7.0

    util.__init__ : ref_count_hfunc() to greedily find tpl_sim with min hfunc calls
    vinecop._data_vcp : one visit() for both hfunc and hinv in sim
    vinecop._factory_vcp: code refactoring to include the above

commit d203c34
Merge: 1d367d7 72a37a3
Author: ian <tycheng@nus.edu.sg>
Date:   Mon Jun 24 19:55:55 2024 +0800

    Merge branch 'main' into dev_ian

commit 1d367d7
Merge: b943dc0 057d3ef
Author: ian <tycheng@nus.edu.sg>
Date:   Mon Jun 24 14:49:51 2024 +0800

    Merge branch 'main' into dev_ian

commit b943dc0
Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
Date:   Mon Jun 24 14:42:01 2024 +0800

    Update python-package.yml

commit 48b0aab
Author: Tuoyuan Cheng <tycheng@nus.edu.sg>
Date:   Mon Jun 24 14:39:30 2024 +0800

    Update python-package.yml

commit 4e87861
Author: ian <tycheng@nus.edu.sg>
Date:   Mon Jun 24 14:31:09 2024 +0800

    Update python-package.yml
Co-Authored-By: Gaurav Agrawal <63945607+gagrawal009@users.noreply.github.com>
@TY-Cheng TY-Cheng requested a review from Copilot May 28, 2025 08:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds non‐parametric bivariate copula functionality (tll, fastKDE) and multiple new usage examples, updates configuration, CI workflows, and documentation to support these features.

  • Introduce a new MNIST VAE experiment (examples/vcae_mnist) with seed control and logging
  • Add prediction‐interval examples (examples/pred_intvl) using vine copulas, ensembles, MC dropout, and BNNs
  • Revise docs, README, and GitHub Actions to integrate new dependencies (fastkde, uv) and deployment steps

Reviewed Changes

Copilot reviewed 55 out of 55 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
examples/vcae_mnist/vcae_mnist/experiment.py New experiment runner for VAE + vine copula on MNIST
examples/vcae_mnist/vcae_mnist/config.py Configuration dataclass and device settings
examples/vcae_mnist/run_seeds.sh Bash script to launch experiments over seed ranges
examples/vcae_mnist/run_seeds.py Python script orchestrating seed‐based experiments
examples/pred_intvl/vine_wrapper.py Wrapper functions for vine copula training and sampling
examples/pred_intvl/models.py Regression models and prediction‐interval methods
examples/pred_intvl/*.py/** Orchestration, data loading, and logging utilities
docs/* Documentation updates (index, conf.py)
README.md Dependency list updates and installation instructions
.github/workflows/*.yml CI/CD workflow revisions for linting, docs, and release
Comments suppressed due to low confidence (1)

examples/pred_intvl/vine_wrapper.py:34

  • [nitpick] Using _ as both the loop variable and a placeholder can be confusing; rename the loop variable to something like dim_idx for clarity.
    dct_v_s_obs = {(_,): Z_test[:, [_]] for _ in range(Z_test.shape[1])}

np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.benchmark = True
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

Enabling both cudnn.benchmark = True and cudnn.deterministic = True can lead to nondeterministic behavior; consider disabling benchmark for strict reproducibility.

Suggested change
torch.backends.cudnn.benchmark = True
torch.backends.cudnn.benchmark = False

Copilot uses AI. Check for mistakes.
end=$((i + 10))
name="seeds_${i}_${end}"
echo "Launching $name"
nohup "$PYTHON_BIN" run_seeds.py $i $end > logs/$name.log 2>&1 &
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

The logs/ directory may not exist before redirection, causing failures; add mkdir -p logs before the loop to ensure the directory is created.

Copilot uses AI. Check for mistakes.
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
# ALso allow manual dispatch
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

Typo in comment: ALso should be Also.

Suggested change
# ALso allow manual dispatch
# Also allow manual dispatch

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +59
self.encoder = nn.Sequential(
nn.Linear(input_dim, hidden_dim1),
nn.BatchNorm1d(hidden_dim1),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim1, hidden_dim2),
nn.BatchNorm1d(hidden_dim2),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim2, latent_dim),
nn.BatchNorm1d(latent_dim),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(latent_dim, hidden_dim3),
nn.BatchNorm1d(hidden_dim3),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim3, hidden_dim4),
nn.BatchNorm1d(hidden_dim4),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim4, hidden_dim5),
nn.BatchNorm1d(hidden_dim5),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim5, latent_dim),
nn.BatchNorm1d(latent_dim),
nn.Tanh(), # keeps latent coords in [–1,1]
)
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

[nitpick] The encoder consists of repeated blocks of Linear➔BatchNorm➔LeakyReLU➔Dropout; consider generating these layers via a loop or helper to reduce duplication and ease future modifications.

Suggested change
self.encoder = nn.Sequential(
nn.Linear(input_dim, hidden_dim1),
nn.BatchNorm1d(hidden_dim1),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim1, hidden_dim2),
nn.BatchNorm1d(hidden_dim2),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim2, latent_dim),
nn.BatchNorm1d(latent_dim),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(latent_dim, hidden_dim3),
nn.BatchNorm1d(hidden_dim3),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim3, hidden_dim4),
nn.BatchNorm1d(hidden_dim4),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim4, hidden_dim5),
nn.BatchNorm1d(hidden_dim5),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
#
nn.Linear(hidden_dim5, latent_dim),
nn.BatchNorm1d(latent_dim),
nn.Tanh(), # keeps latent coords in [–1,1]
)
def _make_block(in_dim, out_dim, p_drop):
return [
nn.Linear(in_dim, out_dim),
nn.BatchNorm1d(out_dim),
nn.LeakyReLU(0.1, inplace=True),
nn.Dropout(p_drop),
]
encoder_layers = []
layer_dims = [
(input_dim, hidden_dim1),
(hidden_dim1, hidden_dim2),
(hidden_dim2, latent_dim),
(latent_dim, hidden_dim3),
(hidden_dim3, hidden_dim4),
(hidden_dim4, hidden_dim5),
(hidden_dim5, latent_dim),
]
for in_dim, out_dim in layer_dims:
encoder_layers.extend(_make_block(in_dim, out_dim, p_drop))
# Add final Tanh layer
encoder_layers.append(nn.Tanh()) # keeps latent coords in [–1,1]
self.encoder = nn.Sequential(*encoder_layers)

Copilot uses AI. Check for mistakes.
TY-Cheng added 3 commits May 28, 2025 17:42
uv run docformatter --in-place torchvinecopulib
uvx ruff format ./**/*.py ./**/*.ipynb
uv run flake8 ./torchvinecopulib --exclude .venv --count --select=E9,F63,F7,F82 --show-source --statistics
uv run flake8 ./torchvinecopulib --count --exit-zero --max-complexity=10 --max-line-length=127 --ignore=E203,W503,E501,C901 --statistics

Whitespace before ':' (E203)
Line break occurred before a binary operator (W503)
Line too long (82 > 79 characters) (E501)
Function is too complex (C901)
@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for a7b356f1 96.64%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a7b356f) Report Missing Report Missing Report Missing
Head commit (db5cd44) 907 877 96.69%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#38) 893 863 96.64%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@TY-Cheng TY-Cheng merged commit c6bc43d into main May 28, 2025
7 of 8 checks passed
@TY-Cheng TY-Cheng deleted the dev_tll branch May 28, 2025 11:26
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.

3 participants