Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Adjust classifier performance (sensitivity & specificity)

Adjust classifier performance (sensitivity & specificity)

PuTI / 2025-01-22
Adjust classifier performance (sensitivity & specificity)
Matlab News

Hi all,
I’m trying to build a classifier for my highly imbalanced binaty data, where I have the following stats:
tabulate(classes)
Value Count Percent
0 133412 97.62%
1 3247 2.38%
My dataset has 119 features. My question is: how can I balance my classifier sensitivity and specificity results (see more details below)?
In order to deal with my imbalanced data, I’m using the ensemble classifier with the RUSBoost Method, and acessing its performance, like shown in the code below:
%% Set cross validation – holdout
part = cvpartition(classes, ‘Holdout’, 0.5);
istrain = training(part); % Data for fitting
istest = test(part); % Data for quality assessment
holdout_train_features = features(istrain,:);
holdout_train_classes = classes(istrain);
holdout_test_features = features(istest,:);
holdout_test_classes = classes(istest);

%% Set classifier
% Set template tree
max_mum_splits = round(sum(istrain)/2);
t = templateTree(‘MaxNumSplits’, max_num_splits);
classifier = fitcensemble(holdout_train_features, holdout_train_classes, ‘Method’,’RUSBoost’, …
‘NumLearningCycles’, 1000, ‘Learners’, t,’LearnRate’, 0.1);

%% Test performance
% Get common classification indicators
[obtained_classes, scores] = predict(classifier, holdout_test_features);
holdout_validation_results = confusionchart(holdout_test_classes, obtained_classes);
TN = holdout_validation_results.NormalizedValues(1,1);
TP = holdout_validation_results.NormalizedValues(2,2);
FP = holdout_validation_results.NormalizedValues(1,2);
FN = holdout_validation_results.NormalizedValues(2,1);
accuracy = (TP + TN)/(TP + TN + FP + FN); % 0.99406
sensitivity = TP/(TP + FN); % 0.86445
specificity = TN/(TN + FP); % 0.99721
PPV = TP/(TP + FP); % 0.88295
NPV = TN/(TN + FN); % 0.9967

% Compute ROC curve
positiveClassIdx = find(classifier.ClassNames == 1);
[X,Y,T,AUC, OPTROCPT] = perfcurve(holdout_test_classes, scores(:,positiveClassIdx), 1);
plot(1-X,Y)
hold on
scatter(1-OPTROCPT(1),OPTROCPT(2), ‘filled’)
xlabel(‘Specificity’)
ylabel(‘Sensitivity’)
Which gets me the following:

As can be appreciated, I get an imbalanced value of specificity (very high) and sensitivity (low). My question is: how can I adjust my classifier in order to balance the sensitivity and specificity (and PPV and NPV, of course), so that it matched my desired balance (e.g., what I show in the ROC curve: 0.97 specificity and 0.961 sensitivity)?
Many thanks for your attention,
DiogoHi all,
I’m trying to build a classifier for my highly imbalanced binaty data, where I have the following stats:
tabulate(classes)
Value Count Percent
0 133412 97.62%
1 3247 2.38%
My dataset has 119 features. My question is: how can I balance my classifier sensitivity and specificity results (see more details below)?
In order to deal with my imbalanced data, I’m using the ensemble classifier with the RUSBoost Method, and acessing its performance, like shown in the code below:
%% Set cross validation – holdout
part = cvpartition(classes, ‘Holdout’, 0.5);
istrain = training(part); % Data for fitting
istest = test(part); % Data for quality assessment
holdout_train_features = features(istrain,:);
holdout_train_classes = classes(istrain);
holdout_test_features = features(istest,:);
holdout_test_classes = classes(istest);

%% Set classifier
% Set template tree
max_mum_splits = round(sum(istrain)/2);
t = templateTree(‘MaxNumSplits’, max_num_splits);
classifier = fitcensemble(holdout_train_features, holdout_train_classes, ‘Method’,’RUSBoost’, …
‘NumLearningCycles’, 1000, ‘Learners’, t,’LearnRate’, 0.1);

