Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
45 views
12 pages
Titanic Akshaya
Uploaded by
Akshaya Venkatarama
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Titanic_Akshaya For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
45 views
12 pages
Titanic Akshaya
Uploaded by
Akshaya Venkatarama
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Titanic_Akshaya For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Titanic_Akshaya For Later
You are on page 1
/ 12
Search
Fullscreen
Task 2 - Titanic Classification Problem Statement: * Develop a predictive model based on ‘Titanic Dataset’ to identify ” what sorts of people were more likely to survive ? * using passenger data such as name, age, gender, socio- economic class, etc. wimporting necessary Libraries import pandas as pd import numpy as np import warnings warnings. filterwarnings (‘ignore’) #importing Librartes for visualisation import matplotlib.pyplot as plt from matplotlib import style import seaborn as sns importing Data data_file=r'C: \Users\sinus\OneDrive\Documents\bharatintern\Titanic Dataset.csv’ data_frame=pd.read_csv(data_file) i? analysis. Understand the variables and their lues. Performing descri corresponding val # Understanding the Oata Variables data_frame.info()
RangeIndex: 891 entries, @ to 890 Data columns (total 12 columns) # Column Non-Null Count Dtype @ PassengerTd 891 non-null 1 Survived 891 non-null 2 Pelass 891 non-null 3° Name 891 non-null object 4 Sex 891 non-null object 5 Age 714 non-null —float64 6 Sibsp 891 non-null —int64 7 Parch 891 non-null —int64 8 Ticket 891 non-null object 9 Fare 891 non-null —floatea 10 Cabin 204 non-null —_ object 11 Embarked 889 non-null —_object dtypes: Floatea(2), int6a(s), object(5) memory usage: 83.7+ KB # Show the top 5 Rows of data data_frane.head()out [4 Passengerld Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabir Braund, o 1 0 3 MrOwen male 220 1 0 Harris NS ain 72500 Nah Cumings, Mrs. John Bradley (Florence Briggs Th. female 380 1 © 0 PC 17599 71.2833 CAE Heikkinen, 2 3 1 3 Miss, female 260 0 0 Laina STON/O2 protzea 72250. Nah Futrelle, Mrs. Jacques Heath (lily May Peel) female 350 1 =—«O—*113803._ $3.10, Allen, Mr. 4 5 0 3 William male 350 «= «0 = «037345080500 Nak Henry ee » a#Identify columns in Dataset data_frame.columns Index(['PassengerId', ‘Survived’, ‘Pclass', ‘Name’, ‘Sex’, ‘Age’, ‘Sibsp', ‘Parch', ‘Ticket’, ‘Fare’, ‘Cabin’, ‘Embarked'], dtype="object') Data Cleaning # Checking for null values data_frame.isnull().sum() PassengerId Survived Pclass Name Sex Age 17 sibsp Parch Ticket Fare Cabin 68) Embarked dtype: intea Yescce coos * Variable ‘Age’ contains 177 null values, So the respective null values can be replaced by the mean values of Age. * Variable ‘Cabin’ can be dropped as it contains 687 null values. # Null values in “Age” column replaced by the mean values data_frame['Age’] = data_frame[ ‘Age’].fillna(data_frame[ ‘Age’ ].mean().round())data_frame[ 'PassengerId'].value_counts() 1 599 588 589 590 301 302 303 304 go. 1 Name: Passengerid, Length: 891, dtype: inte data_frame[' Ticket] .value_counts() 347082 7 cA. 23437 1601 7 31012956 cA 2144 «6 9234 19988 2693 Pc 17612 370376 1 Name: Ticket, Length: 681, dtype: intea * Variables 'Passengerid’ and ‘Ticket’ can be dropped as they have numerous unique values. data_frame.drop({"Passengerid” ‘abin"], axis=1,inplace=true) # Show the remaining coLunns data_frane.columns Index(['Survived', ‘Pclass', ‘Sex’, ‘Age’, 'Sibsp', ‘Parch', ‘Fare’, "embarked" J, dtype="object') ‘a#Checking values in ‘Survived’ Variable data_frame[' Survived" ].value_counts() e549 1 342 Name: Survived, dtype: intes * Survived represented by '1', Not Survived by'0" ‘#hecking values in 'Embarked’ Variable data_frame.Embarked.unique() array(['S', ‘C', 'Q', nan], dtype-object) * Embarked represents the port where the passengers are embarked from , such as C for Cherbourg, Q for Queenstown, S for Southampton.Checking values in ‘Sex’ Variable data_frame[ 'Sex'].value_counts() male 577 female 314 Name: Sex, dtype: int64 Checking values tn ‘Pclass’ Variable data_frame[ 'Pclass'].value_counts() 3 4a 1 216 2 184 Name: Pelass, dtype: intea Checking values in ‘Sibsp’ Variable w#SibSp represents number of sibLings or spouses traveling with passenger data_frame[ 'Sibsp’].value_counts() 2 608 1 209 2 28 4 1B 3 16 8 7 5 5 Name: SibSp, dtype: int6a ‘a#Checking values in ‘Parch’ Variable #arch represents number of parents or children traveling with passenger data_frame[ 'Parch’].value_counts() o 678 1 ous 2 80 5 5 3 5 4 4 6 1 Name: Parch, dtype: intea Data Visualization # find correation between variables in data set for plotting heatmap df_corr=data_frane.corr() # Plotting Heatmap pit. Figure(Figsize=(10,6)) sns.heatmap(d#_corr, annot=True, cmap="BuPUu" ) plt.show()055 - 704 Pelass age sibsp * Variables Fare, Parch have positive correlation values with the target variable ‘Survived’ ) [19]: | # Plotting Histogram of ‘survived’ variable data_frane[ ‘Survived’ ].value_counts() .plot (kin« ‘bar’ ,figsize=(5,3)) cAxes: > 500 400 300 2004 1004 1 [20]: # Plotting countplot of no: of Survivors for 'émbarked’ variable sns.countplot(data_frame, x="Embarked” ,hue="Survived" )
count Sex n # Plotting countplot of no: of Survivors for ‘Pclass’ variable sns.countplot (data_frame,x='Pclass' ,hue="Survived' )Survived 350 mmo m1 300 | 250 count 8 8 150 100 50 1 2 3 Pelass 1 # Plotting countplot of no: of Survivors for 'stbsp’ variable sns.countplot (data_frame, x="SibSp’ ,hue='Survived")
400 350 300 ° 1 2 3 4 5 sibsp ) [24]: # Plotting countpLot of no: of Survivors for ‘Parch' variable sn. countplot (data_frame, x='Parch’ ,hue='Survived" )
You might also like
23BCE7092 ML Lab Assignment
PDF
No ratings yet
23BCE7092 ML Lab Assignment
14 pages
Titanic Survival Prediction ML
PDF
No ratings yet
Titanic Survival Prediction ML
36 pages
Titanic Dataset Model Prediction
PDF
No ratings yet
Titanic Dataset Model Prediction
11 pages
Titanic
PDF
No ratings yet
Titanic
6 pages
Decision Tree
PDF
No ratings yet
Decision Tree
2 pages
Logistic Regression On Titanic Dataset
PDF
No ratings yet
Logistic Regression On Titanic Dataset
6 pages
Machine Learning Lab Assignment 1
PDF
No ratings yet
Machine Learning Lab Assignment 1
23 pages
Maneesha Nidigonda Minor Project .Ipynb
PDF
No ratings yet
Maneesha Nidigonda Minor Project .Ipynb
35 pages
01-Logistic Regression With Python
PDF
No ratings yet
01-Logistic Regression With Python
12 pages
23BCE7199 ML Lab Assignment
PDF
No ratings yet
23BCE7199 ML Lab Assignment
15 pages
Homework 2
PDF
No ratings yet
Homework 2
12 pages
ML File 211173
PDF
No ratings yet
ML File 211173
19 pages
1
PDF
No ratings yet
1
13 pages
EX - NO:3: Algorithm
PDF
No ratings yet
EX - NO:3: Algorithm
11 pages
Iml Project
PDF
No ratings yet
Iml Project
13 pages
Aim: Predicting The Survival of Titanic Passengers
PDF
No ratings yet
Aim: Predicting The Survival of Titanic Passengers
20 pages
M PDF
PDF
No ratings yet
M PDF
13 pages
1.1 Loading The Data: Survival by Sex
PDF
No ratings yet
1.1 Loading The Data: Survival by Sex
6 pages
Titanic PuneethRegonda
PDF
No ratings yet
Titanic PuneethRegonda
8 pages
Iii Aid - ML
PDF
No ratings yet
Iii Aid - ML
30 pages
Home Work
PDF
No ratings yet
Home Work
12 pages
1 10
PDF
No ratings yet
1 10
4 pages
MANUAL
PDF
No ratings yet
MANUAL
33 pages
Titanic Survival Prediction Using Machine Learning
PDF
No ratings yet
Titanic Survival Prediction Using Machine Learning
7 pages
The Titanic Dataset
PDF
No ratings yet
The Titanic Dataset
6 pages
Titanic
PDF
No ratings yet
Titanic
3 pages
Titanic
PDF
No ratings yet
Titanic
3 pages
5) Randomforest - Ipynb - Colaboratory
PDF
No ratings yet
5) Randomforest - Ipynb - Colaboratory
12 pages
Assignment2 DMS672
PDF
No ratings yet
Assignment2 DMS672
15 pages
Ai Tools and Applications-Lab
PDF
No ratings yet
Ai Tools and Applications-Lab
33 pages
Ashwin Report
PDF
No ratings yet
Ashwin Report
18 pages
4.1.3.5 Lab - Decision Tree Classification
PDF
No ratings yet
4.1.3.5 Lab - Decision Tree Classification
11 pages
Loading The Dataset: ## The Matplotlib and Seaborn Library For Result Visualization and Analysis
PDF
No ratings yet
Loading The Dataset: ## The Matplotlib and Seaborn Library For Result Visualization and Analysis
13 pages
Titanic Eda
PDF
No ratings yet
Titanic Eda
14 pages
Titanic Data Analysis
PDF
No ratings yet
Titanic Data Analysis
14 pages
Dav Lab Manual
PDF
No ratings yet
Dav Lab Manual
28 pages
Import Pandas As PD DF PD - Read - CSV ("Titanic - Train - CSV") DF - Head
PDF
No ratings yet
Import Pandas As PD DF PD - Read - CSV ("Titanic - Train - CSV") DF - Head
20 pages
ML Assignment
PDF
No ratings yet
ML Assignment
34 pages
Laporan Titanic Survival Prediction - 132021012
PDF
No ratings yet
Laporan Titanic Survival Prediction - 132021012
6 pages
Machine Learning Lab Manual
PDF
No ratings yet
Machine Learning Lab Manual
26 pages
Ahamed 123
PDF
100% (1)
Ahamed 123
7 pages
Practical No 01
PDF
No ratings yet
Practical No 01
9 pages
Prathamesh KRAI
PDF
No ratings yet
Prathamesh KRAI
38 pages
ML Labmanual
PDF
No ratings yet
ML Labmanual
33 pages
# Load The Titanic Dataset: Import As Import As From Import From Import
PDF
No ratings yet
# Load The Titanic Dataset: Import As Import As From Import From Import
9 pages
ML Short Code - Under Updating
PDF
No ratings yet
ML Short Code - Under Updating
4 pages
Name: Mussab Bin Shahid Sap-Id: 2024 Assignment: Machine-Learning
PDF
No ratings yet
Name: Mussab Bin Shahid Sap-Id: 2024 Assignment: Machine-Learning
5 pages
Titanic Survival Prediction
PDF
No ratings yet
Titanic Survival Prediction
14 pages
Final
PDF
No ratings yet
Final
15 pages
Exercise and Experiment 3
PDF
No ratings yet
Exercise and Experiment 3
14 pages
Train
PDF
No ratings yet
Train
17 pages
ML Lab Manual
PDF
No ratings yet
ML Lab Manual
24 pages
Random Forest Algorithm - Titanic Dataset
PDF
No ratings yet
Random Forest Algorithm - Titanic Dataset
12 pages
Scikit Learn Cheat Sheet Python
PDF
No ratings yet
Scikit Learn Cheat Sheet Python
1 page