|
| 1 | +# Range–CoMine (demo implementation) |
| 2 | + |
| 3 | +This repository contains a **reference implementation** of *Range–CoMine* (single‑pass colocation mining for a **distance range**) and two baselines (Naive and RangeInc‑Mining). It is designed for clarity and correctness on small–medium datasets. |
| 4 | + |
| 5 | +## Quick start |
| 6 | + |
| 7 | +```bash |
| 8 | +# (In this folder) |
| 9 | +python -m range_comine.cli --synthetic --features 4 --instances 6 --d1 10 --d2 35 --min_prev 0.5 --algo range_comine |
| 10 | +``` |
| 11 | + |
| 12 | +Use the baselines: |
| 13 | +```bash |
| 14 | +python -m range_comine.cli --synthetic --features 4 --instances 6 --d1 10 --d2 35 --min_prev 0.5 --algo naive |
| 15 | +python -m range_comine.cli --synthetic --features 4 --instances 6 --d1 10 --d2 35 --min_prev 0.5 --algo range_inc |
| 16 | +``` |
| 17 | + |
| 18 | +## Data format |
| 19 | + |
| 20 | +If using real data, prepare a CSV with header: |
| 21 | +``` |
| 22 | +id,feature,x,y |
| 23 | +A.1,A,12.3,45.6 |
| 24 | +... |
| 25 | +``` |
| 26 | + |
| 27 | +## Notes |
| 28 | + |
| 29 | +- This demo uses an O(n^2) star‑neighborhood build and a naive clique enumeration for k≥3. It is faithful to the paper’s logic but not tuned for very large datasets. |
| 30 | +- For production scale, replace the neighbor construction with an **R‑tree/IR‑tree** and use a **join‑less** clique enumeration with star instances as in the paper. |
| 31 | +- The **critical distance** computation follows the 3‑step procedure (map → cumulative union → PI sweep) and **CDMP** pruning. |
| 32 | + |
| 33 | +## Citation |
| 34 | + |
| 35 | +Please cite the original paper when using this code. |
| 36 | + |
| 37 | + |
| 38 | +## Credits |
| 39 | + |
| 40 | +This reference implementation follows the ideas presented in: |
| 41 | + |
| 42 | +> **Srikanth Baride, Anuj S. Saxena, Vikram Goyal.** *Efficiently Mining Colocation Patterns for Range Query.* **Big Data Research**, 31:100369, 2023. |
| 43 | +
|
| 44 | +If you use this repository in academic work, please cite the above paper. (BibTeX sketch) |
| 45 | + |
| 46 | +```bibtex |
| 47 | +@article{Baride2023RangeCoMine, |
| 48 | + title = {Efficiently Mining Colocation Patterns for Range Query}, |
| 49 | + author = {Baride, Srikanth and Saxena, Anuj S. and Goyal, Vikram}, |
| 50 | + journal = {Big Data Research}, |
| 51 | + volume = {31}, |
| 52 | + pages = {100369}, |
| 53 | + year = {2023}, |
| 54 | + issn = {2214-5796} |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | + |
| 59 | +## Experiments (CLI + SVG export) |
| 60 | + |
| 61 | +Synthetic: |
| 62 | +```bash |
| 63 | +python experiments.py --mode min_prev --mins 0.2,0.4,0.6 --d1 10 --d2 35 --features 4 --instances 8 --seed 13 --algos range,naive,range_inc --export_svg |
| 64 | +``` |
| 65 | + |
| 66 | +CSV dataset: |
| 67 | +```bash |
| 68 | +python experiments.py --mode range --min_prev 0.5 --d1s 5,10 --d2s 20,30 --csv examples/toy.csv --algos range,naive --export_svg |
| 69 | +``` |
| 70 | + |
| 71 | +## Lattice export (PDF/SVG) |
| 72 | +```bash |
| 73 | +python lattice_export.py --outfile lattice_demo --d1 8 --d2 30 --min_prev 0.5 --features 4 --instances 5 --seed 7 |
| 74 | +# outputs plots/lattice_demo.pdf and plots/lattice_demo.svg |
| 75 | +``` |
| 76 | + |
| 77 | +## Tests |
| 78 | +```bash |
| 79 | +pytest -q |
| 80 | +``` |
| 81 | + |
| 82 | + |
| 83 | +## Makefile shortcuts |
| 84 | +```bash |
| 85 | +make install # deps |
| 86 | +make test # run pytest |
| 87 | +make plots # quick sweeps + SVG |
| 88 | +make lattice # lattice export (PDF/SVG/PNG, cross-level edges) |
| 89 | +make all # install + test + plots + lattice |
| 90 | +``` |
| 91 | + |
| 92 | +## CI (GitHub Actions) |
| 93 | +A workflow at `.github/workflows/ci.yml` runs: |
| 94 | +- `pytest` |
| 95 | +- sample experiments (min_prev/range) with SVG export |
| 96 | +- lattice export with cross-level edges and PNG |
| 97 | +- uploads `plots/` as build artifacts |
| 98 | + |
| 99 | + |
| 100 | +## Packaging |
| 101 | +Install in editable/development mode: |
| 102 | +```bash |
| 103 | +./dev_install.sh |
| 104 | +# or |
| 105 | +pip install -e . |
| 106 | +``` |
| 107 | + |
| 108 | + |
| 109 | +## Console scripts |
| 110 | +After `pip install -e .`, you can run: |
| 111 | +```bash |
| 112 | +range-comine-cli --synthetic --features 4 --instances 6 --d1 10 --d2 35 --min_prev 0.5 --algo range_comine |
| 113 | +range-comine-exp --mode min_prev --mins 0.2,0.4,0.6 --d1 10 --d2 35 --features 4 --instances 8 --seed 13 --algos range,naive,range_inc --export_svg |
| 114 | +range-comine-lattice --outfile lattice_demo --d1 8 --d2 30 --min_prev 0.5 --features 4 --instances 5 --seed 7 --cross_level --png |
| 115 | +``` |
| 116 | + |
| 117 | +## Lockfiles |
| 118 | +- Classic pip: |
| 119 | + ```bash |
| 120 | + make lock # creates requirements.lock via pip freeze |
| 121 | + ``` |
| 122 | +- Using **uv**: |
| 123 | + ```bash |
| 124 | + uv venv && uv pip install -e . |
| 125 | + uv lock # creates uv.lock |
| 126 | + ``` |
| 127 | + |
| 128 | +## Docker |
| 129 | +```bash |
| 130 | +make docker-build # build image |
| 131 | +make docker-test # run tests in container |
| 132 | +make docker-minprev # min_prev sweep (plots mounted to ./plots) |
| 133 | +make docker-range # range sweep (plots mounted to ./plots) |
| 134 | +make docker-lattice # lattice export (PDF/SVG/PNG) |
| 135 | +``` |
0 commit comments