Project Overview

In this data analytics capstone project, I will navigate through the six stages of data analysis: Ask, Prepare, Process, Analyze, Share, and Act. I will start by selecting a dataset that aligns with the project’s objectives, considering factors such as relevance, accessibility, and personal interest. Through exploratory data analysis, I will delve into understanding the dataset’s structure, preparing it for analysis, and extracting meaningful insights. My aim is to develop practical skills in data analytics and offer actionable recommendations based on the insights uncovered during the analysis process.

Ask

Key tasks

  1. Identify the business task
  2. Determine key stakeholders
  3. Choose a dataset
  4. Establish metrics

Deliverables

A clear statement of the business task you have selected to investigate:

  • The objective is to analyze and distinguish the specific attributes that differentiate malignant from benign breast tumors.

Prepare

Key tasks

  1. Download data and store it appropriately.
  2. Identify how it’s organized.
  3. Sort and filter the data.
  4. Determine the credibility of the data.

Deliverables

A description of all data sources used:

  • I am using the Breast Cancer Wisconsin (Diagnostic) Data Set downloaded from Kaggle. This dataset’s features are computed from a digitized image of a fine needle aspirate (FNA) of a breast mass. It describes characteristics of the cell nuclei present in the image.

Process

Key tasks

  1. Check the data for errors.
  2. Choose your tools.
  3. Transform the data so you can work with it effectively.
  4. Document the cleaning process.

Deliverables

Documentation of any cleaning or manipulation of data:

# Load packages
install.packages("tidyverse")
install.packages("here")
install.packages("skimr")
install.packages("janitor")

