TITANIC SURVIVAL PREDICTION using TensorFlow | Machine Learning Projects | GeeksforGeeks
Key Takeaways
Builds a Titanic survival prediction model using TensorFlow
Full Transcript
hello everyone welcome to Geeks for Geeks so in this particular video we will talk about a very interesting implementation about the Titanic survival prediction I hope that uh you know this data set you already are aware of at one point of time you definitely have used this data as well because this is quite famous data right so we have been given a number of features on the basis of that the the problem statement is that we need to determine that whether a person will survive or not that's a simple classification problem where we will be having either zero which indicates that the person will not survive and one which indicates that the person will survive now usually you will see that this implementation people usually do via you know machine learning classification algorithms and we do have a lot of uh you know classification algorithms right but in today's video my objective is not to talk about you know machine learning classification algorithms and doing the implementation via that today we will try to talk about how basically using tensor flow and inside that tensor flow uh you know TF learn which is a you know deep learning library which is built on top of tensor flow only so this is a deep learning library which is basically built on top of this tensor flow only so I'll try to demonstrate you the complete end to end implementation but before that let's try to understand that what is the approach that we will follow in order to do the implementation of the same so the very first thing I hope everyone knows that first of all we have to load the data so this is what we will do also we will try to load the data set that we have once we will be able to load the data set we need to obviously pre-process that data what is the meaning of pre-processing I hope everyone knows that for example uh in the given data if you will be having some uh you know categorical feature we need to convert that into a numerical data right because we all know that whenever we train our deep deep learning neural network that only understand the numeric values or maybe we need to you know remove the columns which are not likely to use to predict the survival rate of any person so these things we will try to cover up in the pre-process part the third important step is after doing the complete pre-processing of a data set we will try to you know build the uh I would say neural network classifier right we will try to build the neural network classifier once that is done the next step is to do the model training because now our classifier is ready we need to train that classifier on top of our data that we have and that is what we will do as our fourth step and the very last step is to you know uh do the predictions of our model that we are getting so we'll try to do a model predictions these are the five steps that we will follow step by step we'll try to do one by one every step and then I'll tick mark each and everything so let's get started with the implementation part uh so let me show you so first of all we will connect this collab file and I would recommend that you will just try to use the GPU as the runtime type it will be really helpful when we will try to train our model okay now here what we will try to do first first of all because TF learn is a library which we need to first of all install right so we will install that now whatsoever be the important packages which I believe is required in order to you know do the further implementation I'm just trying to import those so here basically we are trying to import all the required libraries namely naai and pandas and TF learn which we direct which we just just now have installed now once the is done we need to download the data set so in TF learn there are a lot many data sets that we have from all those data sets what what we need to import is the Titanic data set so what we are saying download the data set the the file name is Titanic datas set. CSV so this is done so if we'll just say print the data set so here we will be able to get the CSV file now suppose I want to read the content inside that CSV file so what I will say I'll say read CSV so we will be able to get a data frame and if I'll just say do head you will be easily able to get that in the head obviously we will be able to get the topmost five records starting from survived P class Name six until the fair column so all these are the columns that we have now what we want to predict we want to predict this survived thing right so either the value will be zero or it will be one so if we will just try to see the shape of our data means how many number of rows and the columns that we have so we can see that almost 1,300 number of rows that we have and nine number of columns that we have so if we'll just try to see the column names so these are the columns name that column names that we have now we need to load this particular CSV file now to load that CSV file we need to again import the function loore CSV when we are calling this function I'll just put on the cursor here try to see what parameters we are passing here Target column is something which is the index number of which particular Target you are approaching towards here if you know we are trying to find out the predictions of a survived thing which is present at the zeroth index so Target column is zero as of now after that we will be having a categorical labels so it will contain a bull value Boolean value either it is true or false true means that label returned as a binary vectors which is so true because here we want to predict a label as either zero or one so how many number of classes do we have two classes zero or one so in this way we will be able to get a out of this complete data set that that CSV file we have we are loading that and inside that we're defining our Target column which is at zero index we are defining the categorical labels as two and the number of classes as two so now if you will see we will be able to get a data and the labels separately labels contain two classes either it will be zero or one now we need to do the pre-processing in pre-processing Phase until so far step number one is done where we are trying to load our data so if I'll just try to show you uh this part is done I would say this part is done loading the data set is done done now the second important part here is to you know pre-process that second step here if you will see what we are trying to do we are trying to discard few columns why because we are assuming here that those particular columns are not that much usable to predict that whether a person will survive again this is my assumption what I'm saying that out of a given data the column number one index number one and index number six both of these two columns are not that much usable for me so what I will do here what is column number one if you will see here in data uh because we have just you know uh taken this survived column outside at first index we will be having a column and at the sixth index we will be having a ticket now it's very simple to understand here that when I'm saying you know name do you think it really matters that what the name of a person to do the final prediction that whether a person will survive or not so basically what we are assuming here is that these two columns are not that much that much usable means these two columns we are ignoring so this is something discarded columns which we are passing as a parameter and then we are trying to sort this uh you know by the ID and deleting The Columns second important thing is that we have seen that sex is something which is a you know U having a male or female which my model will not be able to understand we have to convert this particular thing into some numeric form so what we are saying that if a person will be female uh you know indicate that as one otherwise indicate that as zero so once this pre-process will be done the third important step is to build an classifier let it run let it run so in this way our you know Second Step second step is also done where we are trying to pre-process the data set in pre-processing what we usually did here majorly we focus on two aspects first aspect is you know uh discarding of those columns which we feel are not playing a you know a very useful role in order to do the predictions or in other words I can say that those columns which are not correlated with respect to the output Fe future which we are predicting second thing which we are trying to do is trying to convert that sex which is male or female to zero and one because our model will only understand the numeric data now once these two parts are done we are trying to build a neural network classifier here you can see that we are passing a shape none comma 6 six indicates the number of features none indicates undefined Dimensions which we don't know initially here we are trying to build a thre layer neural Network now you can you know increase or decrease those particular uh layers according to your own wish and according to the accuracy that you getting but here as of now we taking three layers first layer will contain 32 32 number of neurons fully connected layer is there second again 32 the last one because we will be having two classes so either it will be zero or one so it will contain two values two number of neurons and the activation function is what we're using as soft Max why soft Max because we are trying to calculate the probability of a class zero or class one so here if you will see once finally our model is ready we are trying to call a regression function on top of that that neural network that we have created and finally we will Define our model this DNN indicates a deep neural network that we are trying to create here right and inside that we're passing our you know neural network classifier that we have just now built after that we are trying to fit our model now here you can take you can see that here we are passing number of epochs again that is a number hyper parameter that you can change according to your own wish for example 10 20 30 uh there is a way to optimize that number of epo as well maybe by bya you know uh using uh uh different different kind of techniques are there where with the help of which you will just keep on checking that what is the loss and what is the accuracy that you have and at one point of time when you feel that the accuracy is high and after increasing the number of epochs it is going down so at that point of time you will completely stop that so there's a complete different technique for that that maybe I'll show you in the future videos but as of now this is something that we have where we are man manually writing the number of epox and you can see you can see that at each and every time your training has started now and you can see here that Epoch number three so at every epoke you will be able to get some loss and some accuracy right some loss some accuracy so this is the way uh where we will be able to train our model and it is done so you can see that here we will be able to get 80.7 as the accuracy and the loss is minimum now the model prediction now the last step is to predict our model where we are manually passing some values with respect to the Shivam and priia which is a list of the data data points that we have we will call the pre-processed function so that uh you know know it will be able to pre-process the data which we are passing here then we are simply calling the predict function where we are passing a list of the data points that we have and you can clearly see if I just run this you will be clearly able to see the surviving rate of Shivam and the surviving rate of priia so 82% chances are there to survive priia but 12.7% chances are there for the survival of Shiva basically in this way we will be you know able to get a training of a neural network classifier where basically we tried to create a in this particular video three layer neural network as you can clearly see now here these numbers you can you know keep on changing and try to see that at which particular number you will be able to get a higher accuracy and lower loss so ultimate Target of training the model is this only that we really want to have a higher accuracy and the lower loss value after that we will try to you know train our model and finally the predictions will be there and that is what we have seen here so in this way the complete implementation of I would say uh Titanic survival uh data set using tensor flow is done here again if you will see uh you know TF learn is something which is quite amazing library with the help of which we can directly call the functions I would highly recommend you guys to go and you know see the documentation of this particular Library uh because it's quite helpful it's quite user friendly and you can clearly see right we will be easily able to create a deep neural network uh model uh on top of the neural network classify that we have created so with this let's end this video uh I hope that you guys will be able to understand the implementation part of each and every step that I have explained here if you still have any sort of Doubt do let me know in the comment section I'll for sure try to resolve it as soon as possible with this happing to all bye-bye everyone and I'll see you all in my next upcoming videos
Original Description
Source Code:- https://www.geeksforgeeks.org/titanic-survival-prediction-using-tensorflow-in-python/
🔍Ever wondered if you could use machine learning to predict historical events? We're putting our skills to the test by creating a predictive model for the Titanic disaster. By leveraging TensorFlow, we'll walk you through each step of the process, from data collection to model training, and finally, making predictions.
👍 Don't forget to like this video, subscribe to our channel for more exciting projects, and hit the notification bell to stay updated on our latest content. Share your thoughts, questions, or suggestions in the comments below — we love hearing from our community of fellow machine-learning enthusiasts!
📈 Want to learn more about Machine Learning & Data Science?
Check out our Complete Machine Learning & Data Science Program: https://practice.geeksforgeeks.org/courses/data-science-live?utm_source=youtube&utm_medium=main_channel&utm_campaign=ml_ projects
Explore Premium LIVE and Online Courses :
https://practice.geeksforgeeks.org/courses/
Follow us for more fun, knowledge and resources:
📱 Download GeeksforGeeks' Official App: https://geeksforgeeksapp.page.link/gfg-app
💬 Twitter- https://twitter.com/geeksforgeeks
🧑💼 LinkedIn- https://www.linkedin.com/company/geeksforgeeks
📷 Instagram- https://www.instagram.com/geeks_for_geeks/?hl=en
💌 Telegram- https://t.me/s/geeksforgeeks_official
Also, Subscribe if you haven't already! :)
#GeeksforGeeks #machinelearningprojects #titanicsurvivalprediction #tensorflow #tensorflowprojects
#machinelearningprojectsgfg #gfg
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from GeeksforGeeks · GeeksforGeeks · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How I got into Walmart | Shailesh Sharma
GeeksforGeeks
Upgrade yourself In 29 Days | GeeksforGeeks
GeeksforGeeks
Learn AWS Fundamentals For Free
GeeksforGeeks
Conversation With Young Achievers | Meet the winners of Bi-Wizard Coding Contest | GeeksforGeeks
GeeksforGeeks
Meet The Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
Interview Prep Strategies | PayPal
GeeksforGeeks
OLX Interview Preparation Strategies | Hukam Singh
GeeksforGeeks
Meet Some More Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Microsoft Azure For Absolute Beginners
GeeksforGeeks
Python for Data Science | Data Science Master Bootcamp | Arpit Jain
GeeksforGeeks
Getting Started with Data Analysis | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
How to prepare theory subjects for SDE interviews | Geeks Summer Carnival 2022
GeeksforGeeks
Get Your Tickets To The Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
TED Talk Data Analysis Project | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
How I Secured AIR 9 in GATE'22 | Tushar
GeeksforGeeks
Learn Java Backend Development | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
Learn Data Structures and Algorithms | GeeksforGeeks
GeeksforGeeks
Interview experience at Flipkart | GeeksforGeeks
GeeksforGeeks
Lets Prepare for GATE'23 the Right Way | Sakshi Singhal | GeekSummerCarnival
GeeksforGeeks
Highest Paying Jobs in 2022 | Ishan Sharma | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival 2022 | 5th April- 11th April | GeeksforGeeks
GeeksforGeeks
Preparing for SDE interviews | Soham Mukherjee | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Full Stack Development with React & Node | Utkarsh Malik | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
Introduction to Open Source and Roadmap to GSOC 2022 | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Web Scraping in Action | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Getting Hired at BITCS via GfG Job Portal | Get Hired With GeeksforGeeks
GeeksforGeeks
How to build a faster landing Page | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival | 5th To 11th April, 2022 | GeeksforGeeks
GeeksforGeeks
How to get ideas for Startup | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Journey from Tier 3 to JusPay | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Dispelling Myths and Pre conceptions of Programming Languages
GeeksforGeeks
Must Do System Design Questions
GeeksforGeeks
Understanding Sorting Techniques in an hour | Keerti Purswani | Geeks Summer Carnival
GeeksforGeeks
Get Hired at NEC | Job-A-Thon 8
GeeksforGeeks
Journey from Tier 3 college to Microsoft | GeeksforGeeks
GeeksforGeeks
Get Hired with GeeksforGeeks at SuperK | Job A Thon 8
GeeksforGeeks
GeeksforGeeks: Redesigned
GeeksforGeeks
From Tier 3 to cracking multiple interviews | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Youtube Data Analysis | Ashish Jangra | GeeksforGeeks
GeeksforGeeks
DSA Self-Paced Course Preview | Sandeep Jain | GeeksforGeeks
GeeksforGeeks
GATE Live Classes | Prepare for GATE CS 2023 | GeeksforGeeks
GeeksforGeeks
Journey from JIIT to Adobe
GeeksforGeeks
Life Is Unfair Ft. Shonty badmash | LIVE Discord Session | A GeeksforGeeks Exclusive
GeeksforGeeks
Interview Experience at Google | Tech Dose
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Interview Experience @ Amazon | GeeksforGeeks
GeeksforGeeks
My journey through the tech world from India to US | Vidushi | GeeksforGeeks
GeeksforGeeks
Complete Interview Preparation Course | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Getting Hired at FiftyFive Technologies | Job-a-thon 9.0
GeeksforGeeks
GFG Karlo, Ho Jayega | GeeksforGeeks ft. Khaleel Ahmed
GeeksforGeeks
How I got job offers from 2 big companies : Arcesium & Microsoft | GeeksforGeeks
GeeksforGeeks
LINUX for Beginners | GFG x Itversity
GeeksforGeeks
My interview experience at Walmart | GeeksforGeeks
GeeksforGeeks
Get Hired at Speckyfox
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
More on: ML Pipelines
View skill →
🎓
Tutor Explanation
DeepCamp AI