Kaggle competition: Titanic - Machine Learning from Disaster
Embed_name=Embedding(max_text,output_dim=30 )(name)
 Embed_desc=Embedding(max_text,output_dim=30 )(item_desc)
 Embed_brand=Embedding(max_brand,output_dim=10 )(brand_name)
 Embed_cat1=Embedding(max_cat1,output_dim=10 )(cat1)
 Embed_cat2=Embedding(max_cat2,output_dim=20 )(cat2)
 Embed_cat3=Embedding(max_cat3,output_dim=20 )(cat3 )<choose_model_class>
df_train = pd.read_csv("/kaggle/input/titanic/train.csv")
 df_test = pd.read_csv("/kaggle/input/titanic/test.csv" )
rnn_name=GRU(24 )(Embed_name)
 rnn_desc=GRU(24 )(Embed_desc )<concatenate>
features = ['Sex','Pclass','SibSp','Parch']
X_train = pd.get_dummies(df_train[features])
 X_train['Age'] = df_train['Age']
X_test = pd.get_dummies(df_test[features])
 X_test['Age'] = df_test['Age']
model=concatenate([rnn_name,rnn_desc,
Flatten()(Embed_brand),Flatten()(Embed_cat1),Flatten()(Embed_cat2),
Flatten()(Embed_cat3),item_condition,ship] )<choose_model_class>
X_train['Age'] = np.where(X_train['Age'].isnull() ,X_train['Age'].median() ,X_train['Age'] )
model1=Dropout(rate=0.1 )(Dense(128 )(model))
model2=Dropout(rate=0.1 )(Dense(16 )(model1))
output=Dense(1,activation='linear' )(model2 )<create_dataframe>
X_test['Age']= np.where(X_test['Age'].isnull() ,X_test['Age'].median() ,X_test['Age'] )
model_keras=Model([name,item_desc,brand_name,cat1,
cat2,cat3,item_condition,ship],output )<choose_model_class>
y_train = df_train['Survived']
X_train
X_test
model_keras.compile(optimizer='adam',loss=['mse'],metrics=['mae'] )<prepare_x_and_y>
clf = RandomForestClassifier(max_depth=5,random_state=1)
 clf.fit(X_train,y_train )
sc_x=StandardScaler()
y=sc_x.fit_transform(np.log(x_train.price.reshape(-1,1)+1))
y_valid=sc_x.transform(np.log(x_valid.price.reshape(-1,1)+1))<train_model>
y_test = clf.predict(X_test )
model_keras.fit(train_keras,y,batch_size=20000,epochs=5 )<predict_on_test>
output = pd.DataFrame({'PassengerId':df_test['PassengerId'],'Survived':y_test} )
<prepare_output><EOS> 
output.to_csv("titanic_a2.csv",index=False )