library(tidyverse)
library(here)
library(skimr)
library(janitor)
# Import Data
breastCancer_df <- read_csv("BreastCancerData.csv")
# Remove extra column
breastCancer_df <- subset(breastCancer_df, select = -...33)
# Check summary of the data
skim_without_charts(breastCancer_df)
Data summary
Name breastCancer_df
Number of rows 568
Number of columns 32
_______________________
Column type frequency:
character 1
numeric 31
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
diagnosis 0 1 1 1 0 2 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100
id 0 1 30425139.67 125124311.81 8670.00 869222.50 906157.00 8825022.25 911320502.00
radius_mean 0 1 14.14 3.52 6.98 11.71 13.38 15.80 28.11
texture_mean 0 1 19.28 4.30 9.71 16.17 18.84 21.78 39.28
perimeter_mean 0 1 92.05 24.25 43.79 75.20 86.29 104.15 188.50
area_mean 0 1 655.72 351.66 143.50 420.30 551.40 784.15 2501.00
smoothness_mean 0 1 0.10 0.01 0.06 0.09 0.10 0.11 0.16
compactness_mean 0 1 0.10 0.05 0.02 0.07 0.09 0.13 0.35
concavity_mean 0 1 0.09 0.08 0.00 0.03 0.06 0.13 0.43
concave points_mean 0 1 0.05 0.04 0.00 0.02 0.03 0.07 0.20
symmetry_mean 0 1 0.18 0.03 0.11 0.16 0.18 0.20 0.30
fractal_dimension_mean 0 1 0.06 0.01 0.05 0.06 0.06 0.07 0.10
radius_se 0 1 0.41 0.28 0.11 0.23 0.32 0.48 2.87
texture_se 0 1 1.22 0.55 0.36 0.83 1.11 1.47 4.88
perimeter_se 0 1 2.87 2.02 0.76 1.61 2.29 3.36 21.98
area_se 0 1 40.37 45.52 6.80 17.85 24.57 45.24 542.20
smoothness_se 0 1 0.01 0.00 0.00 0.01 0.01 0.01 0.03
compactness_se 0 1 0.03 0.02 0.00 0.01 0.02 0.03 0.14
concavity_se 0 1 0.03 0.03 0.00 0.02 0.03 0.04 0.40
concave points_se 0 1 0.01 0.01 0.00 0.01 0.01 0.01 0.05
symmetry_se 0 1 0.02 0.01 0.01 0.02 0.02 0.02 0.08
fractal_dimension_se 0 1 0.00 0.00 0.00 0.00 0.00 0.00 0.03
radius_worst 0 1 16.28 4.83 7.93 13.02 14.97 18.79 36.04
texture_worst 0 1 25.67 6.15 12.02 21.08 25.41 29.68 49.54
perimeter_worst 0 1 107.35 33.57 50.41 84.15 97.66 125.53 251.20
area_worst 0 1 881.66 569.28 185.20 515.68 686.55 1085.00 4254.00
smoothness_worst 0 1 0.13 0.02 0.07 0.12 0.13 0.15 0.22
compactness_worst 0 1 0.25 0.16 0.03 0.15 0.21 0.34 1.06
concavity_worst 0 1 0.27 0.21 0.00 0.12 0.23 0.38 1.25
concave points_worst 0 1 0.11 0.07 0.00 0.06 0.10 0.16 0.29
symmetry_worst 0 1 0.29 0.06 0.16 0.25 0.28 0.32 0.66
fractal_dimension_worst 0 1 0.08 0.02 0.06 0.07 0.08 0.09 0.21
summary(breastCancer_df)
##        id             diagnosis          radius_mean      texture_mean  
##  Min.   :     8670   Length:568         Min.   : 6.981   Min.   : 9.71  
##  1st Qu.:   869222   Class :character   1st Qu.:11.707   1st Qu.:16.17  
##  Median :   906157   Mode  :character   Median :13.375   Median :18.84  
##  Mean   : 30425140                      Mean   :14.139   Mean   :19.28  
##  3rd Qu.:  8825022                      3rd Qu.:15.797   3rd Qu.:21.79  
##  Max.   :911320502                      Max.   :28.110   Max.   :39.28  
##  perimeter_mean     area_mean      smoothness_mean   compactness_mean 
##  Min.   : 43.79   Min.   : 143.5   Min.   :0.06251   Min.   :0.01938  
##  1st Qu.: 75.20   1st Qu.: 420.3   1st Qu.:0.08640   1st Qu.:0.06517  
##  Median : 86.29   Median : 551.4   Median :0.09589   Median :0.09312  
##  Mean   : 92.05   Mean   : 655.7   Mean   :0.09644   Mean   :0.10445  
##  3rd Qu.:104.15   3rd Qu.: 784.1   3rd Qu.:0.10533   3rd Qu.:0.13043  
##  Max.   :188.50   Max.   :2501.0   Max.   :0.16340   Max.   :0.34540  
##  concavity_mean    concave points_mean symmetry_mean    fractal_dimension_mean
##  Min.   :0.00000   Min.   :0.00000     Min.   :0.1060   Min.   :0.04996       
##  1st Qu.:0.02958   1st Qu.:0.02035     1st Qu.:0.1620   1st Qu.:0.05770       
##  Median :0.06155   Median :0.03360     Median :0.1792   Median :0.06155       
##  Mean   :0.08896   Mean   :0.04901     Mean   :0.1812   Mean   :0.06280       
##  3rd Qu.:0.13100   3rd Qu.:0.07401     3rd Qu.:0.1957   3rd Qu.:0.06613       
##  Max.   :0.42680   Max.   :0.20120     Max.   :0.3040   Max.   :0.09744       
##    radius_se        texture_se      perimeter_se       area_se       
##  Min.   :0.1115   Min.   :0.3602   Min.   : 0.757   Min.   :  6.802  
##  1st Qu.:0.2324   1st Qu.:0.8331   1st Qu.: 1.605   1st Qu.: 17.850  
##  Median :0.3240   Median :1.1080   Median : 2.285   Median : 24.565  
##  Mean   :0.4052   Mean   :1.2165   Mean   : 2.867   Mean   : 40.374  
##  3rd Qu.:0.4798   3rd Qu.:1.4743   3rd Qu.: 3.360   3rd Qu.: 45.237  
##  Max.   :2.8730   Max.   :4.8850   Max.   :21.980   Max.   :542.200  
##  smoothness_se      compactness_se      concavity_se     concave points_se 
##  Min.   :0.001713   Min.   :0.002252   Min.   :0.00000   Min.   :0.000000  
##  1st Qu.:0.005166   1st Qu.:0.013133   1st Qu.:0.01510   1st Qu.:0.007663  
##  Median :0.006374   Median :0.020460   Median :0.02592   Median :0.010950  
##  Mean   :0.007041   Mean   :0.025515   Mean   :0.03195   Mean   :0.011817  
##  3rd Qu.:0.008151   3rd Qu.:0.032455   3rd Qu.:0.04212   3rd Qu.:0.014730  
##  Max.   :0.031130   Max.   :0.135400   Max.   :0.39600   Max.   :0.052790  
##   symmetry_se       fractal_dimension_se  radius_worst   texture_worst  
##  Min.   :0.007882   Min.   :0.0008948    Min.   : 7.93   Min.   :12.02  
##  1st Qu.:0.015128   1st Qu.:0.0022445    1st Qu.:13.03   1st Qu.:21.07  
##  Median :0.018725   Median :0.0031955    Median :14.97   Median :25.41  
##  Mean   :0.020531   Mean   :0.0037967    Mean   :16.28   Mean   :25.67  
##  3rd Qu.:0.023398   3rd Qu.:0.0045585    3rd Qu.:18.80   3rd Qu.:29.68  
##  Max.   :0.078950   Max.   :0.0298400    Max.   :36.04   Max.   :49.54  
##  perimeter_worst    area_worst     smoothness_worst  compactness_worst
##  Min.   : 50.41   Min.   : 185.2   Min.   :0.07117   Min.   :0.02729  
##  1st Qu.: 84.15   1st Qu.: 515.7   1st Qu.:0.11660   1st Qu.:0.14758  
##  Median : 97.67   Median : 686.5   Median :0.13135   Median :0.21300  
##  Mean   :107.35   Mean   : 881.7   Mean   :0.13244   Mean   :0.25460  
##  3rd Qu.:125.53   3rd Qu.:1085.0   3rd Qu.:0.14602   3rd Qu.:0.33930  
##  Max.   :251.20   Max.   :4254.0   Max.   :0.22260   Max.   :1.05800  
##  concavity_worst  concave points_worst symmetry_worst   fractal_dimension_worst
##  Min.   :0.0000   Min.   :0.00000      Min.   :0.1565   Min.   :0.05504        
##  1st Qu.:0.1159   1st Qu.:0.06497      1st Qu.:0.2504   1st Qu.:0.07147        
##  Median :0.2275   Median :0.10002      Median :0.2821   Median :0.08005        
##  Mean   :0.2727   Mean   :0.11481      Mean   :0.2901   Mean   :0.08397        
##  3rd Qu.:0.3835   3rd Qu.:0.16168      3rd Qu.:0.3180   3rd Qu.:0.09208        
##  Max.   :1.2520   Max.   :0.29100      Max.   :0.6638   Max.   :0.20750
  • There are no missing values
  • Variables are standardized/normalized
  • No clear outliers or variants
