Problem with GA function

2 views (last 30 days)
Lalit Mohan Kandpal
Lalit Mohan Kandpal on 3 Nov 2022
Answered: Khalid on 15 Nov 2022
Hello,
I am trying to apply genetric algorithm to select the features. I follow the code as suggested in this link: https://ch.mathworks.com/help/bioinfo/ug/genetic-algorithm-search-for-features-in-mass-spectrometry-data.html. However when I used my data the feat = ga(FitnessFcn,nVars,options) showng below error:
Error using rankfeatures (line 206)
Number of output
indices must be a
scalar between 1 and
number of features.
Error in biogacreate (line 17)
ranked_features = rankfeatures(Y,id,'NumberOfIndices',npop,'NWeighting',.5);
Error in makeState (line 34)
state.Population = feval(options.CreationFcn,GenomeLength,FitnessFcn,options,options.CreationFcnArgs{:});
Error in gaunc (line 47)
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 411)
[x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Please help regarding this error. thanks !

Answers (1)

Khalid
Khalid on 15 Nov 2022
Hi,
I understand that you are facing the error in ga function when you are trying to run code from https://ch.mathworks.com/help/bioinfo/ug/genetic-algorithm-search-for-features-in-mass-spectrometry-data.html.
When I tried to reproduce the error on my end, I didn't face any errors.
One possible reason for the error could be because of some issue in preprocessing step. Make sure that the data is preprocessed as mentioned and that the variables MZ, Y and grp are of same dimensions as shown in the article.
Hope it helps.
Regards,
Khalid

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!