Skip to main content
. 2019 May 9;9(2):52. doi: 10.3390/diagnostics9020052
function [knowledgeRuleBase] = knowledgeRB(round,training, validation,testing,numvarinputs)
for a = 2:numvarinputs percent, it could be the same numvarinputs if you work with the same number of input variables.
numvars = a;
n = 1:1:numvarinputs;
combinations = nchoosek(n,numvars);
for i = 1:size(combinations,1)
for j = 1:size(combinations,2)
clustersinputsindices(i,j) = combinations(i,j) *2;
end
end
calculate the clustersoutputsindices;
for i = 1:size(combinations,1)
[RuleBaseInputs,ia,ic] = unique(training(:,clustersinputsindices(i,:)),’rows’,’sorted’); %pivot tables
RuleBaseOutputs = training(ia,clustersoutputsindices(i,:));
RuleBase = [RuleBaseInputs RuleBaseOutputs];
weightsandconnections = ones(size(RuleBase,1),2);
[knowledgeRuleBase] = [RuleBase weightsandconnections];
InferenceEngineandDefuzzification(combination,trainingdata,validationdata,testdata,knowledgeRuleBase,indicesinputs,indicesoutputs);
end
end
end