0% found this document useful (0 votes)
0 views7 pages

YuvaIntern Week4 Final R Data Analyst Report

The final report details a four-week project analyzing Titanic passenger data using R, focusing on data cleaning, visualization, statistical analysis, and predictive modeling. Key findings indicate that passenger characteristics such as class and sex significantly influence survival rates, while age and fare provide additional insights. The project emphasizes the importance of a structured analytical approach in transforming raw data into actionable insights.

Uploaded by

seyedubuhari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views7 pages

YuvaIntern Week4 Final R Data Analyst Report

The final report details a four-week project analyzing Titanic passenger data using R, focusing on data cleaning, visualization, statistical analysis, and predictive modeling. Key findings indicate that passenger characteristics such as class and sex significantly influence survival rates, while age and fare provide additional insights. The project emphasizes the importance of a structured analytical approach in transforming raw data into actionable insights.

Uploaded by

seyedubuhari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

YuvaIntern – Virtual R Data Analyst Internship

Week 4 Final Report: Comprehensive Data Analysis Reporting and Presentation


Project: Titanic Passenger Survival Analysis and Prediction Using R

1. Executive Summary
This final report integrates the four-week Titanic passenger data-analysis project completed as part of the YuvaIntern
Virtual R Data Analyst Internship. The project follows a complete analytical workflow beginning with data cleaning,
continuing through visualization and statistical analysis, and ending with predictive modeling. The purpose is to
demonstrate how raw data can be transformed into reliable information and then communicated as actionable
insights.

2. Introduction
The Titanic dataset was selected because it contains numerical and categorical variables, missing values, and a binary
survival outcome. These characteristics make it suitable for practicing data preparation, exploratory analysis,
visualization, statistical testing, and classification modeling. The project uses R as the primary analytical tool.

3. Data Preparation
The first stage involved inspecting the dataset, standardizing variable names, checking missing values, removing
duplicate observations, treating missing Age values using the median, and treating missing Embarked values using the
mode. Categorical variables were converted into factors. Potential Fare outliers were identified using the IQR method,
and a normalized Fare variable was created. These steps improved consistency and prepared the dataset for further
analysis.

4. Exploratory and Visual Analysis


Visualizations were used to communicate survival patterns and distributions. Bar charts compared survival outcomes
across passenger classes and survival rates across sex and class. A histogram showed the age distribution, a box plot
compared fares between survival groups, and a scatter plot explored the relationship between age and fare. The
visual analysis suggested that survival outcomes differed noticeably across passenger class and sex.

5. Statistical Analysis
Statistical analysis included an independent samples t-test comparing age between survival groups, a chi-square test
examining the association between sex and survival, and correlation analysis among numerical variables. These
methods were selected to complement the visual findings with formal statistical evidence.

6. Predictive Modeling
A logistic regression model was developed to predict survival because the target outcome has two categories. The
model used passenger class, sex, age, family-related variables, fare, and embarkation port as predictors. The dataset
was divided into training and testing subsets using an 80:20 split, and five-fold cross-validation was used during model
training.
7. Model Evaluation
The final model was evaluated using a confusion matrix, classification performance measures, ROC analysis, and AUC.
These evaluation methods provide information about correct predictions, classification errors, and the model's ability
to distinguish between survival outcomes. The actual numerical results should be reported from the R console output
after the script is executed.

8. Key Findings and Business Implications


The combined analysis demonstrates that passenger characteristics contain useful information for explaining and
predicting survival outcomes in the Titanic dataset. Passenger class and sex show important differences in survival
rates, while age and fare provide additional numerical information. From a general data-analytics perspective, the
project demonstrates the value of combining descriptive statistics, visualization, inferential analysis, and predictive
modeling rather than relying on a single technique.

9. Challenges Encountered
Important challenges included handling missing values, deciding how to treat potential outliers without removing
legitimate observations, selecting suitable visualizations, and ensuring that predictive performance was evaluated on
data not used directly for model fitting. Another challenge was balancing model interpretability with predictive
performance.

10. Recommendations
Future analysis could compare logistic regression with decision trees, random forests, or other classification
algorithms. Feature engineering could be used to create additional meaningful variables, such as family size or title
categories. Hyperparameter tuning, repeated cross-validation, and testing on an external dataset could provide a
stronger assessment of model generalization.

