novak-99 / MLPP

A library created to revitalize C++ as a machine learning front end. Per aspera ad astra.
MIT License
1.08k stars 155 forks source link

preformance_function error? #11

Closed algorithmconquer closed 2 years ago

algorithmconquer commented 2 years ago
double Utilities::performance(std::vector<double> y_hat, std::vector<double> outputSet){
    double correct = 0;
    for(int i = 0; i < y_hat.size(); i++){
        if(std::round(y_hat[i]) == outputSet[i]){
            correct++;
        }
    }
    return correct/y_hat.size();
}

problem:std::round(y_hat[i]) == outputSet[i]???

novak-99 commented 2 years ago

Hello,

The reason I employed rounding is for the fact that it is unlikely that a model outputing discrete values would be able to exactly output, say [1, 0, 1]. Typically, these values are approached if an iterative algorithm is used, and a typical output would be something like [0.99, 0.001, 0.999], etc.. For this reason, rounding them to the nearest integer and then comparing them with the true outputs is more convienent for calcualting accuracy.