This repository contains code for visualizing hybrid partitions, a method that plays a significant role in my PhD thesis. The code is designed to plot label partitions, specifically to highlight the differences between label clusters and instance clusters. However, it can be easily adapted to visualize any type of data partition.
@misc{plotHPML2024,
author = {Elaine Cecília Gatto},
title = {plotHPML: A package to plot label partitions},
year = {2024},
note = {R package version 0.1.0. Licensed under CC BY-NC-SA 4.0},
doi = {10.13140/RG.2.2.11938.44484/1},
url = {https://github.com/cissagatto/plotHPML}
}
The input to the plotting functions is a CSV file formatted as follows:
cluster | label |
---|---|
1 | label_1 |
3 | label_2 |
2 | label_3 |
2 | label_4 |
1 | label_5 |
3 | label_6 |
- The
cluster
column contains the cluster ID to which each label belongs. - The
label
column contains the labels that need to be visualized. - Ensure your CSV follows this structure for correct visualization. An example CSV file is provided in the repository for reference.
# install.packages("devtools")
library("devtools")
devtools::install_github("https://github.com/cissagatto/plotHPML")
library(plotHPML)
First, install and call the package plotHPML.
library(plotHPML)
You can generate and save two types of plots for the hybrid partitions:
To visualize multiple partitions in a heatmap format:
# Load the data for multiple partitions
file.name <- paste(FolderData, "/partition_ex2.csv", sep = "")
partitions <- data.frame(read.csv(file.name))
# Define the output PDF filename
pdf.filename <- paste(FolderPlot, "/partition_ex2.pdf", sep = "")
# Generate and save the heatmap plot
hpml.heatmap(df = partitions,
pdf.filename = pdf.filename,
title = "Partition example 2")
To visualize the hybrid partition see the example bellow. The save.plot.hpml
function save the plot in a PDF format, but you can change that in the code if you want. The plot.hpml
is the function that plot the partiton itsel.
# Load the data for a single partition
file.name <- paste(FolderData, "/partition_ex1.csv", sep = "")
partitions <- data.frame(read.csv(file.name))
# Define the output PDF filename
pdf.filename <- paste(FolderPlot, "/partition_ex1.pdf", sep = "")
# Generate the partition plot
plot.hpml(df = partitions, partition_col = "cluster")
# Save the plot as a PDF
save.plot.hpml(df = partitions, partition_col = "cluster",
filename = pdf.filename, width = 8, height = 8,
units = "in", dpi = 300)
The output will be a PDF file saved in the specified FolderPlot
directory. The plot will show the clusters as circles, with labels grouped inside each cluster.
For more detailed documentation on each function, check out the ~/WinTieLoss/docs
folder.
A complete example is available in ~/WinTieLoss/example
folder.
Ensure the following folder structure is set up:
FolderRoot
: Root directory of the project.FolderData
: Directory where CSV data files are stored.FolderResults
: Directory where results and plots are saved.
We welcome contributions from the community! If you have suggestions, improvements, or bug fixes, please submit a pull request or open an issue in the GitHub repository.
- This study was financed in part by the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brasil (CAPES) - Finance Code 001.
- This study was financed in part by the Conselho Nacional de Desenvolvimento Científico e Tecnológico - Brasil (CNPQ) - Process number 200371/2022-3.
- The authors also thank the Brazilian research agencies FAPESP financial support.
For any questions or support, please contact:
- Prof. Elaine Cecilia Gatto (elainececiliagatto@gmail.com)
| Site | Post-Graduate Program in Computer Science | Computer Department | Biomal | CNPQ | Ku Leuven | Embarcados | Read Prensa | Linkedin Company | Linkedin Profile | Instagram | Facebook | Twitter | Twitch | Youtube |
Happy Hybrid Partitions 🎉