How to classifiy data using Fuzzy subtractive clustering?

2 views (last 30 days)
Dear friends, Currently i am working in Fuzzy subtractive clustering. Belo i have mentioned the code. The problem i dont know how to get classification accuracy? I have created 5 rules using Fuzzy inference system.Can any one help how to implement Fuzzy rules using matlab code?? How to proceed after this?? Thanks in advance.
finputtrain = data(train,:); % train_data
foutputtrain = labels(train,:); % train_labels
finputtest= data(test,:); % test_data
foutputtest= labels(test,:); % Target
%clustering the data
[C,S] = subclust([finputtrain,foutputtrain],0.5);
% Generating FISuisng subtractive clustering
myfis = genfis2(finputtrain,foutputtrain,0.2,[],[1.25 0.5 0.15 0]);
fuzout = evalfis (finputtrain,myfis);
trnrmse = norm(fuzout-foutputtrain)/sqrt(length(fuzout));
testfuzout = evalfis (finputtest,myfis);
testrmse = norm(testfuzout-foutputtest)/sqrt(length(testfuzout));

Answers (1)

Prateekshya
Prateekshya on 10 Oct 2024
Edited: Prateekshya on 10 Oct 2024
Hello Yuvaraj,
To calculate classification accuracy using a Fuzzy Inference System (FIS) generated from subtractive clustering, you should follow these steps:
  • Evaluate the FIS on Test Data: You've already done this with evalfis, which generates fuzzy output predictions for your test data.
  • Defuzzify the Output: If your FIS output is continuous, you might need to map it to discrete class labels. This often involves setting thresholds or using a method to determine which class a continuous output belongs to.
  • Calculate Classification Accuracy: Compare the predicted class labels against the true labels to compute the accuracy.
Here is how you can implement these steps in MATLAB:
% Assuming 'testfuzout' is the fuzzy output for the test data
% and 'foutputtest' contains the true labels
% Step 2: Defuzzify the output
% For simplicity, let's assume you have two classes [0, 1]
% You might need to adjust this logic based on your specific classes
threshold = 0.5; % Example threshold for binary classification
predictedLabels = testfuzout >= threshold;
% Step 3: Calculate classification accuracy
correctPredictions = (predictedLabels == foutputtest);
accuracy = sum(correctPredictions) / length(foutputtest) * 100;
fprintf('Classification Accuracy: %.2f%%\n', accuracy);
I hope this helps!

Categories

Find more on Fuzzy Logic Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!