# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory

import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))

# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" 
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
"""
# *In titanic we all saw the end but there is still hope to find if jack is still alive or not
"""
"""
![](https://th.bing.com/th/id/OIP.qKHGSOIZWuimKsQFc3svJQHaDF?pid=Api&rs=1)
"""
"""
# This notebook is a very basic approach to solve the model
"""
#Entering basic data input
train=pd.read_csv('/kaggle/input/titanic/train.csv')  #train
test=pd.read_csv('/kaggle/input/titanic/test.csv')  #test
submission=pd.DataFrame(test['PassengerId'])   
y=train['Survived']  #output
"""
# Combining the dataset
"""
dataset=pd.concat([train.drop(['PassengerId','Survived'],axis=1),test.drop('PassengerId',axis=1)])
"""
# Filling the missing values
"""
dataset['Age'].fillna(dataset['Age'].mean(),inplace=True)
dataset['Fare'].fillna(dataset['Fare'].median(),inplace=True)
dataset['Embarked'].fillna('S',inplace=True)
dataset.drop(['Cabin','Name','Ticket'],axis=1,inplace=True)
"""
# Categorical values uffff..

"""
from sklearn.preprocessing import LabelEncoder
label=LabelEncoder()
dataset['Sex']=label.fit_transform(dataset['Sex'])
dataset['Age']=dataset['Age'].astype(int)
dataset['familyno']=dataset['SibSp']+dataset['Parch']+1
"""
# Getting dummies to pass the test
"""
dataset=pd.get_dummies(dataset,columns=['Pclass','Embarked'])
dataset.drop(['SibSp','Parch'],axis=1,inplace=True)
xtrain=dataset[:len(train)]
test=dataset[len(train):]
xtrain
"""
# Finally building a machine to predict Jack is alive
"""
from sklearn.ensemble import GradientBoostingClassifier
sky=GradientBoostingClassifier()
sky.fit(xtrain,y)
c=sky.predict(test)
submission['Survived']=c
submission.to_csv('ver1.csv',index=False)
"""
Using just basic modelling we get an accuracy of 79% .
Later we try to add mor columns to increase the fuctionality. 
"""
"""
# If you liked the model please give it a one like,
# Help jack in titanic.....


![](https://www.quirkybyte.com/wp-content/uploads/2017/05/t.jpg)



"""