Kaggle competition: Titanic - Machine Learning from Disaster
df = train.fillna('NA' ).groupby(['Country_Region','Province_State','Date'])['ConfirmedCases'].sum() \ 
.groupby(['Country_Region','Province_State'] ).max().sort_values() \ 
.groupby(['Country_Region'] ).sum().sort_values(ascending = False)
 top20_countries = pd.DataFrame(df ).head(20)
 top20_countries<load_from_csv>
train_data = pd.read_csv("/kaggle/input/titanic/train.csv")
 test_data = pd.read_csv("/kaggle/input/titanic/test.csv" )
test = pd.read_csv(f'{PATH}/test.csv')
 test.head()<correct_missing_values>
women = train_data.loc[train_data.Sex == 'female']["Survived"]
rate_women = sum(women)/len(women)
 print("% of women who survived:", rate_women )
x = X.fillna('NA' )<data_type_conversions>
men = train_data.loc[train_data.Sex == 'male']["Survived"]
rate_men = sum(men)/len(men)
 print("% of men who survived:", rate_men )
X_train = train
X_train['Date'] = pd.to_datetime(X_train['Date'], infer_datetime_format=True)
 test['Date'] = pd.to_datetime(test['Date'], infer_datetime_format=True)
<load_pretrained>
train_data['age_group'] = pd.cut(train_data.Age, bins=[0, 10, 20, 30, 40, 50, 60, 70, 80])
 Gender_grp = train_data.groupby(['Sex'])
 percent_present = dict(Gender_grp.get_group('female' ).age_group.value_counts(normalize=True))
num_present = dict(Gender_grp.get_group('female' ).age_group.value_counts())
 survivors = Gender_grp.get_group('female')[Gender_grp.get_group('female' ).Survived == 1]
age_survived = {}
for i in num_present:
age_survived[i] = survivors.loc[survivors.age_group==i]["Survived"].count()
list_of_dict = [age_survived,num_present]
female_survivors = pd.DataFrame(list_of_dict, index = ["Survived","Total"] ).transpose()
female_survivors["Normalized"] = female_survivors['Survived']/female_survivors['Total']
female_survivors
EMPTY_VAL = "EMPTY_VAL"
def fillState(Province_State, Country_Region):
if Province_State == EMPTY_VAL: return Country_Region
return Province_State<data_type_conversions>
num_present = dict(Gender_grp.get_group('male' ).age_group.value_counts())
 print(num_present)
 survivors_1 = Gender_grp.get_group('male')[Gender_grp.get_group('male' ).Survived == 1]
age_survived_1 = {}
for i in num_present:
age_survived[i] = survivors_1.loc[survivors_1.age_group==i]["Survived"].count()
list_of_dict = [age_survived,num_present]
male_survivors = pd.DataFrame(list_of_dict, index = ["Survived","Total"] ).transpose()
male_survivors["Normalized"] = male_survivors['Survived']/male_survivors['Total']
male_survivors
X_train_new = X_train.copy()
X_train_new['Province_State'].fillna(EMPTY_VAL, inplace=True)
 X_train_new['Province_State'] = X_train_new.loc[:, ['Province_State', 'Country_Region']].apply(lambda x : fillState(x['Province_State'], x['Country_Region']), axis=1)
 X_train_new.loc[:, 'Date'] = X_train_new.Date.dt.strftime("%m%d")
 X_train_new["Date"] = X_train_new["Date"].astype(int)
 X_train_new.head()<categorify>
print("Number of missing values for females",Gender_grp.get_group('female' ).Age.isnull().sum())
 print("Total for females",Gender_grp.get_group('female' ).PassengerId.count())
 print("Number of missing values for males",Gender_grp.get_group('male' ).Age.isnull().sum())
 print("Total for males", Gender_grp.get_group('male' ).PassengerId.count() )
l = preprocessing.LabelEncoder()
X_train_new.Country_Region = l.fit_transform(X_train_new.Country_Region)
 X_train_new['Province_State'] = l.fit_transform(X_train_new['Province_State'])
 X_train_new.head() 
