r - How to calculate accuracy from table matrix -


i'm using table show results kmeans cluster vs. actual class values.

enter image description here

how can calculate % accuracy based on table. know how manually.

iris-setosa had 50 in cluster 2 while iris-versicolor had 2 in other cluster.

is there way calculate % incorrectly classified instances: 52%

i print confusion matrix classes , clusters. lke this:

   0   1  <-- assigned cluster  380 120 | 1  135 133 | 0  cluster 0 <-- 1 cluster 1 <-- 0  incorrectly clustered instances :   255.0    33.2031 % 

you can use diag() select cases on diagonal , use calculate (in)accuracy shown below:

sum(diag(d))/sum(d) #overall accuracy 1-sum(diag(d))/sum(d) #incorrect classification  

you can use calculate number of cases (in)correctly classified:

sum(diag(d)) #n cases correctly classified sum(d)-sum(diag(d)) #n cases incorrectly classified 

where d confusion matrix


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -