import numpy as np
import pandas as pd
import csv
from sklearn.ensemble import RandomForestClassifier

# The competition datafiles are in the directory ../input
# Read competition data files:
train = pd.read_csv("../input/train.csv")
test  = pd.read_csv("../input/test.csv")

print(train.shape)
print(test.shape)

train_data = train.values
test_data = test.values

model = RandomForestClassifier(n_estimators=200)
model = model.fit(train_data[0::,1::], train_data[0::,0])
result = model.predict(test_data)

ids = range(1,28001)

# Write to the log:
prediction_file = open("mnist.csv","w", newline='')
open_file_object = csv.writer(prediction_file)
open_file_object.writerow(["ImageId", "Label"])
open_file_object.writerows(zip(ids,result))
prediction_file.close()
# Any files you write to the current directory get shown as outputs