text_plain_output_1.png image_output_1.png
from sklearn.ensemble import RandomForestClassifier

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

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

train_x = train_df.drop(['Survived'], axis=1)
train_y = train_df['Survived']
test_x = test_df

def predict(train_x, train_y, test_df, algo):
    algo.fit(train_x, train_y)
    pred_y = algo.predict(test_df)
    score = algo.score(train_x, train_y)
    return (pred_y, score)

rfc = RandomForestClassifier(max_depth=10, min_samples_split=2, n_estimators=600, random_state=1)
rt_pred_train, score = predict(train_x, train_y, train_x, rfc)
rt_pred_test, score = predict(train_x, train_y, test_x, rfc)
score