<data_type_conversions>
X_Test = test.copy()
X_Test['Province_State'].fillna(EMPTY_VAL, inplace=True)
 X_Test['Province_State'] = X_Test.loc[:, ['Province_State', 'Country_Region']].apply(lambda x : fillState(x['Province_State'], x['Country_Region']), axis=1)
 X_Test.loc[:, 'Date'] = X_Test.Date.dt.strftime("%m%d")
 X_Test["Date"] = X_Test["Date"].astype(int)
 X_Test.head()<categorify>
pclass_group = train_data.groupby('Pclass')
X_Test.Country_Region = l.fit_transform(X_Test.Country_Region)
 X_Test['Province_State'] = l.fit_transform(X_Test['Province_State'])
 X_Test.head() 
<create_dataframe>
num_present_pclass_1 = dict(pclass_group.get_group(1 ).age_group.value_counts())
 survived_age_pclass_1 = {}
for i in num_present_pclass_1:
value = pclass_group.get_group(1 ).loc[pclass_group.get_group(1 ).age_group == i]['Survived']
survived_age_pclass_1[i]=sum(value)
 list_of_pclass_1=[survived_age_pclass_1,num_present_pclass_1]
pclass_1 = pd.DataFrame(list_of_pclass_1,index=['Survived','Total'] ).transpose()
pclass_1['normalised'] = pclass_1['Survived']/pclass_1['Total']
p1_final = pd.DataFrame()
p3 = pd.DataFrame()
pred = pd.DataFrame()
p = list()
id_1 = pd.DataFrame()
id_2 = pd.DataFrame()
p1 =list()
for i in country:
id_1 = pd.concat([id_1,id_2])
 state = X_train_new.loc[X_train_new.Country_Region == i, :].Province_State.unique()
for j in state:
X_train_1 = X_train_new.loc[(X_train_new.Country_Region == i)&(X_train_new.Province_State == j), ['Province_State', 'Country_Region', 'Date', 'ConfirmedCases', 'Fatalities']]
Y_train1 = X_train_1.loc[:, 'ConfirmedCases']
Y_train2 = X_train_1.loc[:, 'Fatalities']
X_train_1 = X_train_1.loc[:, ['Province_State', 'Country_Region', 'Date']]
X_train_1.Country_Region = l.fit_transform(X_train_1.Country_Region)
 X_train_1['Province_State'] = l.fit_transform(X_train_1['Province_State'])
 X_test_1 = X_Test.loc[(X_Test.Country_Region == i)&(X_Test.Province_State == j), ['Province_State', 'Country_Region', 'Date', 'ForecastId']]
X_test_Id = X_test_1.loc[:, 'ForecastId']
X_test_1 = X_test_1.loc[:, ['Province_State', 'Country_Region', 'Date']]
X_test_1.Country_Region = l.fit_transform(X_test_1.Country_Region)
 X_test_1['Province_State'] = l.fit_transform(X_test_1['Province_State'])
 model_1 = XGBRegressor(n_estimators = 5000)
 model_1.fit(X_train_1, Y_train1)
 y_poly_pred_1 = model_1.predict(X_test_1)
 model_2 = XGBRegressor(n_estimators = 5000)
 model_2.fit(X_train_1, Y_train2)
 y_poly_pred_2 = model_2.predict(X_test_1)
 p3 = pd.DataFrame({'ForecastId': X_test_Id, 'ConfirmedCases': y_poly_pred_1, 'Fatalities': y_poly_pred_2})
 pred = pd.concat([pred,p3], axis=0)
<load_from_csv>
num_present_pclass_2 = dict(pclass_group.get_group(2 ).age_group.value_counts())
 survived_age_pclass_2 = {}
for i in num_present_pclass_2:
value = pclass_group.get_group(2 ).loc[pclass_group.get_group(2 ).age_group == i]['Survived']
survived_age_pclass_2[i]=sum(value)
 list_of_pclass_2=[survived_age_pclass_2,num_present_pclass_2]
pclass_2 = pd.DataFrame(list_of_pclass_2,index=['Survived','Total'] ).transpose()
pclass_2['normalised'] = pclass_2['Survived']/pclass_2['Total']
path_week4 = '/kaggle/input/covid19-global-forecasting-week-4'
df_train = pd.read_csv(f'{path_week4}/train.csv',parse_dates=['Date'], engine='python')
 df_test = pd.read_csv(f'{path_week4}/test.csv')
 df_train.head()
