categorical_score Function

public pure function categorical_score(predicted, expected) result(output)

Compute the categorical accuracy of a model

This function is only valid for categorical/classification datasets Arguments

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in), dimension(:,:) :: predicted

Predicted and expected values

real(kind=real32), intent(in), dimension(:,:) :: expected

Predicted and expected values

Return Value real(kind=real32), dimension(size(expected,2))

Categorical accuracy


Source Code

  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