Skip to content

Commit

Permalink
WInLDL
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteMisaka committed Aug 19, 2024
1 parent 61e9673 commit 635c876
Show file tree
Hide file tree
Showing 37 changed files with 539 additions and 98 deletions.
56 changes: 30 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,45 @@
Label distribution learning (LDL) and label enhancement (LE) toolkit implemented in python, including:

+ LDL algorithms:
+ ([Geng, Yin, and Zhou 2013](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/geng2013.pdf))[*TPAMI*]: `CPNN`$^1$.
+ ([Geng and Hou 2015](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/geng2015.pdf))[*IJCAI*]: `LDSVR`.
+ ⭐([Geng 2016](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/geng2016.pdf))[*TKDE*]: `SA_BFGS`, `SA_IIS`, `AA_KNN`, `AA_BP`, `PT_Bayes`, and `PT_SVM`.
+ ([Yang, Sun, and Sun 2017](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/yang2017.pdf))[*AAAI*]: `BCPNN` and `ACPNN`.
+ ([Xu and Zhou 2017](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/xu2017.pdf))[*IJCAI*]: `IncomLDL`$^2$.
+ ([Shen et al. 2017](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/shen2017.pdf))[*NeurIPS*]: `LDLF`.
+ ([Wang and Geng 2019](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/wang2019.pdf))[*IJCAI*]: `LDL4C`$^3$.
+ ([Shen et al. 2020](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/shen2020.pdf))[*南京理工大学学报* (Chinese)]: `AdaBoostLDL`.
+ ([González et al. 2021a](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/gonz%C3%A1lez2021a.pdf))[*Inf. Sci.*]: `SSG_LDL`$^4$.
+ ([González et al. 2021b](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/gonz%C3%A1lez2021b.pdf))[*Inf. Fusion*]: `DF_LDL`.
+ ([Wang and Geng 2021a](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/wang2021a.pdf))[*IJCAI*]: `LDL_HR`$^3$.
+ ([Wang and Geng 2021b](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/wang2021b.pdf))[*ICML*]: `LDLM`$^3$.
+ ([Jia et al. 2021](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/jia2021.pdf))[*TKDE*]: `LDL_SCL`.
+ ([Jia et al. 2023a](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/jia2023a.pdf))[*TKDE*]: `LDL_LRR`.
+ ([Jia et al. 2023b](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/jia2023b.pdf))[*TNNLS*]: `LDL_DPA`.
+ ([Wen et al. 2023](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/wen2023.pdf))[*ICCV*]: `CAD`$^1$, `QFD2`$^1$, and `CJS`$^1$.
+ [Geng, Yin, and Zhou 2013](https://doi.org/10.1109/tpami.2013.51)) [*TPAMI*]: `CPNN`$^1$.
+ ([Geng and Hou 2015](https://www.ijcai.org/Abstract/15/494)) [*IJCAI*]: `LDSVR`.
+ ⭐([Geng 2016](https://doi.org/10.1109/TKDE.2016.2545658)) [*TKDE*]: `SA_BFGS`, `SA_IIS`, `AA_KNN`, `AA_BP`, `PT_Bayes`, and `PT_SVM`.
+ ([Yang, Sun, and Sun 2017](https://doi.org/10.1609/aaai.v31i1.10485)) [*AAAI*]: `BCPNN` and `ACPNN`.
+ ([Xu and Zhou 2017](https://doi.org/10.24963/ijcai.2017/443)) [*IJCAI*]: `IncomLDL`$^2$.
+ ([Shen et al. 2017](https://papers.nips.cc/paper_files/paper/2017/hash/6e2713a6efee97bacb63e52c54f0ada0-Abstract.html)) [*NeurIPS*]: `LDLF`.
+ ([Wang and Geng 2019](https://doi.org/10.24963/ijcai.2019/515)) [*IJCAI*]: `LDL4C`$^3$.
+ ([Shen et al. 2020](https://dx.doi.org/10.14177/j.cnki.32-1397n.2020.44.06.004)) [*南京理工大学学报* (Chinese)]: `AdaBoostLDL`.
+ ([González et al. 2021a](https://doi.org/10.1016/j.ins.2020.07.071)) [*Inf. Sci.*]: `SSG_LDL`$^4$.
+ ([González et al. 2021b](https://doi.org/10.1016/j.inffus.2020.08.024)) [*Inf. Fusion*]: `DF_LDL`.
+ ([Wang and Geng 2021a](https://doi.org/10.24963/ijcai.2021/426)) [*IJCAI*]: `LDL_HR`$^3$.
+ ([Wang and Geng 2021b](https://proceedings.mlr.press/v139/wang21h.html)) [*ICML*]: `LDLM`$^3$.
+ ([Jia et al. 2021](https://doi.org/10.1109/TKDE.2019.2943337)) [*TKDE*]: `LDL_SCL`.
+ ([Jia et al. 2023a](https://doi.org/10.1109/TKDE.2021.3099294)) [*TKDE*]: `LDL_LRR`.
+ ([Jia et al. 2023b](https://doi.org/10.1109/TNNLS.2023.3258976)) [*TNNLS*]: `LDL_DPA`.
+ ([Wen et al. 2023](https://doi.org/10.1109/ICCV51070.2023.02146)) [*ICCV*]: `CAD`$^1$, `QFD2`$^1$, and `CJS`$^1$.
+ ([Li and Chen 2024](https://doi.org/10.24963/ijcai.2024/494)) [*IJCAI*]: `WInLDL`$^2$.
+ ([Wu, Li, and Jia 2024](https://doi.org/10.1109/TBDATA.2024.3442562)) [*TBD*]: `LDL_DA`$^5$.
+ LE algorithms:
+ ([Xu, Liu, and Geng 2019](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/xu2019.pdf))[*TKDE*]: `FCM`, `KM`, `LP`, `ML`, and `GLLE`.
+ ([Xu et al. 2020](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/xu2020.pdf))[*ICML*]: `LEVI`.
+ ([Zheng, Zhu, and Tang 2023](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/zheng2023.pdf))[*CVPR*]: `LIBLE`.
+ ([Xu, Liu, and Geng 2019](https://doi.org/10.1109/TKDE.2019.2947040)) [*TKDE*]: `FCM`, `KM`, `LP`, `ML`, and `GLLE`.
+ ([Xu et al. 2020](https://proceedings.mlr.press/v119/xu20g.html)) [*ICML*]: `LEVI`.
+ ([Zheng, Zhu, and Tang 2023](https://doi.org/10.1109/CVPR52729.2023.00724)) [*CVPR*]: `LIBLE`.
+ LDL metrics: `chebyshev`, `clark`, `canberra`, `kl_divergence`, `cosine`, `intersection`, etc.
+ Structured LDL datasets: *Human_Gene*, *Movie*, *Natural_Scene*, *s-BU_3DFE*, *s-JAFFE*, *Yeast*, etc.
+ LDL applications:
+ Facial emotion recognition (supported datasets: [*JAFFE*](https://zenodo.org/records/3451524))
+ ([Shirani et al. 2019](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/shirani2019.pdf))[*ACL*]: Emphasis selection (supported datasets: [*SemEval2020*](https://github.com/RiTUAL-UH/SemEval2020_Task10_Emphasis_Selection); pre-trained GloVe embeddings can be downloaded [here](https://nlp.stanford.edu/projects/glove/)).
+ ([Wu et al. 2019](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/wu2019.pdf))[*ICCV*]: Lesion counting (supported datasets: [*ACNE04*](https://drive.google.com/drive/folders/18yJcHXhzOv7H89t-Lda6phheAicLqMuZ)).
+ ([Chen et al. 2020](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/chen2020.pdf))[*CVPR*]: Facial emotion recognition with auxiliary label space graphs (supported datasets: [*CK+*](https://www.jeffcohn.net/Resources/); OpenFace can be downloaded [here](https://github.com/TadasBaltrusaitis/OpenFace/releases), and the required models can be downloaded [here](https://github.com/TadasBaltrusaitis/OpenFace/wiki/Model-download)).
+ Facial emotion recognition (supported datasets: [*JAFFE*](https://zenodo.org/records/3451524) and [*BU-3DFE*](https://www.cs.binghamton.edu/~lijun/Research/3DFE/3DFE_Analysis.html))
+ ([Shirani et al. 2019](https://doi.org/10.18653/v1/P19-1112)) [*ACL*]: Emphasis selection (supported datasets: [*SemEval2020*](https://github.com/RiTUAL-UH/SemEval2020_Task10_Emphasis_Selection); pre-trained GloVe embeddings can be downloaded [here](https://nlp.stanford.edu/projects/glove/)).
+ ([Wu et al. 2019](https://doi.org/10.1109/ICCV.2019.01074)) [*ICCV*]: Lesion counting (supported datasets: [*ACNE04*](https://drive.google.com/drive/folders/18yJcHXhzOv7H89t-Lda6phheAicLqMuZ)).
+ ([Chen et al. 2020](https://doi.org/10.1109/CVPR42600.2020.01400)) [*CVPR*]: Facial emotion recognition with auxiliary label space graphs (supported datasets: [*CK+*](https://www.jeffcohn.net/Resources/); OpenFace can be downloaded [here](https://github.com/TadasBaltrusaitis/OpenFace/releases), and the required models can be downloaded [here](https://github.com/TadasBaltrusaitis/OpenFace/wiki/Model-download)).

> $^1$ Technically, these methods are only suitable for totally ordered labels.
>
> $^2$ These are algorithms for incomplete LDL, so you should use `pyldl.utils.random_missing` to generate the missing label distribution matrix and the corresponding mask matrix in the experiments.
> $^2$ These are algorithms for incomplete LDL, so you should use `pyldl.utils.random_missing` to generate the missing label distribution matrix and the corresponding mask matrix in the experiments. [Here](https://github.com/SpriteMisaka/PyLDL/blob/main/demo/incomplete_settings.ipynb) is a demo on using the incomplete LDL algorithms.
>
> $^3$ These are LDL classifiers, so you should use `predict_proba` to get label distributions and `predict` to get predicted labels.
>
> $^4$ These are oversampling algorithms for LDL, therefore you should use `fit_transform` to generate synthetic samples.
>
> $^5$: To use domain adaptation methods for LDL, you need to provide the source domain data via parameters `sX` and `sy` of the `fit` method. [Here](https://github.com/SpriteMisaka/PyLDL/blob/main/demo/domain_adaptation.ipynb) is a demo on domain adaptation for LDL.
## Installation

Expand Down Expand Up @@ -89,7 +93,7 @@ Now, you can load the original implementation of the method, e.g.:
from pyldl.matlab_algorithms import SA_IIS
```

You can visualize the performance of any model on the artificial dataset ([Geng 2016](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/geng2016.pdf)) with the `pyldl.utils.plot_artificial` function, e.g.:
You can visualize the performance of any model on the artificial dataset ([Geng 2016](https://doi.org/10.1109/TKDE.2016.2545658)) with the `pyldl.utils.plot_artificial` function, e.g.:

```python
from pyldl.algorithms import LDSVR, SA_BFGS, SA_IIS, AA_KNN, PT_Bayes, GLLE, LIBLE
Expand Down Expand Up @@ -137,7 +141,7 @@ Results of ours are as follows.
| PT-Bayes | .116 ± .011 | .425 ± .031 | .874 ± .064 | .073 ± .012 | .932 ± .011 | .850 ± .012 |
| PT-SVM | .117 ± .012 | .422 ± .027 | .875 ± .057 | .072 ± .011 | .932 ± .011 | .850 ± .011 |

Results of the original MATLAB implementation ([Geng 2016](https://github.com/SpriteMisaka/PyLDL/blob/main/bibliography/geng2016.pdf)) are as follows.
Results of the original MATLAB implementation ([Geng 2016](https://doi.org/10.1109/TKDE.2016.2545658)) are as follows.

| Algorithm | Cheby.(↓) | Clark(↓) | Can.(↓) | K-L(↓) | Cos.(↑) | Int.(↑) |
| :-------: | :-------------: | :-------------: | :-------------: | :-------------: | :-------------: | :-------------: |
Expand Down
Binary file removed bibliography/chen2020.pdf
Binary file not shown.
Binary file removed bibliography/geng2013.pdf
Binary file not shown.
Binary file removed bibliography/geng2015.pdf
Binary file not shown.
Binary file removed bibliography/geng2016.pdf
Binary file not shown.
Binary file removed bibliography/gonzález2021a.pdf
Binary file not shown.
Binary file removed bibliography/gonzález2021b.pdf
Binary file not shown.
Binary file removed bibliography/jia2021.pdf
Binary file not shown.
Binary file removed bibliography/jia2023a.pdf
Binary file not shown.
Binary file removed bibliography/jia2023b.pdf
Binary file not shown.
Binary file removed bibliography/shen2017.pdf
Binary file not shown.
Binary file removed bibliography/shen2020.pdf
Binary file not shown.
Binary file removed bibliography/shirani2019.pdf
Binary file not shown.
Binary file removed bibliography/wang2019.pdf
Binary file not shown.
Binary file removed bibliography/wang2021a.pdf
Binary file not shown.
Binary file removed bibliography/wang2021b.pdf
Binary file not shown.
Binary file removed bibliography/wen2023.pdf
Binary file not shown.
Binary file removed bibliography/wu2019.pdf
Binary file not shown.
Binary file removed bibliography/xu2017.pdf
Binary file not shown.
Binary file removed bibliography/xu2019.pdf
Binary file not shown.
Binary file removed bibliography/xu2020.pdf
Binary file not shown.
Binary file removed bibliography/yang2017.pdf
Binary file not shown.
Binary file removed bibliography/zheng2023.pdf
Binary file not shown.
82 changes: 63 additions & 19 deletions demo/incomplete_settings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"metadata": {},
"outputs": [],
"source": [
"from pyldl.algorithms import IncomLDL, SA_BFGS\n",
"from pyldl.algorithms import IncomLDL, WInLDL, SA_BFGS\n",
"from pyldl.utils import load_dataset, random_missing"
]
},
Expand All @@ -38,7 +38,7 @@
"metadata": {},
"outputs": [],
"source": [
"y_missing, mask = random_missing(y, missing_rate=.9)"
"y_missing, mask = random_missing(y, missing_rate=.8)"
]
},
{
Expand Down Expand Up @@ -68,7 +68,7 @@
"metadata": {},
"outputs": [],
"source": [
"incomldl.fit(X, y_missing, mask=mask)"
"incomldl.fit(X, y_missing, mask=mask);"
]
},
{
Expand All @@ -81,12 +81,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"chebyshev 0.107078\n",
"clark 0.383754\n",
"canberra 0.773841\n",
"kl_divergence 0.061603\n",
"cosine 0.941953\n",
"intersection 0.868440\n",
"chebyshev 0.103008\n",
"clark 0.366500\n",
"canberra 0.699817\n",
"kl_divergence 0.057294\n",
"cosine 0.945605\n",
"intersection 0.879389\n",
"dtype: float64\n"
]
}
Expand All @@ -98,6 +98,50 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "3da583a8",
"metadata": {},
"outputs": [],
"source": [
"winldl = WInLDL()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "9880abd0",
"metadata": {},
"outputs": [],
"source": [
"winldl.fit(X, y_missing, mask=mask);"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "26195ba8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"chebyshev 0.086545\n",
"clark 0.326738\n",
"canberra 0.628083\n",
"kl_divergence 0.041396\n",
"cosine 0.961706\n",
"intersection 0.894525\n",
"dtype: float64\n"
]
}
],
"source": [
"print(pd.Series(winldl.score(X, y), index=metrics))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "2aaef4f3-2ab9-4630-ad82-742511e1c599",
"metadata": {},
"outputs": [],
Expand All @@ -107,30 +151,30 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"id": "e411e05d-40ce-4d5e-8316-bb243529043b",
"metadata": {},
"outputs": [],
"source": [
"bfgs.fit(X, y_missing)"
"bfgs.fit(X, y_missing);"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"id": "0af220c7-9a88-4fb9-91f6-1764b5c4adac",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"chebyshev 0.120746\n",
"clark 0.427860\n",
"canberra 0.898344\n",
"kl_divergence 0.073986\n",
"cosine 0.930277\n",
"intersection 0.846990\n",
"chebyshev 0.120316\n",
"clark 0.429790\n",
"canberra 0.902958\n",
"kl_divergence 0.074000\n",
"cosine 0.930210\n",
"intersection 0.846223\n",
"dtype: float64\n"
]
}
Expand Down Expand Up @@ -164,7 +208,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.9.17"
}
},
"nbformat": 4,
Expand Down
49 changes: 45 additions & 4 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ <h1 id="index">Index</h1>

<div class="genindex-jumpbox">
<a href="#_"><strong>_</strong></a>
| <a href="#A"><strong>A</strong></a>
| <a href="#F"><strong>F</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#L"><strong>L</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#W"><strong>W</strong></a>

</div>
<h2 id="_">_</h2>
Expand All @@ -49,11 +52,23 @@ <h2 id="_">_</h2>
</ul></td>
</tr></table>

<h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyldl.algorithms.LDL_DA.augment">augment() (pyldl.algorithms.LDL_DA static method)</a>
</li>
</ul></td>
</tr></table>

<h2 id="F">F</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyldl.algorithms.base._Base.fit">fit() (pyldl.algorithms.base._Base method)</a>

<ul>
<li><a href="index.html#pyldl.algorithms.LDL_DA.fit">(pyldl.algorithms.LDL_DA method)</a>
</li>
</ul></li>
</ul></td>
</tr></table>

Expand All @@ -74,11 +89,13 @@ <h2 id="L">L</h2>
</li>
<li><a href="index.html#pyldl.algorithms.LDL_DPA">LDL_DPA (class in pyldl.algorithms)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyldl.algorithms.LDL_HR">LDL_HR (class in pyldl.algorithms)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyldl.algorithms.LDL_LRR">LDL_LRR (class in pyldl.algorithms)</a>
</li>
<li><a href="index.html#pyldl.algorithms.LDL_SCL">LDL_SCL (class in pyldl.algorithms)</a>
</li>
<li><a href="index.html#pyldl.algorithms.LDLF">LDLF (class in pyldl.algorithms)</a>
</li>
Expand Down Expand Up @@ -109,22 +126,30 @@ <h2 id="M">M</h2>
<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyldl.algorithms.LDL_DA.pairwise_cosine">pairwise_cosine() (pyldl.algorithms.LDL_DA static method)</a>
</li>
<li><a href="index.html#pyldl.algorithms.LDL_DA.pairwise_euclidean">pairwise_euclidean() (pyldl.algorithms.LDL_DA static method)</a>
</li>
<li><a href="index.html#pyldl.algorithms.LDL_DA.pairwise_jsd">pairwise_jsd() (pyldl.algorithms.LDL_DA static method)</a>
</li>
<li><a href="index.html#pyldl.algorithms.LDL_DA.pairwise_label">pairwise_label() (pyldl.algorithms.LDL_DA static method)</a>
</li>
<li>
pyldl.algorithms

<ul>
<li><a href="index.html#module-pyldl.algorithms">module</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
pyldl.algorithms.base

<ul>
<li><a href="index.html#module-pyldl.algorithms.base">module</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
pyldl.metrics

Expand All @@ -142,6 +167,22 @@ <h2 id="P">P</h2>
</ul></td>
</tr></table>

<h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyldl.algorithms.LDL_DA.reorder_y">reorder_y() (pyldl.algorithms.LDL_DA static method)</a>
</li>
</ul></td>
</tr></table>

<h2 id="W">W</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyldl.algorithms.WInLDL">WInLDL (class in pyldl.algorithms)</a>
</li>
</ul></td>
</tr></table>



</div>
Expand Down
Loading

0 comments on commit 635c876

Please sign in to comment.