MATLAB Answers


How to validate value of K with PSO.

Asked by karthik on 13 Aug 2018 at 7:29
Latest activity Edited by karthik on 17 Aug 2018 at 6:00

I am creating bag of visual words using bagOfFeatures() function for my dataset. Here I wanted to know for how many number of clusters do I get a good accuracy value., so I kept changing the values of k from 50 to 400 in steps of 50. like {50,100,150,200,250 ..... 400}. and i get a good accuracy at k=250. This k value I want to validate it with other methods like:

1. automatic identification method of k value for the dataset used. Which is the best method for this.? and also

2. by Using Particle Swarm optimization (PSO).

How i can proceed further. Your inputs are more important to me.


Sign in to comment.

1 Answer

Answer by Yuvaraj V
on 13 Aug 2018 at 13:45


Yes Sir, Yesterday I gone through this video tutorial course. But my problem here is how i can write these parts to my problem..

%% Problem Definition
CostFunction=@(x) Sphere(x);        % Cost Function
nVar=10;            % Number of Decision Variables
VarSize=[1 nVar];   % Size of Decision Variables Matrix
VarMin=-10;         % Lower Bound of Variables
VarMax= 10;         % Upper Bound of Variables
%% PSO Parameters
MaxIt=1000;      % Maximum Number of Iterations
nPop=100;        % Population Size (Swarm Size)
% PSO Parameters
w=1;            % Inertia Weight
wdamp=0.99;     % Inertia Weight Damping Ratio
c1=1.5;         % Personal Learning Coefficient
c2=2.0;         % Global Learning Coefficient

@Karthik, In reference code, they are using sphere equation as cost function or objective function. In your work, You have take your equation which you want to optimize. PSO parameters are variables which you can adjust, no issues. Initially, the best value is varied by increasing the iteration. After some iteration, the value is attained consistent if you increase large number of iteration.

Yes Sir, these things i got to know and the above tutorials demonstrates this. But how to write for k means is my question. Searched a lot not able to find it sir.

Sign in to comment.