# Check for duplicates
duplicated(breastCancer_df)
##   [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [49] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [61] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [73] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [85] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [97] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [109] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [121] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [133] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [145] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [157] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [169] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [181] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [193] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [205] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [217] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [229] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [241] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [253] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [265] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [277] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [289] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [301] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [313] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [325] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [337] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [349] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [361] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [373] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [385] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [397] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [409] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [421] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [433] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [445] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [457] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [469] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [481] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [493] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [505] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [517] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [529] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [541] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [553] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [565] FALSE FALSE FALSE FALSE
  • There are no duplicates

Analyze

Key tasks

  1. Aggregate your data so it’s useful and accessible.
  2. Organize and format your data.
  3. Perform calculations.
  4. Document your calculations to keep track of your analysis steps.
  5. Identify trends and relationships.
# Select columns for analysis
df_v2 = data.frame(diagnosis=breastCancer_df$diagnosis, radius_mean=breastCancer_df$radius_mean, 
                   texture_mean=breastCancer_df$texture_mean, perimeter_mean=breastCancer_df$perimeter_mean,
                   area_mean=breastCancer_df$area_mean, smoothness_mean=breastCancer_df$smoothness_mean, 
                   compactness_mean=breastCancer_df$compactness_mean, concavity_mean=breastCancer_df$concavity_mean, 
                   concave_points_mean=breastCancer_df$`concave points_mean`, symmetry_mean=breastCancer_df$symmetry_mean,fractal_dimension_mean=breastCancer_df$fractal_dimension_mean)
# Separate by diagnosis
malignant <- filter(df_v2, df_v2$diagnosis=='M')
summary(malignant)
##   diagnosis          radius_mean     texture_mean   perimeter_mean  
##  Length:212         Min.   :10.95   Min.   :10.38   Min.   : 71.90  
##  Class :character   1st Qu.:15.07   1st Qu.:19.33   1st Qu.: 98.75  
##  Mode  :character   Median :17.32   Median :21.46   Median :114.20  
##                     Mean   :17.46   Mean   :21.60   Mean   :115.37  
##                     3rd Qu.:19.59   3rd Qu.:23.77   3rd Qu.:129.93  
##                     Max.   :28.11   Max.   :39.28   Max.   :188.50  
##    area_mean      smoothness_mean   compactness_mean  concavity_mean   
##  Min.   : 361.6   Min.   :0.07371   Min.   :0.04605   Min.   :0.02398  
##  1st Qu.: 705.3   1st Qu.:0.09401   1st Qu.:0.10960   1st Qu.:0.10952  
##  Median : 932.0   Median :0.10220   Median :0.13235   Median :0.15135  
##  Mean   : 978.4   Mean   :0.10290   Mean   :0.14519   Mean   :0.16077  
##  3rd Qu.:1203.8   3rd Qu.:0.11092   3rd Qu.:0.17240   3rd Qu.:0.20305  
##  Max.   :2501.0   Max.   :0.14470   Max.   :0.34540   Max.   :0.42680  
##  concave_points_mean symmetry_mean    fractal_dimension_mean
##  Min.   :0.02031     Min.   :0.1308   Min.   :0.04996       
##  1st Qu.:0.06462     1st Qu.:0.1741   1st Qu.:0.05660       
##  Median :0.08628     Median :0.1899   Median :0.06157       
##  Mean   :0.08799     Mean   :0.1929   Mean   :0.06268       
##  3rd Qu.:0.10318     3rd Qu.:0.2099   3rd Qu.:0.06707       
##  Max.   :0.20120     Max.   :0.3040   Max.   :0.09744
benign <- filter(df_v2, df_v2$diagnosis=='B')
summary(benign)
##   diagnosis          radius_mean      texture_mean   perimeter_mean  
##  Length:356         Min.   : 6.981   Min.   : 9.71   Min.   : 43.79  
##  Class :character   1st Qu.:11.117   1st Qu.:15.14   1st Qu.: 70.91  
##  Mode  :character   Median :12.205   Median :17.38   Median : 78.22  
##                     Mean   :12.159   Mean   :17.90   Mean   : 78.16  
##                     3rd Qu.:13.373   3rd Qu.:19.74   3rd Qu.: 86.14  
##                     Max.   :17.850   Max.   :33.81   Max.   :114.60  
##    area_mean     smoothness_mean   compactness_mean  concavity_mean   
##  Min.   :143.5   Min.   :0.06251   Min.   :0.01938   Min.   :0.00000  
##  1st Qu.:378.4   1st Qu.:0.08310   1st Qu.:0.05576   1st Qu.:0.02041  
##  Median :458.6   Median :0.09082   Median :0.07536   Median :0.03710  
##  Mean   :463.6   Mean   :0.09259   Mean   :0.08019   Mean   :0.04619  
##  3rd Qu.:551.2   3rd Qu.:0.10070   3rd Qu.:0.09756   3rd Qu.:0.06003  
##  Max.   :992.1   Max.   :0.16340   Max.   :0.22390   Max.   :0.41080  
##  concave_points_mean symmetry_mean    fractal_dimension_mean
##  Min.   :0.00000     Min.   :0.1060   Min.   :0.05185       
##  1st Qu.:0.01503     1st Qu.:0.1580   1st Qu.:0.05853       
##  Median :0.02353     Median :0.1716   Median :0.06155       
##  Mean   :0.02579     Mean   :0.1742   Mean   :0.06288       
##  3rd Qu.:0.03254     3rd Qu.:0.1891   3rd Qu.:0.06577       
##  Max.   :0.08534     Max.   :0.2743   Max.   :0.09575
# Analyze tables
mal_sum <- data.frame(unclass(summary(malignant)), check.names = FALSE)
ben_sum <- data.frame(unclass(summary(benign)), check.names = FALSE)
mal_ben <-mal_sum %>% bind_rows(ben_sum)
mal_ben
##                   diagnosis      radius_mean    texture_mean   perimeter_mean
## X...1    Length:212          Min.   :10.95   Min.   :10.38   Min.   : 71.90  
## X.1...2  Class :character    1st Qu.:15.07   1st Qu.:19.33   1st Qu.: 98.75  
## X.2...3  Mode  :character    Median :17.32   Median :21.46   Median :114.20  
## X.3...4                <NA>  Mean   :17.46   Mean   :21.60   Mean   :115.37  
## X.4...5                <NA>  3rd Qu.:19.59   3rd Qu.:23.77   3rd Qu.:129.93  
## X.5...6                <NA>  Max.   :28.11   Max.   :39.28   Max.   :188.50  
## X...7    Length:356         Min.   : 6.981   Min.   : 9.71   Min.   : 43.79  
## X.1...8  Class :character   1st Qu.:11.117   1st Qu.:15.14   1st Qu.: 70.91  
## X.2...9  Mode  :character   Median :12.205   Median :17.38   Median : 78.22  
## X.3...10               <NA> Mean   :12.159   Mean   :17.90   Mean   : 78.16  
## X.4...11               <NA> 3rd Qu.:13.373   3rd Qu.:19.74   3rd Qu.: 86.14  
## X.5...12               <NA> Max.   :17.850   Max.   :33.81   Max.   :114.60  
##                 area_mean   smoothness_mean  compactness_mean    concavity_mean
## X...1    Min.   : 361.6   Min.   :0.07371   Min.   :0.04605   Min.   :0.02398  
## X.1...2  1st Qu.: 705.3   1st Qu.:0.09401   1st Qu.:0.10960   1st Qu.:0.10952  
## X.2...3  Median : 932.0   Median :0.10220   Median :0.13235   Median :0.15135  
## X.3...4  Mean   : 978.4   Mean   :0.10290   Mean   :0.14519   Mean   :0.16077  
## X.4...5  3rd Qu.:1203.8   3rd Qu.:0.11092   3rd Qu.:0.17240   3rd Qu.:0.20305  
## X.5...6  Max.   :2501.0   Max.   :0.14470   Max.   :0.34540   Max.   :0.42680  
## X...7     Min.   :143.5   Min.   :0.06251   Min.   :0.01938   Min.   :0.00000  
## X.1...8   1st Qu.:378.4   1st Qu.:0.08310   1st Qu.:0.05576   1st Qu.:0.02041  
## X.2...9   Median :458.6   Median :0.09082   Median :0.07536   Median :0.03710  
## X.3...10  Mean   :463.6   Mean   :0.09259   Mean   :0.08019   Mean   :0.04619  
## X.4...11  3rd Qu.:551.2   3rd Qu.:0.10070   3rd Qu.:0.09756   3rd Qu.:0.06003  
## X.5...12  Max.   :992.1   Max.   :0.16340   Max.   :0.22390   Max.   :0.41080  
##          concave_points_mean    symmetry_mean fractal_dimension_mean
## X...1      Min.   :0.02031   Min.   :0.1308        Min.   :0.04996  
## X.1...2    1st Qu.:0.06462   1st Qu.:0.1741        1st Qu.:0.05660  
## X.2...3    Median :0.08628   Median :0.1899        Median :0.06157  
## X.3...4    Mean   :0.08799   Mean   :0.1929        Mean   :0.06268  
## X.4...5    3rd Qu.:0.10318   3rd Qu.:0.2099        3rd Qu.:0.06707  
## X.5...6    Max.   :0.20120   Max.   :0.3040        Max.   :0.09744  
## X...7      Min.   :0.00000   Min.   :0.1060        Min.   :0.05185  
## X.1...8    1st Qu.:0.01503   1st Qu.:0.1580        1st Qu.:0.05853  
## X.2...9    Median :0.02353   Median :0.1716        Median :0.06155  
## X.3...10   Mean   :0.02579   Mean   :0.1742        Mean   :0.06288  
## X.4...11   3rd Qu.:0.03254   3rd Qu.:0.1891        3rd Qu.:0.06577  
## X.5...12   Max.   :0.08534   Max.   :0.2743        Max.   :0.09575
  • Malignant diagnosis are typically larger in all stats

  • Area_mean has a positive correlation

    • Min for M = 361.6, B = 143.5 ; >2.5X larger
    • Mean for M = 978.4, B = 463.6 ; >2.1X larger
  • Concavity_mean has a positive correlation

    • Mean for M = 0.16077, B = 0.04619 ; >3.4X larger
    • Min for M = 0.02398, B = 0
    • 3rd Qrt for M = 0.20305, B = 0.06003 ; >3.3X larger
  • ConcavePoints_mean has positive correlation

    • Mean for M = 0.08799, B = 0.02579 ; >3.4X larger
  • FractalDimension_mean is the only feature with no clear trend

