I think there's a bug in the code here. You're using data you're already training on as test data.
On line 446, the train data is using all the samples (i.e. X = X[:N]), where N is the number of samples.
On line 447, the test data is using the last 20% of the samples (i.e. X=X[4/5*N:N]).
I think this is a bug.