df_test.head()
df_train.rename(columns={'Country_Region':'Country'}, inplace=True)
 df_test.rename(columns={'Country_Region':'Country'}, inplace=True)
 df_train.rename(columns={'Province_State':'State'}, inplace=True)
 df_test.rename(columns={'Province_State':'State'}, inplace=True)
 df_train['Date'] = pd.to_datetime(df_train['Date'], infer_datetime_format=True)
 df_test['Date'] = pd.to_datetime(df_test['Date'], infer_datetime_format=True)
 df_train.info()
df_test.info()
y1_Train = df_train.iloc[:, -2]
y1_Train.head()
y2_Train = df_train.iloc[:, -1]
y2_Train.head()
EMPTY_VAL = "EMPTY_VAL"
def fillState(state, country):
if state == EMPTY_VAL: return country
return state
X_Train = df_train.copy()
X_Train['State'].fillna(EMPTY_VAL, inplace=True)
 X_Train['State'] = X_Train.loc[:, ['State', 'Country']].apply(lambda x : fillState(x['State'], x['Country']), axis=1)
 X_Train.loc[:, 'Date'] = X_Train.Date.dt.strftime("%m%d")
 X_Train["Date"] = X_Train["Date"].astype(int)
 X_Train.head()
X_Test = df_test.copy()
X_Test['State'].fillna(EMPTY_VAL, inplace=True)
 X_Test['State'] = X_Test.loc[:, ['State', 'Country']].apply(lambda x : fillState(x['State'], x['Country']), axis=1)
 X_Test.loc[:, 'Date'] = X_Test.Date.dt.strftime("%m%d")
 X_Test["Date"] = X_Test["Date"].astype(int)
 X_Test.head()
le = preprocessing.LabelEncoder()
X_Train.Country = le.fit_transform(X_Train.Country)
 X_Train['State'] = le.fit_transform(X_Train['State'])
 X_Train.head()
X_Test.Country = le.fit_transform(X_Test.Country)
 X_Test['State'] = le.fit_transform(X_Test['State'])
 X_Test.head()
df_train.head()
df_train.loc[df_train.Country == 'Afghanistan', :]
df_test.tail()
filterwarnings('ignore')
 le = preprocessing.LabelEncoder()
countries = X_Train.Country.unique()
df_out = pd.DataFrame({'ForecastId': [], 'ConfirmedCases': [], 'Fatalities': []})
 for country in countries:
states = X_Train.loc[X_Train.Country == country, :].State.unique()
for state in states:
X_Train_CS = X_Train.loc[(X_Train.Country == country)&(X_Train.State == state), ['State', 'Country', 'Date', 'ConfirmedCases', 'Fatalities']]
y1_Train_CS = X_Train_CS.loc[:, 'ConfirmedCases']
y2_Train_CS = X_Train_CS.loc[:, 'Fatalities']
X_Train_CS = X_Train_CS.loc[:, ['State', 'Country', 'Date']]
X_Train_CS.Country = le.fit_transform(X_Train_CS.Country)
 X_Train_CS['State'] = le.fit_transform(X_Train_CS['State'])
 X_Test_CS = X_Test.loc[(X_Test.Country == country)&(X_Test.State == state), ['State', 'Country', 'Date', 'ForecastId']]
X_Test_CS_Id = X_Test_CS.loc[:, 'ForecastId']
X_Test_CS = X_Test_CS.loc[:, ['State', 'Country', 'Date']]
X_Test_CS.Country = le.fit_transform(X_Test_CS.Country)
 X_Test_CS['State'] = le.fit_transform(X_Test_CS['State'])
 classifier1 = RandomForestClassifier(n_estimators = 1000, criterion = 'entropy', random_state = 0)
 classifier1.fit(X_Train_CS, y1_Train_CS)
 Y1_pred = classifier1.predict(X_Test_CS)
 classifier2 = RandomForestClassifier(n_estimators = 1000, criterion = 'entropy', random_state = 0)
 classifier2.fit(X_Train_CS, y2_Train_CS)
 Y2_pred = classifier2.predict(X_Test_CS)
 df = pd.DataFrame({'ForecastId': X_Test_CS_Id, 'ConfirmedCases': Y1_pred, 'Fatalities': Y2_pred})
 df_out = pd.concat([df_out, df], axis=0)
 df_out.ForecastId = df_out.ForecastId.astype('int')
 df_out.tail()
df_out.to_csv('submission.csv', index=False )<import_modules>
num_present_pclass_3 = dict(pclass_group.get_group(3 ).age_group.value_counts())
 survived_age_pclass_3 = {}
for i in num_present_pclass_3:
value = pclass_group.get_group(3 ).loc[pclass_group.get_group(3 ).age_group == i]['Survived']
survived_age_pclass_3[i]=sum(value)
 list_of_pclass_3=[survived_age_pclass_3,num_present_pclass_3]
pclass_3 = pd.DataFrame(list_of_pclass_3,index=['Survived','Total'] ).transpose()
pclass_3['normalised'] = pclass_3['Survived']/pclass_3['Total']
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.model_selection import train_test_split
from xgboost import XGBRegressor
from sklearn.multioutput import MultiOutputRegressor
from sklearn.impute import SimpleImputer<load_from_csv>
gender_class_group = train_data.groupby(['Sex','Pclass'] )
train_data = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/train.csv')
 test_data = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/test.csv')
 submission_csv = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/submission.csv' )<data_type_conversions>
num_present_gender_class_1 = dict(gender_class_group.get_group(( 'female',1)).age_group.value_counts())
 survived_1 = {}
for i in num_present_gender_class_1:
value = gender_class_group.get_group(( 'female',1)).loc[gender_class_group.get_group(( 'female',1)).age_group==i]['Survived']
survived_1[i] = sum(value)
 list_1 = [survived_1,num_present_gender_class_1]
gender_class_1 = pd.DataFrame(list_1, index = ['Survived','Total'] ).transpose()
gender_class_1
train_data['Date'] = pd.to_datetime(train_data['Date'], infer_datetime_format=True)
 test_data['Date'] = pd.to_datetime(test_data['Date'], infer_datetime_format=True )<data_type_conversions>
print("Number of missing values for females",gender_class_group.get_group(( 'female',1)).Age.isnull().sum())
 print("Total for females",gender_class_group.get_group(( 'female',1)).PassengerId.count() )
train_data.loc[:, 'Date'] = train_data.Date.dt.strftime('%y%m%d')
 train_data.loc[:, 'Date'] = train_data['Date'].astype(int)
 test_data.loc[:, 'Date'] = test_data.Date.dt.strftime('%y%m%d')
 test_data.loc[:, 'Date'] = test_data['Date'].astype(int )<feature_engineering>
train_data['Province_State'] = np.where(train_data['Province_State'] == 'nan',train_data['Country_Region'],train_data['Province_State'])
 test_data['Province_State'] = np.where(test_data['Province_State'] == 'nan',test_data['Country_Region'],test_data['Province_State'] )<data_type_conversions>
print("Number of missing values for females",gender_class_group.get_group(( 'female',1)).Age.isnull().sum())
 print("Total for females",gender_class_group.get_group(( 'female',1)).PassengerId.count() )
convert_dict = {'Province_State': str}
train_data = train_data.astype(convert_dict)
 test_data = test_data.astype(convert_dict )<define_variables>
num_present_gender_class_2 = dict(gender_class_group.get_group(( 'female',2)).age_group.value_counts())
 survived_2 = {}
for i in num_present_gender_class_2:
value = gender_class_group.get_group(( 'female',2)).loc[gender_class_group.get_group(( 'female',2)).age_group==i]['Survived']
survived_2[i] = sum(value)
 list_2 = [survived_2,num_present_gender_class_2]
gender_class_2 = pd.DataFrame(list_2, index = ['Survived','Total'] ).transpose()
gender_class_2
s =(train_data.dtypes == 'object')
 object_cols = list(s[s].index )<import_modules>
print("Number of missing values for females",gender_class_group.get_group(( 'female',2)).Age.isnull().sum())
 print("Total for females",gender_class_group.get_group(( 'female',2)).PassengerId.count() )
from sklearn.preprocessing import LabelEncoder<categorify>
num_present_gender_class_3 = dict(gender_class_group.get_group(( 'female',3)).age_group.value_counts())
 survived_3 = {}
for i in num_present_gender_class_3:
value = gender_class_group.get_group(( 'female',3)).loc[gender_class_group.get_group(( 'female',3)).age_group==i]['Survived']
survived_3[i] = sum(value)
 list_3 = [survived_3,num_present_gender_class_3]
