nickgillian / grt

gesture recognition toolkit
859 stars 285 forks source link

Unhandled Exception while trying to train a .csv file for DTW #124

Open SurKM9 opened 7 years ago

SurKM9 commented 7 years ago

I get an unhandled exception error while trying to train .csv file. For instance, my data file looks like this:

3 7.54712 1.5487 8.65 0 0 1.564 412.12 0 0

The white spaces represent values in different cells. The first column is the class label.

While training i get an exception which points to this function in DTW.cpp

Float DTW::d(int m,int n,MatrixFloat &distanceMatrix,const int M,const int N){

Float dist = 0;
//The following is based on Matlab code by Eamonn Keogh and Michael Pazzani

//If this cell is NAN then it has already been flagged as unreachable
if( grt_isnan( distanceMatrix[m][n] ) ){
    return NAN;
}

if( constrainWarpingPath ){
    Float r = ceil( grt_min(M,N)*radius );
    //Test to see if the current cell is outside of the warping window
    if( fabs( n-((N-1)/((M-1)/Float(m))) ) > r ){
        if( n-((N-1)/((M-1)/Float(m))) > 0 ){
            for(int i=0; i<m; i++){
                for(int j=n; j<N; j++){
                    distanceMatrix[i][j] = NAN;
                }
            }
        }else{
            for(int i=m; i<M; i++){
                for(int j=0; j<n; j++){
                    distanceMatrix[i][j] = NAN;
                }
            }
        }
        return NAN;
    }
}

Is there something i am missing ? I have crosschecked my .csv file for rogue values but it seems absolutely fine.

nickgillian commented 7 years ago

Hi SurKM9,

I think the issue here is the CSV loader expects comma seperated values, but you are using whitespace seperated values.

I'll add some additional logic to help catch this loading error and flag a better error message when not using the expected format.

SurKM9 commented 7 years ago

Hi @nickgillian thank you for the response. I should have made it more clearer. My training data looks like this shortfixedcolumns.txt

I had to change it to .txt since GitHub doesn't upload a .csv. I have another 35mb file with thousands of samples but the program crashes when i use it.