How to classifiy data using Fuzzy subtractive clustering?

조회 수: 1 (최근 30일)
Yuvaraj
Yuvaraj 2014년 1월 20일
편집: Prateekshya 2024년 10월 10일
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));

답변 (1개)

Prateekshya
Prateekshya 2024년 10월 10일
편집: Prateekshya 2024년 10월 10일
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!

카테고리

Help CenterFile Exchange에서 Fuzzy Logic Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by