Summary

  • Malignant diagnoses tend to exhibit larger values across various statistics compared to benign ones.

  • Specifically, for the Area_mean, malignant diagnoses have a notably higher minimum and mean values, being over 2.5 times larger than benign diagnoses.

  • Additionally, Concavity_mean and ConcavePoints_mean also show positive correlations, with malignant diagnoses having mean values over 3.4 times larger than benign diagnoses.

  • However, FractalDimension_mean does not exhibit a clear trend between malignant and benign diagnoses.

  • These findings suggest that certain features, such as Area_mean, Concavity_mean, and ConcavePoints_mean, may serve as potential indicators for distinguishing between malignant and benign diagnoses.

Statistical testing

t.test(radius_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  radius_mean by diagnosis
## t = -22.177, df = 288.79, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -5.774710 -4.833259
## sample estimates:
## mean in group B mean in group M 
##        12.15885        17.46283
  • The p-value obtained (< 2.2e-16) is extremely small, suggests that there is a statistically significant difference between benign and malignant diagnoses

  • The negative t-value (-22.177) indicates that malignant tumors tend to have smaller radii compared to benign tumors.

  • The 95% confidence interval for the difference in means (-5.774710, -4.833259) does not include zero, further supporting the conclusion that the difference in mean radius between benign and malignant diagnoses is significant.

  • Overall, based on these results, you can confidently conclude that the mean radius is significantly different between benign and malignant diagnoses, with malignant tumors having smaller mean radii compared to benign tumors.

t.test(texture_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  texture_mean by diagnosis
## t = -11.082, df = 462.42, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -4.366380 -3.051128
## sample estimates:
## mean in group B mean in group M 
##        17.89615        21.60491
  • The p-value obtained (< 2.2e-16) is extremely small, suggests that there is a significant difference in the mean area between benign and malignant diagnoses

  • The negative t-value (-11.082) indicates that malignant tumors tend to have lower mean textures compared to benign tumors.

  • The 95% confidence interval for the difference in means (-4.366380, -3.051128) does not include zero, further supporting the conclusion that the difference in mean texture between benign and malignant diagnoses is significant.

  • Overall, based on these results, you can confidently conclude that the mean texture is significantly different between benign and malignant diagnoses, with malignant tumors having lower mean textures compared to benign tumors.

t.test(area_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  area_mean by diagnosis
## t = -19.616, df = 244.56, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -566.4877 -463.1017
## sample estimates:
## mean in group B mean in group M 
##        463.5817        978.3764
  • The p-value obtained (< 2.2e-16) is extremely small, suggests that there is a significant difference in the mean area between benign and malignant diagnoses

  • Since the p-value is smaller than any conventional significance level (e.g., 0.05), we reject the null hypothesis,

t.test(perimeter_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  perimeter_mean by diagnosis
## t = -22.905, df = 284.44, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -40.40250 -34.00803
## sample estimates:
## mean in group B mean in group M 
##        78.16011       115.36538
  • The p-value obtained (< 2.2e-16) is extremely small, indicating strong evidence against the null hypothesis. This suggests that there is a statistically significant difference

  • The negative t-value (-22.905) indicates that the mean perimeter for malignant diagnoses is significantly lower than for benign diagnoses. This implies that malignant tumors tend to have smaller mean perimeters compared to benign tumors.

  • The 95% confidence interval for the difference in means (-40.40250, -34.00803) does not include zero, further supporting that the difference is significant.

  • Overall, based on these results, you can confidently conclude that the mean perimeter is significantly different between benign and malignant diagnoses, with malignant tumors having smaller mean perimeters compared to benign tumors.

t.test(smoothness_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  smoothness_mean by diagnosis
## t = -9.2334, df = 462.49, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -0.012502921 -0.008114903
## sample estimates:
## mean in group B mean in group M 
##      0.09258958      0.10289849
  • The p-value obtained (< 2.2e-16) is extremely small, indicating strong evidence against the null hypothesis. This suggests that there is a statistically significant difference

  • The negative t-value (-9.2334) indicates that the mean smoothness for malignant diagnoses is significantly lower than for benign diagnoses. This implies that malignant tumors tend to have lower mean smoothness compared to benign tumors.

  • The 95% confidence interval for the difference in means (-0.012502921, -0.008114903) does not include zero, further supporting that the difference is significant.

  • Overall, based on these results, you can confidently conclude that the mean smoothness is significantly different between benign and malignant diagnoses, with malignant tumors having lower mean smoothness compared to benign tumors.

t.test(compactness_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  compactness_mean by diagnosis
## t = -15.79, df = 310.59, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -0.07310069 -0.05690078
## sample estimates:
## mean in group B mean in group M 
##      0.08018705      0.14518778
  • The p-value obtained (< 2.2e-16) is extremely small, indicating strong evidence against the null hypothesis. This suggests that there is a statistically significant difference between benign and malignant diagnoses.

  • The negative t-value (-15.79) indicates that the mean compactness for malignant diagnoses is significantly lower than for benign diagnoses. This implies that malignant tumors tend to have lower mean compactness compared to benign tumors.

  • The 95% confidence interval for the difference in means (-0.07310069, -0.05690078) does not include zero, further supporting that the difference is significant.

  • Overall, based on these results, you can confidently conclude that the mean compactness is significantly different between benign and malignant diagnoses, with malignant tumors having lower mean compactness compared to benign tumors.

t.test(concavity_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  concavity_mean by diagnosis
## t = -20.305, df = 296.62, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -0.1256936 -0.1034819
## sample estimates:
## mean in group B mean in group M 
##       0.0461870       0.1607747
  • The p-value obtained (< 2.2e-16) is extremely small, indicating strong evidence against the null hypothesis. This suggests that there is a statistically significant difference between benign and malignant diagnoses.

  • The negative t-value (-20.305) indicates that the mean concavity for malignant diagnoses is significantly lower than for benign diagnoses. This implies that malignant tumors tend to have lower mean concavity compared to benign tumors.

  • The 95% confidence interval for the difference in means (-0.1256936, -0.1034819) does not include zero, further supporting that the difference is significant.

  • Overall, based on these results, you can confidently conclude that the mean concavity is significantly different between benign and malignant diagnoses, with malignant tumors having lower mean concavity compared to benign tumors.

t.test(symmetry_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  symmetry_mean by diagnosis
## t = -8.0874, df = 406.7, p-value = 7.075e-15
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -0.02321989 -0.01413904
## sample estimates:
## mean in group B mean in group M 
##       0.1742295       0.1929090
  • The p-value obtained (< 2.2e-16) is extremely small, suggests that there is a statistically significant difference in the mean area between benign and malignant diagnoses

  • The negative t-value (-8.0874) indicates that the mean symmetry for malignant diagnoses is significantly lower than for benign diagnoses. This implies that malignant tumors tend to have lower mean symmetry compared to benign tumors.

  • The 95% confidence interval for the difference in means (-0.02321989, -0.01413904) does not include zero, further supporting that the difference is significant.

  • Overall, based on these results, you can confidently conclude that the mean symmetry is significantly different between benign and malignant diagnoses, with malignant tumors having lower mean symmetry compared to benign tumors.

t.test(fractal_dimension_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  fractal_dimension_mean by diagnosis
## t = 0.31456, df = 404.27, p-value = 0.7533
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -0.001042612  0.001439839
## sample estimates:
## mean in group B mean in group M 
##      0.06287871      0.06268009
  • The p-value obtained (0.7533) is greater than a conventional significance level (e.g., 0.05). This suggests weak evidence against the null hypothesis. The difference in mean fractal dimension between benign and malignant diagnoses is not statistically significant.

  • Since the p-value is not less than the chosen significance level, we fail to reject the null hypothesis. This implies that there is insufficient evidence to conclude that there is a significant difference in mean fractal dimension between benign and malignant diagnoses.

  • The positive t-value (0.31456) suggests that the mean fractal dimension for malignant diagnoses is slightly higher than for benign diagnoses, but this difference is not statistically significant.

  • The 95% confidence interval for the difference in means (-0.001042612, 0.001439839) includes zero, indicating that the difference in mean fractal dimension between benign and malignant diagnoses is not statistically significant

  • Overall, based on these results, we cannot conclude that there is a significant difference in the mean fractal dimension between benign and malignant diagnoses. The difference observed could likely be due to random variation rather than a true difference between the two groups.

t.test(concave_points_mean~diagnosis, data=df_v2, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  concave_points_mean by diagnosis
## t = -24.818, df = 265.44, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group B and group M is not equal to 0
## 95 percent confidence interval:
##  -0.06713494 -0.05726577
## sample estimates:
## mean in group B mean in group M 
##      0.02578965      0.08799000
  • The p-value obtained (< 2.2e-16) is extremely small, suggests that there is a statistically significant difference in the mean area between benign and malignant diagnoses

  • The negative t-value (-24.818) indicates that the mean concave points for malignant diagnoses are significantly lower than for benign diagnoses. This implies that malignant tumors tend to have lower mean concave points compared to benign tumors.

  • The 95% confidence interval for the difference in means (-0.06713494, -0.05726577) does not include zero, further supporting that the difference is significant.

  • Overall, based on these results, you can confidently conclude that the mean concave points are significantly different between benign and malignant diagnoses, with malignant tumors having lower mean concave points compared to benign tumors.

Deliverables

A summary of your analysis:

  • Overall, most features exhibit statistically significant differences between benign and malignant diagnoses, indicating their potential importance in distinguishing between the two types of breast tumors. However, the fractal dimension mean did not show a significant difference between the two diagnoses.

Share

Key tasks

  • Determine the best way to share your findings.
  • Create effective data visualizations.
  • Present your findings.
  • Ensure your work is accessible.

Deliverables

Supporting visualizations and key findings:

radius_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=radius_mean, fill=diagnosis)) +
  ggtitle('Radius')
radius_mean_plot

  • Malignant plot is higher
  • Malignant median > benign upper whisker
  • Benign has more outliers above and below whiskers, Malignant only above
  • Malignant has more variability
  • Symmetrical distributions for both
texture_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=texture_mean, fill=diagnosis)) +
  ggtitle('Texture')
texture_mean_plot

  • Benign has may outliers above the whiskers
  • Malignant has many above, two below
  • Malignant plot is higher
  • Benign upper quartile around malignant lower quartile
  • Symmetrical distributions for both
area_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=area_mean, fill=diagnosis)) +
  ggtitle('Area')
area_mean_plot

  • Malignant is higher
  • Malignant has three outliers above the whisker
  • Benign has a few above the whisker
  • Benign upper whisker is below malignant median
  • Malignant has more variability
  • Symmetrical distributions for both
perimeter_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=perimeter_mean, fill=diagnosis)) +
  ggtitle('Perimeter')
perimeter_mean_plot

  • Malignant is higher, a few above the whisker, more variability
  • Benign upper whisker below malignant median, one upper outlier, a few below
  • Malignant positively skewed right
  • Benign upper whisker below malignant median
smoothness_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=smoothness_mean, fill=diagnosis)) +
  ggtitle('Smoothness')