%% Test performance
% Get common classification indicators
[obtained_classes, scores] = predict(classifier, holdout_test_features);
holdout_validation_results = confusionchart(holdout_test_classes, obtained_classes);
TN = holdout_validation_results.NormalizedValues(1,1);
TP = holdout_validation_results.NormalizedValues(2,2);
FP = holdout_validation_results.NormalizedValues(1,2);
FN = holdout_validation_results.NormalizedValues(2,1);
accuracy = (TP + TN)/(TP + TN + FP + FN); % 0.99406
sensitivity = TP/(TP + FN); % 0.86445
specificity = TN/(TN + FP); % 0.99721
PPV = TP/(TP + FP); % 0.88295
NPV = TN/(TN + FN); % 0.9967

% Compute ROC curve
positiveClassIdx = find(classifier.ClassNames == 1);
[X,Y,T,AUC, OPTROCPT] = perfcurve(holdout_test_classes, scores(:,positiveClassIdx), 1);
plot(1-X,Y)
hold on
scatter(1-OPTROCPT(1),OPTROCPT(2), ‘filled’)
xlabel(‘Specificity’)
ylabel(‘Sensitivity’)
Which gets me the following:

As can be appreciated, I get an imbalanced value of specificity (very high) and sensitivity (low). My question is: how can I adjust my classifier in order to balance the sensitivity and specificity (and PPV and NPV, of course), so that it matched my desired balance (e.g., what I show in the ROC curve: 0.97 specificity and 0.961 sensitivity)?
Many thanks for your attention,
Diogo Hi all,
I’m trying to build a classifier for my highly imbalanced binaty data, where I have the following stats:
tabulate(classes)
Value Count Percent
0 133412 97.62%
1 3247 2.38%
My dataset has 119 features. My question is: how can I balance my classifier sensitivity and specificity results (see more details below)?
In order to deal with my imbalanced data, I’m using the ensemble classifier with the RUSBoost Method, and acessing its performance, like shown in the code below:
%% Set cross validation – holdout
part = cvpartition(classes, ‘Holdout’, 0.5);
istrain = training(part); % Data for fitting
istest = test(part); % Data for quality assessment
holdout_train_features = features(istrain,:);
holdout_train_classes = classes(istrain);
holdout_test_features = features(istest,:);
holdout_test_classes = classes(istest);

%% Set classifier
% Set template tree
max_mum_splits = round(sum(istrain)/2);
t = templateTree(‘MaxNumSplits’, max_num_splits);
classifier = fitcensemble(holdout_train_features, holdout_train_classes, ‘Method’,’RUSBoost’, …
‘NumLearningCycles’, 1000, ‘Learners’, t,’LearnRate’, 0.1);

%% Test performance
% Get common classification indicators
[obtained_classes, scores] = predict(classifier, holdout_test_features);
holdout_validation_results = confusionchart(holdout_test_classes, obtained_classes);
TN = holdout_validation_results.NormalizedValues(1,1);
TP = holdout_validation_results.NormalizedValues(2,2);
FP = holdout_validation_results.NormalizedValues(1,2);
FN = holdout_validation_results.NormalizedValues(2,1);
accuracy = (TP + TN)/(TP + TN + FP + FN); % 0.99406
sensitivity = TP/(TP + FN); % 0.86445
specificity = TN/(TN + FP); % 0.99721
PPV = TP/(TP + FP); % 0.88295
NPV = TN/(TN + FN); % 0.9967

% Compute ROC curve
positiveClassIdx = find(classifier.ClassNames == 1);
[X,Y,T,AUC, OPTROCPT] = perfcurve(holdout_test_classes, scores(:,positiveClassIdx), 1);
plot(1-X,Y)
hold on
scatter(1-OPTROCPT(1),OPTROCPT(2), ‘filled’)
xlabel(‘Specificity’)
ylabel(‘Sensitivity’)
Which gets me the following:

As can be appreciated, I get an imbalanced value of specificity (very high) and sensitivity (low). My question is: how can I adjust my classifier in order to balance the sensitivity and specificity (and PPV and NPV, of course), so that it matched my desired balance (e.g., what I show in the ROC curve: 0.97 specificity and 0.961 sensitivity)?
Many thanks for your attention,
Diogo machine learning, performance, matlab, classification, ensemble learning MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

How to debug C# .NET assembly called from MATLAB?
2025-05-15

How to debug C# .NET assembly called from MATLAB?

How do I set the size of a tile from tiledlayout?
2025-05-15

How do I set the size of a tile from tiledlayout?

Communicate with worker through client
2025-05-15

Communicate with worker through client

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss