def writeSubmissionFile(Y): submission = pp.loadCSV("submission.txt", sep ="\t") submission["prediction"] = Y submission = submission.as_matrix() np.savetxt('submission-test.txt', submission,delimiter='\t',fmt = ('%s','%s','%s'),header = "DATE"+"\t"+"ASS_ASSIGNMENT"+"\t"+"prediction",comments='')
def buildInput(): #Only DATE and ASSIGNEMENT submission = pp.loadCSV("submission.txt", sep ="\t") submission.drop('prediction', axis=1, inplace=True) X = submission X['DAY_OFF']= 0 X['DATE'] = pd.to_datetime(X['DATE']) # Setting the dates 3 days earlier. X["DATE"] = X["DATE"].apply(lambda x: x+pd.DateOffset(days=-3)) X['WEEK_END'] = X['DATE'].apply(lambda x: x.dayofweek>=5) X = pp.parseDate(submission,drop = False) X = pp.oneHot(X, "ASS_ASSIGNMENT", delCol = True) #X = pp.oneHot(X, "YEAR", delCol = True, prefix="YEAR") X.drop('YEAR', axis=1, inplace=True) X['MONTH_1']= 0 X = pp.oneHot(X, "MONTH", delCol = True, prefix="MONTH") X.drop('DAY', axis=1, inplace=True) #X = pp.oneHot(X, "DAY", delCol = True, prefix="DAY") X = pp.oneHot(X, "CRENEAU", delCol = True, prefix="CRENEAU") X.drop('DATE', axis=1, inplace=True) return X