gender_class_3 = pd.DataFrame(list_3, index = ['Survived','Total'] ).transpose()
gender_class_3
label_encoder1 = LabelEncoder()
label_encoder2 = LabelEncoder()
train_data['Province_State'] = label_encoder1.fit_transform(train_data['Province_State'])
 test_data['Province_State'] = label_encoder1.transform(test_data['Province_State'])
 train_data['Country_Region'] = label_encoder2.fit_transform(train_data['Country_Region'])
 test_data['Country_Region'] = label_encoder2.transform(test_data['Country_Region'])
<define_variables>
print("Number of missing values for females",gender_class_group.get_group(( 'female',3)).Age.isnull().sum())
 print("Total for females",gender_class_group.get_group(( 'female',3)).PassengerId.count() )
Test_id = test_data.ForecastId<drop_column>
num_present_gender_class_4 = dict(gender_class_group.get_group(( 'male',1)).age_group.value_counts())
 survived_4 = {}
for i in num_present_gender_class_4:
value = gender_class_group.get_group(( 'male',1)).loc[gender_class_group.get_group(( 'male',1)).age_group==i]['Survived']
survived_4[i] = sum(value)
 list_4 = [survived_4,num_present_gender_class_4]
gender_class_4 = pd.DataFrame(list_4, index = ['Survived','Total'] ).transpose()
gender_class_4
train_data.drop(['Id'], axis=1, inplace=True)
 test_data.drop('ForecastId', axis=1, inplace=True )<count_missing_values>
print("Number of missing values for males",gender_class_group.get_group(( 'male',1)).Age.isnull().sum())
 print("Total for males",gender_class_group.get_group(( 'male',1)).PassengerId.count() )
missing_val_count_by_column =(train_data.isnull().sum())
 print(missing_val_count_by_column[missing_val_count_by_column>0] )<import_modules>
num_present_gender_class_5 = dict(gender_class_group.get_group(( 'male',2)).age_group.value_counts())
 survived_5 = {}
for i in num_present_gender_class_5:
value = gender_class_group.get_group(( 'male',2)).loc[gender_class_group.get_group(( 'male',2)).age_group==i]['Survived']
survived_5[i] = sum(value)
 list_5 = [survived_5,num_present_gender_class_5]
gender_class_5 = pd.DataFrame(list_5, index = ['Survived','Total'] ).transpose()
gender_class_5
from xgboost import XGBRegressor<prepare_x_and_y>
print("Number of missing values for males",gender_class_group.get_group(( 'male',2)).Age.isnull().sum())
 print("Total for males",gender_class_group.get_group(( 'male',2)).PassengerId.count() )
X_train = train_data[['Province_State','Country_Region','Date']]
y_train = train_data[['ConfirmedCases', 'Fatalities']]<prepare_x_and_y>
num_present_gender_class_6 = dict(gender_class_group.get_group(( 'male',3)).age_group.value_counts())
 survived_6 = {}
for i in num_present_gender_class_6:
value = gender_class_group.get_group(( 'male',3)).loc[gender_class_group.get_group(( 'male',3)).age_group==i]['Survived']
survived_6[i] = sum(value)
 list_6 = [survived_6,num_present_gender_class_6]
gender_class_6 = pd.DataFrame(list_6, index = ['Survived','Total'] ).transpose()
gender_class_6
y_train_confirm = y_train.ConfirmedCases
y_train_fatality = y_train.Fatalities<split>
print("Number of missing values for males",gender_class_group.get_group(( 'male',3)).Age.isnull().sum())
 print("Total for males",gender_class_group.get_group(( 'male',3)).PassengerId.count() )
x_train = X_train.iloc[:,:].values
x_test = X_train.iloc[:,:].values<train_model>
num_2 = train_data.Parch.unique()
cnt_3 = Counter()
for num in train_data.Parch:
cnt_3.update([num])
 print(cnt_3)
 for num in cnt_3:
num_survived = train_data.loc[train_data.Parch == num]["Survived"]
print(sum(num_survived))
rate_survived = sum(num_survived)/cnt_3[num]
print("% of {} parent/child survived".format(num), rate_survived)
model1 = XGBRegressor(n_estimators=40000)
 model1.fit(X_train, y_train_confirm)
 y_pred_confirm = model1.predict(test_data )<train_model>
