FQ1.docx - FQ1 Shashaank 2020-10-12 abstract =...

This preview shows page 1 - 6 out of 30 pages.

The preview shows page 4 - 6 out of 30 pages.
FQ1Shashaank2020-10-12abstract =read.csv("iris_exams.csv")Data Screening:Accuracy:summary(abstract)##idSpeciesSepal.LengthSepal.Width##Length:300Length:300Min.:4.417Min.:1.796##Class :characterClass :character1st Qu.:5.2091stQu.:2.720##Mode:characterMode:characterMedian :5.844Median :2.992##Mean:5.857Mean:3.064##3rd Qu.:6.4483rdQu.:3.375##Max.:8.478Max.:4.810##Petal.LengthPetal.Width##Min.:1.135Min.:-0.03371##1st Qu.:1.5661st Qu.: 0.30278##Median :4.228Median : 1.28776##Mean:3.738Mean: 1.19830##3rd Qu.:5.2053rd Qu.: 1.87452##Max.:6.955Max.: 2.62487abstract$Petal.Width[abstract$Petal.Width<1]=NA# We can see there are 105 NAs.summary(abstract)##idSpeciesSepal.LengthSepal.Width##Length:300Length:300Min.:4.417Min.:1.796##Class :characterClass :character1st Qu.:5.2091stQu.:2.720##Mode:characterMode:characterMedian :5.844
Median :2.992##Mean:5.857Mean:3.064##3rd Qu.:6.4483rdQu.:3.375##Max.:8.478Max.:4.810####Petal.LengthPetal.Width##Min.:1.135Min.:1.004##1st Qu.:1.5661st Qu.:1.305##Median :4.228Median :1.719##Mean:3.738Mean:1.698##3rd Qu.:5.2053rd Qu.:2.052##Max.:6.955Max.:2.625##NA's:105# Above Summary() function indicates that we do have NA's but noother major issue to fix. We will check for missing and outliersas we examine the data further.Missing:missing_data_perc =function(x){sum(is.na(x))/length(x)*100}missing_data_perc(abstract$Petal.Length)## [1] 0missing_data_perc(abstract$Petal.Width)## [1] 35missing_data_perc(abstract$Sepal.Length)## [1] 0missing_data_perc(abstract$Sepal.Width)## [1] 0# We can see 35% missing data in Petal.Width# Since the missing data is more than 5%, there will be accuracyerrors.apply(abstract,1,missing_data_perc)##[1] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[9] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[17] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667
##[25] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[33] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[41] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[49] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[57] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[65] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[73] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[81] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[89] 16.66667 16.66667 16.66667 16.66667 16.66667 16.6666716.66667 16.66667##[97] 16.66667 16.66667 16.66667 16.666670.000000.000000.000000.00000## [105]0.000000.000000.000000.000000.000000.000000.000000.00000## [113]0.000000.000000.000000.000000.000000.000000.000000.00000## [121]0.000000.000000.000000.000000.000000.000000.000000.00000## [129] 16.666670.000000.000000.000000.000000.000000.000000.00000## [137]0.000000.000000.00000 16.666670.000000.000000.000000.00000## [145]0.000000.000000.000000.000000.000000.000000.000000.00000## [153]0.000000.000000.000000.000000.000000.000000.000000.00000## [161]0.000000.000000.000000.000000.000000.000000.000000.00000## [169]0.000000.000000.000000.000000.000000.000000.000000.00000## [177]0.000000.000000.000000.00000 16.666670.000000.000000.00000## [185]0.00000 16.666670.00000 16.666670.000000.000000.000000.00000## [193]0.000000.000000.000000.000000.000000.000000.000000.00000## [201]0.000000.000000.000000.000000.000000.000000.000000.00000## [209]0.000000.000000.000000.000000.000000.000000.000000.00000## [217]0.000000.000000.000000.000000.000000.000000.000000.00000
## [225]0.000000.000000.000000.000000.000000.000000.000000.00000## [233]0.000000.000000.000000.000000.000000.000000.000000.00000## [241]0.000000.000000.000000.000000.000000.000000.000000.00000## [249]0.000000.000000.000000.000000.000000.000000.000000.00000## [257]0.000000.000000.000000.000000.000000.000000.000000.00000## [265]0.000000.000000.000000.000000.000000.000000.000000.00000## [273]0.000000.000000.000000.000000.000000.000000.000000.00000## [281]0.000000.000000.000000.000000.000000.000000.000000.00000## [289]0.000000.000000.000000.000000.000000.000000.000000.00000## [297]0.000000.000000.000000.00000missing_data =apply(abstract,1,missing_data_perc)table(missing_data)## missing_data##0 16.6666666666667##195105replace_missing_data =subset(abstract, missing_data<=20)missing_data1 =apply(replace_missing_data,1,missing_data_perc)table(missing_data1)## missing_data1##0 16.6666666666667##195105apply(abstract,2,missing_data_perc)##idSpecies Sepal.LengthSepal.WidthPetal.LengthPetal.Width##0000035replace_missing_column =replace_missing_data[,-c(2,1)]wd_replace_column =replace_missing_data[c(1,2)]replace_missing_column##Sepal.Length Sepal.Width Petal.Length Petal.Width## 14.7465103.3015321.441511NA## 25.0720223.6781331.208144NA## 35.2410443.4420491.585426NA## 45.4753113.9602151.533434NA
## 54.9004812.8064501.486378NA## 65.5806213.8577341.875316NA## 74.8509863.1724041.339713NA## 85.6601323.7038581.494393NA## 94.7295803.0578811.135306NA## 105.2193833.5465901.482494NA## 115.8435814.8100041.707506NA## 125.1760613.9367421.482811NA## 135.7462843.9509911.708016NA## 145.0358693.7120731.549868NA## 155.2034123.7059531.641574NA## 165.0572463.6584781.449732NA## 175.6557434.4892461.551453NA## 184.7440743.3081121.430194NA## 195.2524264.0649701.567033NA## 204.8763253.2702431.452477NA## 214.5776772.7672311.394993NA## 225.0918583.7313681.451007NA## 234.5024843.5396011.524054NA## 245.2309623.4599941.475177NA## 255.4431493.4804591.544585NA## 265.1744383.3414271.346401NA## 275.5714703.8166301.635982NA## 284.8429993.3420541.443339NA## 295.1534643.6022621.530769NA## 305.0840693.5355561.552879NA## 314.8049093.0068271.614557NA## 324.5173533.1837031.159255NA## 335.1584313.3370791.395731NA## 345.0523583.8177761.390738NA## 354.9465743.3689351.345880NA## 365.0008053.8396061.396330NA## 375.0095223.0813671.407579NA## 385.1891873.4175041.393419NA## 395.2402384.0549231.550640NA

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 30 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
N/A
Tags
Na Na Hey Hey Kiss Him Goodbye

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture