Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS R PROGRAMMING - Use thetitanic_traindata frame from the titanic library as the starting point for this project. library(titanic) # loads titanic_train data frame

THIS IS R PROGRAMMING - Use thetitanic_traindata frame from thetitaniclibrary as the starting point for this project.

library(titanic) # loads titanic_train data frame

library(caret)

library(tidyverse)

library(rpart)

# 3 significant digits

options(digits = 3)

# clean the data - `titanic_train` is loaded with the titanic package

titanic_clean <- titanic_train %>%

mutate(Survived = factor(Survived),

Embarked = factor(Embarked),

Age = ifelse(is.na(Age), median(Age, na.rm = TRUE), Age), # NA age to median age

FamilySize = SibSp + Parch + 1) %>% # count family members

select(Survived, Sex, Pclass, Age, Fare, SibSp, Parch, FamilySize, Embarked)

Splittitanic_cleaninto test and training sets - after running the setup code, it should have 891 rows and 9 variables.

Set the seed to 42, then use thecaretpackage to create a 20% data partition based on theSurvivedcolumn. Assign the 20% partition totest_setand the remaining 80% partition totrain_set.

How many observations are in the training set? _________

How many observations are in the test set? ___________

What proportion of individuals in the training set survived? ________

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

=+2. What are the two ways govemment can finance a budget deficit?

Answered: 1 week ago