Compute the categorical accuracy of a model
This function is only valid for categorical/classification datasets Arguments
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(in), | dimension(:,:) | :: | predicted |
Predicted and expected values |
|
| real(kind=real32), | intent(in), | dimension(:,:) | :: | expected |
Predicted and expected values |
Categorical accuracy
pure function categorical_score(predicted, expected) result(output) !! Compute the categorical accuracy of a model !! !! This function is only valid for categorical/classification datasets implicit none !! Arguments real(real32), dimension(:,:), intent(in) :: predicted, expected !! Predicted and expected values real(real32), dimension(size(expected,2)) :: output !! Categorical accuracy ! Local variables integer :: s !! Loop index !! Compute the accuracy do concurrent(s=1:size(expected,2)) if(maxloc(expected(:,s),dim=1).eq.maxloc(predicted(:,s),dim=1))then output(s) = 1._real32 else output(s) = 0._real32 end if end do end function categorical_score