Kaggle competition: Titanic - Machine Learning from Disaster
ans["price"] = preds
ans.to_csv("heroz_nakai.csv", index=False )<load_from_csv>
train_data = pd.read_csv('/kaggle/input/titanic/train.csv')
 test_data = pd.read_csv('/kaggle/input/titanic/test.csv')
 train_data['Age'].fillna(train_data['Age'].mean() , inplace=True)
 test_data['Age'].fillna(test_data['Age'].mean() , inplace=True)
 train_data['Fare'].fillna(train_data['Fare'].mean() , inplace=True)
 test_data['Fare'].fillna(test_data['Fare'].mean() , inplace=True )
df_train = pd.read_csv('/kaggle/input/homework-for-students3/train.csv', index_col=0, parse_dates=['issue_d'])
 df_test =pd.read_csv('/kaggle/input/homework-for-students3/test.csv', index_col=0, parse_dates=['issue_d'])
 year = df_train.issue_d.dt.year
df_train = df_train[year >= 2014]
columns = df_train.columns
y_train = df_train.loan_condition
X_train = df_train.drop(['loan_condition'], axis = 1)
 X_test = df_test
del df_train
del df_test<drop_column>
features = ["Pclass", "Sex", "SibSp", "Parch", "Age", "Fare"]
train_y = train_data["Survived"]
train_x = pd.get_dummies(train_data[features])
 test_x = pd.get_dummies(test_data[features] )
drop_col = ['issue_d','earliest_cr_line']
X_train = X_train.drop(columns=drop_col)
 X_test = X_test.drop(columns=drop_col )<categorify>
model = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=1)
 model.fit(train_x, train_y)
 test_y = model.predict(test_x )
<concatenate><EOS> 
output = pd.DataFrame({'PassengerId': test_data.PassengerId, 'Survived': test_y})
 output.to_csv('submission.csv', index=False )