11. Conclusion
The four-week project demonstrates a complete R-based data-analysis workflow. Data cleaning created an analysis-
ready dataset, visualization communicated patterns clearly, statistical tests added formal evidence, and logistic
regression provided a predictive component. The final project highlights the importance of a structured, data-driven
approach in turning raw information into interpretable findings. The workflow can be adapted to many business and
analytical problems involving data quality, visualization, statistical inference, and prediction.

12. Final R Code


# YuvaIntern - Virtual R Data Analyst Internship

# Week 4: Comprehensive Data Analysis Reporting and Presentation

# Project: Titanic Passenger Survival Analysis and Prediction Using R

library(tidyverse)

library(caret)
library(pROC)

library(janitor)

[Link](123)

# 1. Load and prepare the Titanic dataset

url <- "[Link]

titanic <- [Link](url, stringsAsFactors = FALSE) %>%

clean_names()

titanic$age[[Link](titanic$age)] <- median(titanic$age, [Link] = TRUE)

get_mode <- function(x) {

ux <- unique(x[![Link](x) & x != ""])

ux[[Link](tabulate(match(x, ux)))]

titanic$embarked[[Link](titanic$embarked) | titanic$embarked == ""] <-

get_mode(titanic$embarked)

titanic$survived_label <- factor(

titanic$survived,

levels = c(0, 1),

labels = c("Did not survive", "Survived")

# 2. Key summary results

survival_summary <- titanic %>%

group_by(survived_label) %>%

summarise(

passengers = n(),

average_age = mean(age),

average_fare = mean(fare),

.groups = "drop"
)

print(survival_summary)

class_summary <- titanic %>%

group_by(pclass) %>%

summarise(

survival_rate = mean(survived),

passengers = n(),

.groups = "drop"

print(class_summary)

sex_summary <- titanic %>%

group_by(sex) %>%

summarise(

survival_rate = mean(survived),

passengers = n(),

.groups = "drop"

print(sex_summary)

# 3. Final visualization: survival rate by class and sex

final_plot <- titanic %>%

group_by(pclass, sex) %>%

summarise(survival_rate = mean(survived), .groups = "drop") %>%

ggplot(aes(x = pclass, y = survival_rate, fill = sex)) +

geom_col(position = "dodge") +

scale_y_continuous(labels = scales::percent) +

labs(

title = "Titanic Survival Rate by Passenger Class and Sex",

x = "Passenger Class",

y = "Survival Rate",

fill = "Sex"
) +

theme_minimal()

print(final_plot)

ggsave("final_survival_rate_chart.png", final_plot,

width = 8, height = 5, dpi = 300)

# 4. Final predictive model

model_data <- titanic %>%

select(survived, pclass, sex, age, sib_sp, parch, fare, embarked) %>%

mutate(

survived = factor(survived, levels = c(0, 1),

labels = c("No", "Yes")),

pclass = factor(pclass),

sex = factor(sex),

embarked = factor(embarked)

train_index <- createDataPartition(model_data$survived,

p = 0.80, list = FALSE)

train_data <- model_data[train_index, ]

test_data <- model_data[-train_index, ]

ctrl <- trainControl(

method = "cv",

number = 5,

classProbs = TRUE,

savePredictions = "final"

final_model <- train(

survived ~ pclass + sex + age + sib_sp + parch + fare + embarked,

data = train_data,
method = "glm",

family = binomial,

trControl = ctrl

print(final_model)

pred_class <- predict(final_model, newdata = test_data)

pred_prob <- predict(final_model, newdata = test_data, type = "prob")[, "Yes"]

final_cm <- confusionMatrix(

pred_class,

test_data$survived,

positive = "Yes"

print(final_cm)

roc_final <- roc(

response = test_data$survived,

predictor = pred_prob,

levels = c("No", "Yes"),

direction = "<"

print(auc(roc_final))

plot(roc_final, main = "Final ROC Curve - Titanic Survival Model")

# 5. Export final predictions

final_predictions <- test_data %>%

mutate(

predicted_survival = pred_class,

survival_probability = pred_prob

)
[Link](final_predictions,

"titanic_final_predictions.csv",

[Link] = FALSE)

# End of comprehensive analysis

13. Final Evidence Checklist


 Dataset structure and cleaning output.
 Key summary statistics.
 Final survival-rate visualization.
 Statistical test outputs.
 Logistic regression model summary.
 Confusion matrix and classification metrics.
 ROC curve and AUC.
 Final interpretation and recommendations.

You might also like