Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am really not sure what I am doing wrong but it is still saying this is incorrect. The dimensions and table look correct. 2.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedI am really not sure what I am doing wrong but it is still saying this is incorrect. The dimensions and table look correct.

2. (a) Data Cleaning Before we get to work, we need to clean up this data a bit. If you look over it, you will notice a fair number of columns, many missing values and some NA values. We're going to need to clean our data before we're able to do any modelling. When you're done, you will have a cleaned dataset titanic, your training set titanic.train and your test set titanic.test. Here's what needs to be done: - We have a lot of predictors, but we don't need them all. Restrict the data to on the and columns. - There's still missing data in our dataframe. That won't do. Remove any rows that have at least one missing value in any column. - If you look at the types of each column, you'll notice that some factors have been loaded as numeric. We should change that. Set Survived and Pclass to categorical. - We will eventually want to analyze how well our model performs. Split the data into training and test sets. Do this by putting every fifth row into the test set, and use the rest for training. For example, the first 4 rows will be in the training set, and the 5th row will be in the test set. Repeat that pattern for the rest of the data. titanic.train = titanic [seq(0, nrow (titanic),5), titanic.test = titanic [ seq (0, nrow(titanic), 5), ] \# your code here titanic=na.omit(titanic) titanic=subset(titanic, select=c(Survived, Pclass, Sex, Age, Fare)) titanic $ Survived=as.factor(titanic\$Survived) titanic $ Pclass=as.factor(titanic $ Pclass) summary(titanic) head(titanic) dim(titanic) dim(titanic.test) dim(titanic.train) head(titanic.train) A data.frame: 65 click to scroll output; double click to hide \begin{tabular}{rrrrrr} & Survived & Fare \\ \hline 1 & 0 & 3 & male & 22 & 7.2500 \\ 2 & 1 & 1 & female & 38 & 71.2833 \\ 3 & 1 & 3 & female & 26 & 7.9250 \\ 4 & 1 & 1 & female & 35 & 53.1000 \\ 7 & 0 & 1 & male & 54 & 51.8625 \\ 8 & 0 & 3 & male & 2 & 21.0750 \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago