<gh_stars>0
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
import seaborn as sns
import inspect, os.path
# filePath=os.path.dirname(os.path.abspath(__file__))+'\\DataSets\\train.csv'
# print(filePath)

filename = inspect.getframeinfo(inspect.currentframe()).filename
path     = os.path.dirname(os.path.abspath(filename))+"/datasets/titanic/output.csv"


data=pd.read_csv(path)
print("Subset of the Data from the Output")
print(data.head())
fig, ax = plt.subplots(1,1,figsize=(13,5))
sns.heatmap(data.isnull(), cbar=False, cmap="YlGnBu_r")
#plt.show()
total = data.isnull().sum().sort_values(ascending = False)
percent = round(data.isnull().sum().sort_values(ascending = False)/len(data)*100, 2)
temp = pd.concat([total, percent], axis = 1,keys= ['Total', 'Percent'])
# ax [1] = sns.barplot(data=data.isnull())
plt.xticks(rotation=90)
f,ax=plt.subplots(1,5,figsize=(13,5))
data['Survived'].value_counts().plot.pie(explode=[0,0.05],autopct='%1.1f%%',ax=ax[1],shadow=True)
ax[0].set_title('Survived')
ax[0].set_ylabel('')
sns.countplot('Survived',data=data,ax=ax[0])
ax[1].set_title('Survived')
# plt.show()
#f,ax=plt.subplots(1,3,figsize=(18,5))
data[['Sex','Survived']].groupby(['Sex']).mean().plot.bar(ax=ax[2])
ax[2].set_title('Fraction of Survival \n with respect to Sex')
sns.countplot('Sex',hue='Survived',data=data,ax=ax[3])
ax[3].set_title('Survived vs Dead counts \n with respect to Sex')
sns.barplot(x="Sex", y="Survived", data=data,ax=ax[4])
ax[4].set_title('Survival by Gender')
f.show()
plt.show()
f,ax=plt.subplots(1,3,figsize=(18,5))
data['Pclass'].value_counts().plot.bar(color=['#BC8F8F','#F4A460','#DAA520'],ax=ax[0])
ax[0].set_title('Number Of Passengers \n with respect to Pclass')
ax[0].set_ylabel('Count')
sns.countplot('Pclass',hue='Survived',data=data,ax=ax[1])
ax[1].set_title('Survived vs Dead counts \n with respect to Pclass')
sns.barplot(x="Pclass", y="Survived", data=data,ax=ax[2])
ax[2].set_title('Survival by Pclass')
f.show()
plt.show()
f,ax=plt.subplots(1,1,figsize=(25,6))
sns.barplot(data['Age'],data['Survived'], ci=None, ax=ax)
ax.set_title('Survived vs Dead counts with respect to Pclass')
plt.xticks(rotation=90)
f.show()
plt.show()
f,ax=plt.subplots(1,2,figsize=(18,6))
data.boxplot(column=['Age'],ax=ax[0], grid=False)
ax[0].set_title('Age Box Plot')
ax[0].set_ylabel('Age Years')
sns.boxplot(y='Age', data=data, ax=ax[0])
sns.boxplot(x='Survived', y='Age', data=data, ax=ax[1])
ax[1].set_title('Age Box Plot')
ax[1].set_ylabel('Age Years')
f.show()
plt.show()
f,ax=plt.subplots(1,2,figsize=(12,5))
sns.countplot('Embarked',data=data,ax=ax[0])
ax[0].set_title('No. Of Passengers Boarded')
sns.countplot('Embarked',hue='Survived',data=data,ax=ax[1])
ax[1].set_title('Embarked vs Survived')
plt.subplots_adjust(wspace=0.2,hspace=0.5)
f.show()
plt.show()
f,ax=plt.subplots(1,2,figsize=(12,5))
sns.countplot('Embarked',hue='Sex',data=data,ax=ax[0])
ax[0].set_title('Male-Female Split for Embarked')
sns.countplot('Embarked',hue='Pclass',data=data,ax=ax[1])
ax[1].set_title('Embarked vs Pclass')
plt.subplots_adjust(wspace=0.2,hspace=0.5)
f.show()
f,ax=plt.subplots(2,2,figsize=(15,10))
sns.countplot('SibSp',hue='Survived',data=data,ax=ax[0,0])
ax[0,0].set_title('SibSp vs Survived')
sns.barplot('SibSp','Survived',data=data,ax=ax[0,1])
ax[0,1].set_title('SibSp vs Survived')
sns.countplot('Parch',hue='Survived',data=data,ax=ax[1,0])
ax[1,0].set_title('Parch vs Survived')
sns.barplot('Parch','Survived',data=data,ax=ax[1,1])
ax[1,1].set_title('Parch vs Survived')
plt.subplots_adjust(wspace=0.2,hspace=0.5)
plt.show()
f,ax=plt.subplots(1,1,figsize=(20,5))
sns.distplot(data.Fare,ax=ax)
ax.set_title('Distribution of Fares')
plt.show()
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
import seaborn as sns
import inspect, os.path
# filePath=os.path.dirname(os.path.abspath(__file__))+'\\DataSets\\train.csv'
# print(filePath)

filename = inspect.getframeinfo(inspect.currentframe()).filename
path     = os.path.dirname(os.path.abspath(filename))+"/datasets/titanic/output.csv"


data=pd.read_csv(path)
print("Subset of the Data from the Output")
print(data.head())
fig, ax = plt.subplots(1,1,figsize=(13,5))
sns.heatmap(data.isnull(), cbar=False, cmap="YlGnBu_r")
#plt.show()
total = data.isnull().sum().sort_values(ascending = False)
percent = round(data.isnull().sum().sort_values(ascending = False)/len(data)*100, 2)
temp = pd.concat([total, percent], axis = 1,keys= ['Total', 'Percent'])
# ax [1] = sns.barplot(data=data.isnull())
plt.xticks(rotation=90)
f,ax=plt.subplots(1,5,figsize=(13,5))
data['Survived'].value_counts().plot.pie(explode=[0,0.05],autopct='%1.1f%%',ax=ax[1],shadow=True)
ax[0].set_title('Survived')
ax[0].set_ylabel('')
sns.countplot('Survived',data=data,ax=ax[0])
ax[1].set_title('Survived')
# plt.show()
#f,ax=plt.subplots(1,3,figsize=(18,5))
data[['Sex','Survived']].groupby(['Sex']).mean().plot.bar(ax=ax[2])
ax[2].set_title('Fraction of Survival \n with respect to Sex')
sns.countplot('Sex',hue='Survived',data=data,ax=ax[3])
ax[3].set_title('Survived vs Dead counts \n with respect to Sex')
sns.barplot(x="Sex", y="Survived", data=data,ax=ax[4])
ax[4].set_title('Survival by Gender')
f.show()
plt.show()
f,ax=plt.subplots(1,3,figsize=(18,5))
data['Pclass'].value_counts().plot.bar(color=['#BC8F8F','#F4A460','#DAA520'],ax=ax[0])
ax[0].set_title('Number Of Passengers \n with respect to Pclass')
ax[0].set_ylabel('Count')
sns.countplot('Pclass',hue='Survived',data=data,ax=ax[1])
ax[1].set_title('Survived vs Dead counts \n with respect to Pclass')
sns.barplot(x="Pclass", y="Survived", data=data,ax=ax[2])
ax[2].set_title('Survival by Pclass')
f.show()
plt.show()
f,ax=plt.subplots(1,1,figsize=(25,6))
sns.barplot(data['Age'],data['Survived'], ci=None, ax=ax)
ax.set_title('Survived vs Dead counts with respect to Pclass')
plt.xticks(rotation=90)
f.show()
plt.show()
f,ax=plt.subplots(1,2,figsize=(18,6))
data.boxplot(column=['Age'],ax=ax[0], grid=False)
ax[0].set_title('Age Box Plot')
ax[0].set_ylabel('Age Years')
sns.boxplot(y='Age', data=data, ax=ax[0])
sns.boxplot(x='Survived', y='Age', data=data, ax=ax[1])
ax[1].set_title('Age Box Plot')
ax[1].set_ylabel('Age Years')
f.show()
plt.show()
f,ax=plt.subplots(1,2,figsize=(12,5))
sns.countplot('Embarked',data=data,ax=ax[0])
ax[0].set_title('No. Of Passengers Boarded')
sns.countplot('Embarked',hue='Survived',data=data,ax=ax[1])
ax[1].set_title('Embarked vs Survived')
plt.subplots_adjust(wspace=0.2,hspace=0.5)
f.show()
plt.show()
f,ax=plt.subplots(1,2,figsize=(12,5))
sns.countplot('Embarked',hue='Sex',data=data,ax=ax[0])
ax[0].set_title('Male-Female Split for Embarked')
sns.countplot('Embarked',hue='Pclass',data=data,ax=ax[1])
ax[1].set_title('Embarked vs Pclass')
plt.subplots_adjust(wspace=0.2,hspace=0.5)
f.show()
f,ax=plt.subplots(2,2,figsize=(15,10))
sns.countplot('SibSp',hue='Survived',data=data,ax=ax[0,0])
ax[0,0].set_title('SibSp vs Survived')
sns.barplot('SibSp','Survived',data=data,ax=ax[0,1])
ax[0,1].set_title('SibSp vs Survived')
sns.countplot('Parch',hue='Survived',data=data,ax=ax[1,0])
ax[1,0].set_title('Parch vs Survived')
sns.barplot('Parch','Survived',data=data,ax=ax[1,1])
ax[1,1].set_title('Parch vs Survived')
plt.subplots_adjust(wspace=0.2,hspace=0.5)
plt.show()
f,ax=plt.subplots(1,1,figsize=(20,5))
sns.distplot(data.Fare,ax=ax)
ax.set_title('Distribution of Fares')
plt.show()
# linear algebra # data processing, CSV file I/O (e.g. pd.read_csv) # filePath=os.path.dirname(os.path.abspath(__file__))+'\\DataSets\\train.csv' # print(filePath) #plt.show() # ax [1] = sns.barplot(data=data.isnull()) # plt.show() #f,ax=plt.subplots(1,3,figsize=(18,5))