Kaggle competition: Forest Cover Type Prediction
<train_model><EOS> 


train = pd.read_csv('.. /input/train.csv')
 test = pd.read_csv('.. /input/test.csv')

train = train.fillna(0)
 test = test.fillna(0)
 column_target = 'Cover_Type'
column_id = 'Id'
data = train.dropna(axis='columns')
 print("Total data: ",len(data))
X = data
y = data[column_target]
c_sample = 0.99
if c_sample < 1.0:
X_null, X, y_null, y = train_test_split(X, y, test_size=c_sample, random_state=0)
 ID = X[column_id]
y = X[column_target]
X = X.drop([column_id, column_target], axis=1 ).select_dtypes(include=[np.number])
 train_select_atributes = X.columns
print("Amostragem: ",len(X))


X = X.values
y = y.values

 model = RandomForestClassifier(random_state=0, n_estimators=500)
 kf = StratifiedKFold(n_splits=10)
 outcomes = []
for train_index, test_index in kf.split(X, y):
Xtrain, Xtest = X[train_index], X[test_index]
ytrain, ytest = y[train_index], y[test_index]
model.fit(Xtrain, ytrain)
 expected = ytest
predictions = model.predict(Xtest)
 accuracy = accuracy_score(ytest, predictions)
 outcomes.append(accuracy)
 mean_outcome = np.array(outcomes ).mean()
print("Mean Accuracy:", mean_outcome)

X_test = test[train_select_atributes]
x_test_id = test[column_id]
predictions = model.predict(X_test)
 predictions = pd.DataFrame(predictions, columns = ["Cover_Type"])
 result = pd.concat([x_test_id, predictions], axis=1, sort=False)
 result.to_csv("result.csv", mode = 'w', index=False)

isfineClass = False
for i in range(len(y)) :
if y[i]==0:
isfineClass=True
break;
if isfineClass==False:
for i in range(len(y)) :
v = y[i]
y[i] = v-1
c_sample = 0.1
if c_sample < 1.0:
X_null, X, y_null, y = train_test_split(X, y, test_size=c_sample, random_state=0)
 print("Amostragem para a visualização: ", len(X))
tsne = TSNE(n_components=2, random_state=0)
 X_2d = tsne.fit_transform(X)
 plt.figure(figsize=(6, 5))
colors = ["
for i in range(len(y)) :
v = y[i]
plt.plot(X_2d[i, 0], X_2d[i, 1], 'o', color=colors[v], alpha=0.3)
 plt.show()