Kaggle competition: Titanic - Machine Learning from Disaster
train_df=train_df.drop(rush_hour.index,axis=0 )<filter>
train_X = pd.read_csv(".. /input/titanic/train.csv")
 test_y = pd.read_csv(".. /input/titanic/test.csv")
 print("Test and Train FILES are loaded")
 train_X.columns
non_rush_hour = train_df.loc[(((train_df['hour']<6)|(train_df['hour']>20)) &(( train_df['day_of_week']>=1)&(train_df['day_of_week']<=5)) &(train_df['S_Distance']==0)&(train_df['fare_amount'] < 3.0)) ]<filter>
features = ["Pclass", "Sex", "SibSp", "Parch"]
train_y = train_X['Survived']
train_f= train_X[features]
le = LabelEncoder()
train_f['Sex']=le.fit_transform(train_f['Sex'])
 test_y['Sex'] = le.fit_transform(test_y['Sex'])
non_rush_hour = train_df.loc[(((train_df['hour']<6)|(train_df['hour']>20)) &(( train_df['day_of_week']>=1)&(train_df['day_of_week']<=5)) &(train_df['S_Distance']==0)&(train_df['fare_amount'] < 3.0)) ]
non_rush_hour<feature_engineering>
model = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=1)
 model.fit(train_f,train_y)
 predictions = model.predict(test_y[features])
 predictions
train_df.loc[(train_df['S_Distance']!=0)&(train_df['fare_amount']==0)]<filter>
output = pd.DataFrame({"PassengerId" :test_y['PassengerId'] , 'Survived':predictions})
 output.to_csv('submission1.csv',index=False)
 print("Your submission was successfully saved!" )