text_html_output_1.png
from sklearn.ensemble import RandomForestClassifier

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

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

simple_feature_cutting_df = df.drop(['PassengerId', 'Name', 'Ticket', 'Cabin', 'Embarked'], axis=1)
simple_feature_cutting_df = simple_feature_cutting_df.dropna()
simple_feature_cutting_df = pd.get_dummies(simple_feature_cutting_df, columns=['Sex'])
simple_feature_cutting_df.index = range(0, len(simple_feature_cutting_df))
simple_feature_cutting_df

test_data_set = simple_feature_cutting_df[:100]
train_data_set = simple_feature_cutting_df[100:]

from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
label_data = train_data_set['Survived']
train_data = train_data_set.drop('Survived', axis=1)
model.fit(train_data, label_data)

result_test_predict = model.predict(test_data_set.drop('Survived', axis=1))
real_test_observations = np.array(test_data_set['Survived'])
result = pd.DataFrame({'predict': result_test_predict, 'real': real_test_observations})
result['Correct'] = result.apply(lambda row: row['predict'] == row['real'], axis=1)
result