Skip to content

Commit 0a9049c

Browse files
authored
Update README.md
1 parent 3e12b8b commit 0a9049c

File tree

1 file changed

+126
-20
lines changed

1 file changed

+126
-20
lines changed

Diff for: README.md

+126-20
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,162 @@
44
> --- [Jingwei Too](https://jingweitoo.wordpress.com/)
55
---
66

7-
## Description
7+
## Introduction
88

99
* This toolbox offers more than 40 wrapper feature selection methods
10-
+ The < A_Main.m file > provides the demostrations on benchmark dataset.
10+
* The < A_Main.m file > provides the examples of how to apply these methods on benchmark dataset
11+
* Source code of these methods are written based on pseudocode & paper
1112

1213

1314
* Main goals of this toolbox are:
1415
+ Knowledge sharing on wrapper feature selection
1516
+ Assists others in data mining projects
1617

17-
### Example 1
18+
## Usage
19+
The main function *jfs* is adopted to perform feature selection. You may switch the algorithm by changing the 'pso' to other [other abbreviations](/README.md#list-of-available-wrapper-feature-selection-methods)
20+
* If you wish to use particle swarm optimization ( see example 1 ) then you may write
21+
```code
22+
FS = jfs('pso',feat,label,opts);
23+
```
24+
* If you want to use slime mould algorithm ( see example 2 ) then you may write
25+
```code
26+
FS = jfs('sma',feat,label,opts);
27+
```
28+
29+
## Input
30+
* feat : feature vector matrix ( Instance x Features )
31+
* label : label matrix ( Instance x 1 )
32+
* opts : parameter settings
33+
+ N : number of solutions / population size ( *for all methods* )
34+
+ T : maximum number of iterations ( *for all methods* )
35+
+ k : *k*-value in *k*-nearest neighbor
36+
37+
38+
## Output
39+
* Acc : accuracy of feature selection
40+
* FS : feature selection model ( It contains several results )
41+
+ sf : index of selected features
42+
+ ff : selected features
43+
+ nf : number of selected features
44+
+ c : convergence curve
45+
46+
47+
## Notation
48+
Some methods have their specific parameters ( example: PSO, GA, DE ), and if you do not set them then they will be defined as default settings
49+
* you may open the < m.file > to view or change the parameters
50+
* you may use *opts* to set the parameters of method ( see example 1 or refer [here](/Description.md) )
51+
* you may also change the < jFitnessFunction.m file >
52+
53+
54+
### Example 1 : Particle Swarm Optimization ( PSO )
1855
```code
19-
%% Particle Swarm Optimization (PSO)
20-
clear, clc, close;
21-
22-
% Parameters settings
23-
opts.k = 5;
24-
ho = 0.2;
25-
opts.N = 10;
26-
opts.T = 100;
56+
% Common parameter settings
57+
opts.k = 5; % Number of k in K-nearest neighbor
58+
opts.N = 10; % number of solutions
59+
opts.T = 100; % maximum number of iterations
60+
% Parameters of PSO
2761
opts.c1 = 2;
2862
opts.c2 = 2;
2963
opts.w = 0.9;
3064
31-
% Prepare data
32-
load ionosphere.mat;
65+
% Load dataset
66+
load ionosphere.mat;
67+
68+
% Ratio of validation data
69+
ho = 0.2;
70+
% Divide data into training and validation sets
3371
HO = cvpartition(label,'HoldOut',ho);
3472
opts.Model = HO;
3573
36-
% Feature selection
74+
% Perform feature selection
3775
FS = jfs('pso',feat,label,opts);
3876
3977
% Define index of selected features
4078
sf_idx = FS.sf;
4179
4280
% Accuracy
43-
Acc = jknn(feat(:,sf_idx),label,opts);
81+
Acc = jknn(feat(:,sf_idx),label,opts);
82+
83+
% Plot convergence
84+
plot(FS.c); grid on; xlabel('Number of Iterations'); ylabel('Fitness Value'); title('PSO');
85+
86+
```
87+
88+
### Example 2 : Slime Mould Algorithm ( SMA )
89+
```code
90+
% Common parameter settings
91+
opts.k = 5; % Number of k in K-nearest neighbor
92+
opts.N = 10; % number of solutions
93+
opts.T = 100; % maximum number of iterations
94+
95+
% Load dataset
96+
load ionosphere.mat;
97+
98+
% Ratio of validation data
99+
ho = 0.2;
100+
% Divide data into training and validation sets
101+
HO = cvpartition(label,'HoldOut',ho);
102+
opts.Model = HO;
103+
104+
% Perform feature selection
105+
FS = jfs('sma',feat,label,opts);
106+
107+
% Define index of selected features
108+
sf_idx = FS.sf;
109+
110+
% Accuracy
111+
Acc = jknn(feat(:,sf_idx),label,opts);
112+
113+
% Plot convergence
114+
plot(FS.c); grid on; xlabel('Number of Iterations'); ylabel('Fitness Value'); title('SMA');
115+
116+
```
117+
118+
### Example 3 : Whale Optimization Algorithm ( WOA )
119+
```code
120+
% Common parameter settings
121+
opts.k = 5; % Number of k in K-nearest neighbor
122+
opts.N = 10; % number of solutions
123+
opts.T = 100; % maximum number of iterations
124+
% Parameter of WOA
125+
opts.b = 1;
126+
127+
% Load dataset
128+
load ionosphere.mat;
129+
130+
% Ratio of validation data
131+
ho = 0.2;
132+
% Divide data into training and validation sets
133+
HO = cvpartition(label,'HoldOut',ho);
134+
opts.Model = HO;
135+
136+
% Perform feature selection
137+
FS = jfs('woa',feat,label,opts);
138+
139+
% Define index of selected features
140+
sf_idx = FS.sf;
141+
142+
% Accuracy
143+
Acc = jknn(feat(:,sf_idx),label,opts);
144+
145+
% Plot convergence
146+
plot(FS.c); grid on; xlabel('Number of Iterations'); ylabel('Fitness Value'); title('WOA');
44147
45148
```
46149

150+
47151
## Requirement
48152

49153
* MATLAB 2014 or above
50154
* Statistics and Machine Learning Toolbox
51155

52-
## List of available methods
53-
* Note that the methods are altered so that they can be used in feature selection tasks.
54-
* The extra parameters represent the parameter(s) other than population size and maximum number of iteration
55-
* Click on the name of method to view the detailed parameters
56-
* Use the *opts* to set the specific parameters
156+
157+
## List of available wrapper feature selection methods
158+
* Note that the methods are altered so that they can be used in feature selection tasks
159+
* The extra parameters represent the parameter(s) other than population size and maximum number of iterations
160+
* Click on the name of method to view the extra parameter(s)
161+
* Use the *opts* to set the specific parameter(s)
162+
57163

58164
| No. | Abbreviation | Name | Year | Extra Parameters |
59165
|-----|--------------|---------------------------------------------------------------------------------------------|------|------------------|

0 commit comments

Comments
 (0)