smoothness_mean_plot

  • Symmetrical distributions for both
  • Benign has 3 upper outliers, malignant has a few too
  • Malignant is slightly higher
  • Benign upper quartile below malignant median
compactness_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=compactness_mean, fill=diagnosis)) +
  ggtitle('Compactness')
compactness_mean_plot

  • Both have a few upper outliers
  • Malignant is clearly higher than benign
  • Benign upper quartile below malignant lower quartile
concavity_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=concavity_mean, fill=diagnosis)) +
  ggtitle('Concavity')
concavity_mean_plot

  • Benign is skewed right, many upper outliers, clearly below malignant
  • Malignant has a few upper outliers, more variability
  • Malignant median > benign upper whisker
symmetry_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=symmetry_mean, fill=diagnosis)) +
  ggtitle('Symmetry')
symmetry_mean_plot

  • Both have symmetrical distribution
  • Benign has many upper outliers, one lower, Malignant has a few upper ones
  • Benign upper quartile around malignant median
fractal_dim_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=fractal_dimension_mean, fill=diagnosis)) +
  ggtitle('Fractal Dimension')
fractal_dim_mean_plot

  • Benign has A LOT of upper outliers, malignant has one upper one
  • Plots are level with median, malignant has more variability
concave_points_mean_plot <- ggplot(data = df_v2) + 
  geom_boxplot(mapping=aes(x=diagnosis, y=concave_points_mean, fill=diagnosis)) +
  ggtitle('Concave Points')
