working poly fitting train and test scripts