for i in range(len(train_data)) :
if np.isnan(train_data["Age"][i]):
if train_data["Sex"][i]=='female':
train_data.at[i,"Age"]= 80
else:
train_data.at[i,"Age"]=70
for i in range(len(test_data)) :
if np.isnan(test_data["Age"][i]):
if test_data["Sex"][i]=='female':
test_data.at[i,"Age"]= 80
else:
test_data.at[i,"Age"]=70
model2 = XGBRegressor(n_estimators=20000)
 model2.fit(X_train,y_train_fatality)
 y_pred_fat = model2.predict(test_data )<save_to_csv>
df_sub = pd.DataFrame()
df_sub['ForecastId'] = Test_id
df_sub['ConfirmedCases'] = y_pred_confirm
df_sub['Fatalities'] = y_pred_fat
df_sub.to_csv('submission.csv', index=False )<load_from_csv>
interaction_train_2 = train_data.Age/train_data.Pclass
interaction_test_2 = test_data.Age/test_data.Pclass
interaction_test_1 = test_data.SibSp+test_data.Parch
interaction_train_1 = train_data.SibSp+train_data.Parch
df_train = pd.read_csv('.. /input/covid19-global-forecasting-week-4/train.csv')
 df_test = pd.read_csv('.. /input/covid19-global-forecasting-week-4/test.csv')
 df_train.head()<feature_engineering>
features = ['Sex','Age','Pclass']
X_train = train_data[features]
X_test = test_data[features]
y = train_data.Survived
def datesplit(df):
year = []
month = []
day = []
for item in df['Date']:
x = item.split("-")
 year.append(x[0])
 month.append(x[1])
 day.append(x[2])
 df['Year'] = year
df['Month'] = month
df['Day'] = day
datesplit(df_train)
 datesplit(df_test)
 df_train['ConfirmedCases'] = df_train['ConfirmedCases'].apply(int)
 df_train['Fatalities'] = df_train['Fatalities'].apply(int)
 df_train.head() 
<categorify>
X_train.insert(1,"interaction",interaction_train_1)
 X_train.insert(2,"interaction_1",interaction_train_2)
 X_test.insert(1,"interaction",interaction_test_1)
 X_test.insert(2,"interaction_1",interaction_test_2)
df_train['Province_State'].fillna('',inplace=True)
 df_test['Province_State'].fillna('',inplace=True)
 lbe = LabelEncoder()
df_train['Country_Region'] = lbe.fit_transform(df_train['Country_Region'])
 df_test['Country_Region'] = lbe.transform(df_test['Country_Region'])
 df_train['Province_State'] = lbe.fit_transform(df_train['Province_State'])
 df_test['Province_State'] = lbe.transform(df_test['Province_State'])
<normalization>
label_X_train = X_train.copy()
label_X_test = X_test.copy()
label_encoder = LabelEncoder()
label_X_train['Sex'] = label_encoder.fit_transform(X_train['Sex'])
 label_X_test['Sex'] = label_encoder.transform(X_test['Sex'])
X_train = df_train.drop(["Id", "ConfirmedCases", "Fatalities", "Date"], axis = 1)
 X_test = df_test.drop(["ForecastId","Date"], axis = 1)
 scaler = MinMaxScaler()
X_train = scaler.fit_transform(X_train.values)
 X_test = scaler.transform(X_test.values )<prepare_x_and_y>
label_X_test.tail()
y1 = df_train['ConfirmedCases']
y2 = df_train['Fatalities'] 
<define_variables>
train_X, valid_X, y_train, y_valid = train_test_split(label_X_train,y,random_state =1 )
y_train = y1
y_train_fat = y2<train_model>
xgb = XGBRegressor(n_estimators = 1500 , random_state = 0 , max_depth = 15)
 xgb.fit(X_train,y_train )<predict_on_test>
model = LogisticRegression()
model.fit(train_X, y_train)
 predictions_val = model.predict(valid_X)
 mae = mean_absolute_error(y_valid,predictions_val)
 print(mae )
y_pred = xgb.predict(X_test)
 y_pred = np.around(y_pred,decimals = 0)
 y_pred<train_model>
predictions = model.predict(label_X_test)
 output = pd.DataFrame({'PassengerId': test_data.PassengerId, 'Survived': predictions})
 output.to_csv('my_submission.csv', index=False)
 print("Your submission was successfully saved!" )