>>297
print(result, predict, data_test)  # 標準出力に出力
print(result, predict, data_test, file=f) # ファイルハンドル f のファイルに出力

これが理解できないならもうワシは知らん