Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Import Data Execute the cell below to load the Titanic data from Seaborn and reduce it to the meaningful variables For this analysis, the survived
Import Data
Execute the cell below to load the Titanic data from Seaborn and reduce it to the meaningful variables
For this analysis, the survived variable will be used as the target variable, while the rest of the variables are the input features.
The goal is to predict whether a passenger survived survived or died survived the Titanic sinking
In a Markdown cell, identify the categorical and numerical features
Examine the possible values each feature can assume
Hint: survived is the Target. There will be four of each type.
Partition Data into Training and Testing sets
Stratify on the target variable to maintain the imbalance in the data sets
Extract for testing
Print the dimensions of the Training and Testing Data sets
Hint: Split into two DataFrames with the target present:
The output should be dftrain, dftest
Using the Training Data, calculate the following:
Calculate and show
The probability of each target label
Calculate and show for each of the categorical features in the Training Data
identify and show the means and standard deviations of the Continuous features
The probability of observing any value is assumed to the Normal Distribution:
given the target label
where and are calculated from each feature and target label
Construct a prediction function
This data set is of mixed types Categorical and Continuous so builtin functionality cannot work.
Recall, you are calculating:
argmax in argmax in
Where ykDied and ykSurvived
Your function should calculate the above expression for k and k and return both predictions for each instance considered.
Using your function, calculate the predictions from the Training data
Then, calculate the confusion matrix and accuracy score
Using your function, calculate the predictions from the Test data
Then, calculate the confusion matrix and accuracy score
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started