About Data Analysis Report

This RMarkdown file contains the report of the data analysis done for the project on building and deploying a stroke prediction model in R. It contains analysis such as data exploration, summary statistics and building the prediction models. The final report was completed on Sat Jul 6 05:11:33 2024.

Data Description:

According to the World Health Organization (WHO) stroke is the 2nd leading cause of death globally, responsible for approximately 11% of total deaths.

This data set is used to predict whether a patient is likely to get stroke based on the input parameters like gender, age, various diseases, and smoking status. Each row in the data provides relevant information about the patient.

Task One: Import data and data preprocessing

Load data and install packages

Describe and explore the data

Task Two: Build prediction models

Task Three: Evaluate and select prediction models

Task Four: Deploy the prediction model

Task Five: Findings and Conclusions

install.packages(“caret”) install.packages(“caret”, dependencies=c(“Depends”, “Suggests”)) library(caret) # attach the iris dataset to the environment data(iris) # rename the dataset dataset <- iris # define the filename filename <- “iris.csv” # load the CSV file from the local directory dataset <- read.csv(filename, header=FALSE) # set the column names in the dataset colnames(dataset) <- c(“Sepal.Length”,“Sepal.Width”,“Petal.Length”,“Petal.Width”,“Species”) # create a list of 80% of the rows in the original dataset we can use for training validation_index <- createDataPartition(dataset$Species, p=0.80, list=FALSE) # select 20% of the data for validation validation <- dataset[-validation_index,] # use the remaining 80% of data to training and testing the models dataset <- dataset[validation_index,]

dimensions of dataset

dim(dataset) [1] 120 5 # list types for each attribute sapply(dataset, class) Sepal.Length Sepal.Width Petal.Length Petal.Width Species “numeric” “numeric” “numeric” “numeric” “factor” Sepal.Length Sepal.Width Petal.Length Petal.Width Species “numeric” “numeric” “numeric” “numeric” “factor” Sepal.Length Sepal.Width Petal.Length Petal.Width Species “numeric” “numeric” “numeric” “numeric” “factor” Sepal.Length Sepal.Width Petal.Length Petal.Width Species “numeric” “numeric” “numeric” “numeric” “factor” # take a peek at the first 5 rows of the data head(dataset) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa 7 4.6 3.4 1.4 0.3 setosa # list the levels for the class levels(dataset\(Species) # list the levels for the class levels(dataset\)Species) [1] “setosa” “versicolor” “virginica” # summarize the class distribution percentage <- prop.table(table(dataset\(Species)) * 100 cbind(freq=table(dataset\)Species), percentage=percentage)