This code is part of my PhD at PPG-CC/DC/UFSCar. The aim is generate hybrid partitions for multilabel classification using Kohonen.
@misc{Gatto2021, author = {Gatto, E. C.}, title = {Generate Kohonen Partitions for Multilabel Classification}, year = {2021}, publisher = {GitHub}, journal = {GitHub repository}, howpublished = {\url{https://github.com/cissagatto/Generate-Partitions-Kohonen}}}
This source code consists of an R project for R Studio and the following R scripts:
- libraries.R
- utils.R
- processKohonen.R
- run.R
- kohonen.R
This code is executed in X-fold cross-validation (mandatory!). First, you have to obtain the X-fold cross-validation files using this code: https://github.com/cissagatto/CrossValidationMultiLabel (all the instructions to use the code are in the Github). After that, put the results generated in the datasets folder in this project. The folder structure generated by the code CrossValidationMultilabel is used here.
Place a copy of this code in "C:/Users/[username]/Generate-Partitions-Jaccard" or "/home/username/Generate-Partitions-Jaccard. Our files are configured to obtain the paths of the folders from the root. You can change this in the code if you want.
A file called datasets.csv must be in the root project folder. This file is used to read information about the datasets and they are used in the code. All 74 datasets available in cometa (https://cometa.ujaen.es/) are in this file. If you want to use another dataset, please, add the following information about the dataset in the file:
Id, Name, Domain, Labels, Instances, Attributes, Inputs, Labelsets, Single, Max freq, Card, Dens, MeanIR, Scumble, TCS, AttStart, AttEnd, LabelStart, LabelEnd, xn, yn, gridn
The Id of the dataset is a mandatory parameter in the command line to run all code. The fields are used in a lot of internal functions. Please, make sure that this information is available before running the code. xn and yn correspond to a dimension of the quadrangular map for kohonen, and gridn is (xn * yn). Example: xn = 4, yn = 4, gridn = 16.
Confirms if the folder UTILS contains the following files: Clus.jar, R_csv_2_arff.jar, and weka.jar. Without these jars, the code not runs. Also, confirms if the folder libs is present with the jars: Clus.jar, commons-math-1.0.jar, jgap.jar and weka.jar.
NOTE: Please, pay attention to the datasets-hpmlk.csv names and the names in the CSV file. They must be the same, on the contrary, an error may occur.
This code was develop in RStudio Version 1.4.1106 © 2009-2021 RStudio, PBC "Tiger Daylily" (2389bc24, 2021-02-11) for Ubuntu Bionic Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36. The R Language version was: R version 4.1.0 (2021-05-18) -- "Camp Pontanezen" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit).
Please, make sure all the dependencies are installed (verify libraries.R). This code does not provide any installation of the packages.
This code may or may not be executed in parallel, however, it is highly recommended that you run it in parallel. The number of cores can be configured via the command line (number_cores). If number_cores = 1 the code will run sequentially. In our experiments, we used 10 cores. For reproducibility, we recommend that you also use ten cores. This code was tested with the birds dataset in the following machine:
System:
Host: bionote | Kernel: 5.8.0-53-generic | x86_64 bits: 64 | Desktop: Gnome 3.36.7 | Distro: Ubuntu 20.04.2 LTS (Focal Fossa)
CPU:
Topology: 6-Core | model: Intel Core i7-10750H | bits: 64 | type: MT MCP | L2 cache: 12.0 MiB | Speed: 800 MHz | min/max: 800/5000 MHz Core speeds (MHz): | 1: 800 | 2: 800 | 3: 800 | 4: 800 | 5: 800 | 6: 800 | 7: 800 | 8: 800 | 9: 800 | 10: 800 | 11: 800 | 12: 800 |
Then the experiment was executed in a cluster at UFSCar.
The results are store in the folder RESULTS. The results stored in the folder OUTPUT it will be used in the next phase: Best-Partition-Silhoute or Best-Partition-MacroF1. The result for a dataset must be put in the folder PARTITIONS in the code https://github.com/cissagatto/Best-Partition-Silhouete.
To run the code, open the terminal, enter /home/[username]/Generate-Partitions-Kohonen/scripts/ folder, and type:
Rscript kohonen.R [number_dataset] [number_cores] [number_folds] [name_folder_results]
Where:
number_dataset is the dataset number in the datasets.csv file
number_cores is the total cores you want to use in parallel execution.
number_folds is the number of folds you want for cross-validation
_name_folders_results is the name of the folder to save the results
All parameters are mandatory. Example:
Rscript kohonen.R 17 5 10 /dev/shm/results/
This will execute the code for the dataset number 17 in the dataset.csv, with 5 cores, 10 folds and the process will be store in the /dev/shm/results/. This code automatically makes a copy of the /dev/shm/results/ in the folder Results - which is in the root of the project. In this way, you can run the code using a temporary folder, like scratch and shm, to speed up the execution.
- 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.
| 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 |