concave_points_mean_plot

  • Malignant is clearly above benign, lots of upper outliers on both
  • Symmetrical distribution for both
  • More variability for malignant
  • Benign upper whisker around malignant lower quartile
# Group visuals
install.packages('patchwork')
library(patchwork)
radius_mean_plot + texture_mean_plot + smoothness_mean_plot + area_mean_plot +
  perimeter_mean_plot + symmetry_mean_plot + compactness_mean_plot +
  concavity_mean_plot + concave_points_mean_plot + fractal_dim_mean_plot +
  plot_layout(guides = "collect") +
  plot_annotation(
        title = 'Malignant vs Benign Diagnosis',
        caption = 'Note: Only the fractal dimension mean does not show a significant difference',
        theme = theme(plot.title = element_text(hjust=.5, size = 25, lineheight = 20),
                plot.caption = element_text(size = 10, colour = 'red')))

Summary

  • Radius, Texture, Area, Perimeter, and Smoothness Mean:
    • Malignant tumors consistently displayed higher values compared to benign tumors in terms of radius, texture, area, perimeter, and smoothness mean.
    • Malignant distributions generally exhibited more variability, with a higher number of outliers above the upper whisker.
radius_mean_plot + texture_mean_plot + smoothness_mean_plot +
    plot_layout(guides = "collect")

  • Compactness and Concave Points Mean:
    • Features like compactness and concave points mean were significantly higher in malignant tumors compared to benign ones.
    • Benign distributions tended to have more upper outliers compared to malignant ones.
compactness_mean_plot + concave_points_mean_plot 

  • Concavity and Symmetry Mean:
    • Concavity mean showed a clear distinction between the distributions, with malignant tumors demonstrating higher variability and more upper outliers.
    • Symmetry mean distributions were generally symmetrical for both diagnoses, but benign tumors had more upper outliers.
concavity_mean_plot + symmetry_mean_plot

  • Fractal Dimension Mean:
    • Benign tumors exhibited numerous upper outliers for fractal dimension mean compared to malignant tumors.
    • Malignant tumors showed more variability, but the overall distribution was similar in shape to benign tumors.
fractal_dim_mean_plot

  • Overall, these findings suggest that several features, including radius, texture, area, perimeter, smoothness, compactness, concave points, concavity, and symmetry mean, can serve as potential markers for distinguishing between malignant and benign breast tumor diagnoses.

Act

Key tasks

  1. Create your portfolio.
  2. Add your case study.
  3. Practice presenting your case study to a friend or family member.

Deliverables

  • Your top high-level insights based on your analysis:

    • Distinctive Features: The analysis highlights several features that consistently exhibit significant differences between malignant and benign breast tumor diagnoses. These features include radius, texture, area, perimeter, smoothness, compactness, concave points, concavity, and symmetry mean.

    • Higher Values in Malignant Tumors: Malignant tumors tend to display higher values across most of these features compared to benign tumors, indicating potential markers for malignancy.

    • Variability and Outliers: Malignant distributions often show more variability and fewer outliers compared to benign distributions, suggesting a more uniform and characteristic pattern in malignant tumors.

    • Fractal Dimension Mean: Surprisingly, fractal dimension mean did not show a significant difference between malignant and benign tumors, indicating that this feature may not be as useful in distinguishing between the two diagnoses.

    • Potential Marker Identification: The findings suggest the potential for using these identified features as markers for distinguishing between malignant and benign breast tumor diagnoses, which could aid in early detection and treatment planning.

  • Based on what you discover, a list of additional deliverables you think would be helpful to include for further exploration:

    • Feature Importance Analysis: Conduct feature importance analysis to rank the identified features based on their contribution to the classification task. This will provide insights into which features are most informative for distinguishing between malignant and benign tumors.

    • Visualization Techniques: Utilize advanced visualization techniques such as heatmaps, scatter plots, or dimensionality reduction techniques (e.g., PCA) to visualize the relationships between features and diagnoses more comprehensively.

    • Validation and Generalization: Validate the findings and models on external datasets or through cross-validation to ensure their generalizability and robustness.

    • Further Statistical Analysis: Conduct additional statistical tests or analyses to explore potential interactions between features, subgroup differences, or other patterns in the data that may provide further insights into breast tumor diagnoses.