Kaggle competition: Data Series Summarization Project (v3)
<SOS> metric: rmse Kaggle data source: data-series-summarization-project-(v3)<load_from_csv>
inputFolderPath = '/kaggle/input/data-series-summarization-project-v3/'
outputFolderPath = '/kaggle/working/'
filename = 'synthetic_size50k_len256_znorm.bin'
inputFilePath = inputFolderPath + filename
df=pd.read_csv("/kaggle/input/covid19-global-forecasting-week-2/train.csv",
usecols=['Province_State','Country_Region','Date','ConfirmedCases','Fatalities'])
<drop_column>
def sum32(inputFilePath):

 summary_filepath = outputFolderPath + filename + '_sum32'
time_series50k = np.fromfile(inputFilePath, dtype=np.float32 ).reshape(-1, 256)
 summary50k = []
for time_series in time_series50k:
summary50k.append(time_series[0])
 summary50knp = np.array(summary50k,dtype=np.float32)
 summary50knp.tofile(summary_filepath)
 return summary_filepath
def rec32(summary_filepath):

 reconstructed_filepath = summary_filepath + '_rec32'
summary50k = np.fromfile(summary_filepath, dtype=np.float32)
 reconstructed50k = []
for summary in summary50k:
reconstructed50k.append([summary]*256)
 reconstructed50knp = np.array(reconstructed50k,dtype=np.float32)
 reconstructed50knp.tofile(reconstructed_filepath)
 return reconstructed_filepath
def sum64(inputFilePath):

 summary_filepath = outputFolderPath + filename + '_sum64'
time_series50k = np.fromfile(inputFilePath, dtype=np.float32 ).reshape(-1, 256)
 summary50k = []
for time_series in time_series50k:
summary50k.append(time_series[0])
 summary50k.append(time_series[0])
 summary50knp = np.array(summary50k,dtype=np.float32)
 summary50knp.tofile(summary_filepath)
 return summary_filepath
def rec64(summary_filepath):

 reconstructed_filepath = summary_filepath + '_rec64'
summary50k = np.fromfile(summary_filepath, dtype=np.float32 ).reshape(-1, 2)
 reconstructed50k = []
for summary in summary50k:
reconstructed50k.append([summary[0]]*256)
 reconstructed50knp = np.array(reconstructed50k,dtype=np.float32)
 reconstructed50knp.tofile(reconstructed_filepath)
 return reconstructed_filepath
def sum128(inputFilePath):

 summary_filepath = outputFolderPath + filename + '_sum128'
time_series50k = np.fromfile(inputFilePath, dtype=np.float32 ).reshape(-1, 256)
 summary50k = []
for time_series in time_series50k:
summary50k.append(time_series[0])
 summary50k.append(time_series[0])
 summary50k.append(time_series[0])
 summary50k.append(time_series[0])
 summary50knp = np.array(summary50k,dtype=np.float32)
 summary50knp.tofile(summary_filepath)
 return summary_filepath
def rec128(summary_filepath):

 reconstructed_filepath = summary_filepath + '_rec128'
summary50k = np.fromfile(summary_filepath, dtype=np.float32 ).reshape(-1, 4)
 reconstructed50k = []
for summary in summary50k:
reconstructed50k.append([summary[0]]*256)
 reconstructed50knp = np.array(reconstructed50k,dtype=np.float32)
 reconstructed50knp.tofile(reconstructed_filepath)
 return reconstructed_filepath
<load_from_csv><EOS> 
s32= sum32(inputFilePath)
 r32 = rec32(s32)
 pred32=np.fromfile(r32, dtype=np.float32)
 s64= sum64(inputFilePath)
 r64 = rec64(s64)
 pred64=np.fromfile(r64, dtype=np.float32)
 s128= sum128(inputFilePath)
 r128 = rec128(s128)
 pred128=np.fromfile(r128, dtype=np.float32)
 output = []
globalCsvIndex = 0
for i in range(len(pred32)) :
output.append([globalCsvIndex,pred32[i]])
 globalCsvIndex = globalCsvIndex+1
for i in range(len(pred64)) :
output.append([globalCsvIndex,pred64[i]])
 globalCsvIndex = globalCsvIndex+1
for i in range(len(pred128)) :
output.append([globalCsvIndex,pred128[i]])
 globalCsvIndex = globalCsvIndex+1
with open('submission.csv', 'w', newline='')as file:
writer = csv.writer(file)
 writer.writerow(['id','expected'])
 writer.writerows(output )