Skip to content

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 data partitions, specifically to highlight the differences between label clusters and instance clusters.

License

Notifications You must be signed in to change notification settings

cissagatto/plotHPML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plot Hybrid Partitions for Multi-Label Classification

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.

How to cite

@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}
}

CSV Example

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

Notes:

  • 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.

Instalation

# install.packages("devtools")
library("devtools")
devtools::install_github("https://github.com/cissagatto/plotHPML")
library(plotHPML)

How to Use the Code

1. Package

First, install and call the package plotHPML.

library(plotHPML)

2. Plotting Hybrid Partitions

You can generate and save two types of plots for the hybrid partitions:

A. A Heatmap for Multiple 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")

B. Hybrid Partition itself

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)

4. Output

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.

Documentation

For more detailed documentation on each function, check out the ~/WinTieLoss/docs folder. A complete example is available in ~/WinTieLoss/example folder.

Folder Structure

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.

📚 Contributing

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.

Acknowledgment

  • 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.

📧 Contact

For any questions or support, please contact:

Links

| 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 🎉

About

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 data partitions, specifically to highlight the differences between label clusters and instance clusters.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages