|
1 |
| -# FKL |
| 1 | +# Fair Kernel Learning (FKL) and Feature Analysis Tools |
| 2 | + |
| 3 | +**Version:** 1.0 |
| 4 | +**Release Date:** 2017 |
| 5 | + |
| 6 | +## Overview |
| 7 | +This repository provides the Fair Kernel Learning (FKL) implementation and tools for Feature Discriminative Ratio (FDR) and Feature Kernel Learning (FKL) analysis. The repository also includes utilities for visualization, kernel learning, and fairness-driven learning methods, as presented in the ECML 2017 paper: |
| 8 | + |
| 9 | +**"Fair Kernel Learning"** |
| 10 | +**Authors:** Adrian Perez-Suay, Valero Laparra, Gonzalo Mateo-Garcia, Jordi Muñoz-Marí, Luis Gomez-Chova, Gustau Camps-Valls |
| 11 | +**Image Processing Laboratory (IPL)** - [http://isp.uv.es/](http://isp.uv.es/) |
| 12 | + |
| 13 | +This repository offers utilities for performing fair kernel learning with demographic-aware tools for fairness analysis, particularly for attributes like sex and race. |
| 14 | + |
| 15 | +## Features |
| 16 | +- **Fair Kernel Learning (FKL):** Implementation of fairness-aware learning methods. |
| 17 | +- **FDR Computation:** Calculate Feature Discriminative Ratios (FDR) for datasets. |
| 18 | +- **FKL Computation:** Perform Feature Kernel Learning (FKL) for fairness-based feature selection. |
| 19 | +- **Demographic Analysis:** Specific scripts to analyze fairness performance by demographic subgroups. |
| 20 | +- **Visualization Tools:** |
| 21 | + - `draw_FDR.m`: Plot FDR results. |
| 22 | + - `draw_FKL.m`: Visualize FKL results. |
| 23 | +- **Pre-Loaded Datasets:** Supports a9a dataset from LIBSVM and UCI repositories. |
| 24 | + |
| 25 | +## Usage |
| 26 | +### Example 1: Run Fair Kernel Learning (FKL) |
| 27 | +Run the main script `FKL_2017_ECML.m` to perform Fair Kernel Learning. |
| 28 | + |
| 29 | +```matlab |
| 30 | +% Fair Kernel Learning Example |
| 31 | +clear; clc; close all; |
| 32 | +
|
| 33 | +% Set experiment type for exact reproduction |
| 34 | +exp = 2; |
| 35 | +
|
| 36 | +% Run the main FKL function |
| 37 | +FKL_2017_ECML; |
| 38 | +``` |
| 39 | +**Important Note:** To reproduce the experimental setup exactly as in the ECML 2017 paper, set the variable `exp` to `2` (`exp = 2;`) in the script `FKL_2017_ECML.m`. |
| 40 | + |
| 41 | +### Example 2: Compute Feature Discriminative Ratio (FDR) |
| 42 | +Run `FDR.m` to compute the Feature Discriminative Ratio for your dataset. |
| 43 | + |
| 44 | +```matlab |
| 45 | +% FDR Example |
| 46 | +clear; clc; close all; |
| 47 | +
|
| 48 | +% Load or define data |
| 49 | +X = rand(100, 10); % 100 samples, 10 features |
| 50 | +Y = randi([0, 1], 100, 1); % Binary class labels |
| 51 | +
|
| 52 | +% Compute FDR |
| 53 | +FDR_scores = FDR(X, Y); |
| 54 | +
|
| 55 | +% Display results |
| 56 | +disp('Feature Discriminative Ratios:'); |
| 57 | +disp(FDR_scores); |
| 58 | +``` |
| 59 | + |
| 60 | +### Example 3: Visualize FDR Results |
| 61 | +Use `draw_FDR.m` to visualize FDR scores. |
| 62 | + |
| 63 | +```matlab |
| 64 | +% Visualize FDR |
| 65 | +FDR_scores = rand(1, 10); % Example FDR scores for 10 features |
| 66 | +draw_FDR(FDR_scores); |
| 67 | +
|
| 68 | +% Plot customization |
| 69 | +title('Feature Discriminative Ratios'); |
| 70 | +xlabel('Features'); |
| 71 | +ylabel('FDR Score'); |
| 72 | +``` |
| 73 | + |
| 74 | +### Example 4: Compute Feature Kernel Learning (FKL) |
| 75 | +Run `FKL.m` to compute FKL values for your dataset. |
| 76 | + |
| 77 | +```matlab |
| 78 | +% FKL Example |
| 79 | +clear; clc; close all; |
| 80 | +
|
| 81 | +% Load or define data |
| 82 | +X = rand(100, 10); % 100 samples, 10 features |
| 83 | +Y = randi([0, 1], 100, 1); % Binary class labels |
| 84 | +
|
| 85 | +% Compute FKL |
| 86 | +FKL_scores = FKL(X, Y); |
| 87 | +
|
| 88 | +% Display FKL scores |
| 89 | +disp('Feature Kernel Learning Scores:'); |
| 90 | +disp(FKL_scores); |
| 91 | +``` |
| 92 | + |
| 93 | +### Example 5: Analyze Fairness by Demographics (Sex and Race) |
| 94 | +Run specific scripts to analyze FDR and FKL for specific demographic groups. |
| 95 | + |
| 96 | +```matlab |
| 97 | +% Example: FKL analysis by sex |
| 98 | +FKL_sex; |
| 99 | +
|
| 100 | +% Example: FKL analysis by sex and race |
| 101 | +FKL_sex_race; |
| 102 | +``` |
| 103 | + |
| 104 | +### Example 6: Use Radial Basis Function (RBF) Kernel |
| 105 | +Use `rbf.m` to compute the RBF kernel for your data. |
| 106 | + |
| 107 | +```matlab |
| 108 | +% RBF Kernel Example |
| 109 | +X1 = rand(10, 5); |
| 110 | +X2 = rand(8, 5); |
| 111 | +sigma = 1.0; |
| 112 | +
|
| 113 | +% Compute RBF kernel |
| 114 | +K = rbf(X1, X2, sigma); |
| 115 | +disp('RBF Kernel Matrix:'); |
| 116 | +disp(K); |
| 117 | +``` |
| 118 | + |
| 119 | +## Dataset |
| 120 | +The dataset used in this project is the a9a dataset from LIBSVM and UCI repositories. |
| 121 | + |
| 122 | +- **Original source:** LIBSVM datasets |
| 123 | +- **Additional info:** UCI Machine Learning Repository |
| 124 | +The dataset was converted to Octave/GNU format using `libsvmread` from LIBSVM. |
| 125 | + |
| 126 | +## Installation |
| 127 | +1. Clone the repository: |
| 128 | + |
| 129 | +```bash |
| 130 | +git clone https://github.com/username/fair-kernel-learning.git |
| 131 | +cd fair-kernel-learning |
| 132 | +``` |
| 133 | + |
| 134 | +2. Add paths to MATLAB: |
| 135 | + |
| 136 | +```matlab |
| 137 | +addpath(pwd); |
| 138 | +``` |
| 139 | + |
| 140 | +3. Verify your MATLAB environment and ensure all functions are accessible. |
| 141 | + |
| 142 | +## Authors |
| 143 | +- **Adrian Perez-Suay** |
| 144 | +- **Valero Laparra** |
| 145 | +- **Gonzalo Mateo-Garcia** |
| 146 | +- **Jordi Muñoz-Marí** |
| 147 | +- **Luis Gomez-Chova** |
| 148 | +- **Gustau Camps-Valls** |
| 149 | + |
| 150 | +**Image Processing Laboratory (IPL)** - [http://isp.uv.es/](http://isp.uv.es/) |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | +## License |
| 155 | +``` |
| 156 | + |
| 157 | +
|
| 158 | +All rights reserved. |
| 159 | +
|
| 160 | +Redistribution and use in source and binary forms, with or without |
| 161 | +modification, are permitted provided that the following conditions are met: |
| 162 | +
|
| 163 | +- Redistributions of source code must retain the above copyright notice, |
| 164 | + this list of conditions and the following disclaimer. |
| 165 | +- Redistributions in binary form must reproduce the above copyright notice, |
| 166 | + this list of conditions and the following disclaimer in the documentation |
| 167 | + and/or other materials provided with the distribution. |
| 168 | +
|
| 169 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 170 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 171 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 172 | +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 173 | +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 174 | +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 175 | +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 176 | +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 177 | +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 178 | +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 179 | +POSSIBILITY OF SUCH DAMAGE. |
| 180 | +``` |
| 181 | + |
0 commit comments