library(caret)
## Loading required package: ggplot2
## Loading required package: lattice
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ tibble 3.1.8 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ✔ purrr 0.3.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::lift() masks caret::lift()
library(class)
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
library(mice)
##
## Attaching package: 'mice'
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## cbind, rbind
#library(MLmetrics)
library(mltools)
##
## Attaching package: 'mltools'
##
## The following object is masked from 'package:tidyr':
##
## replace_na
library(data.table)
##
## Attaching package: 'data.table'
##
## The following objects are masked from 'package:dplyr':
##
## between, first, last
##
## The following object is masked from 'package:purrr':
##
## transpose
Instructions: Let’s build a kNN model using the college completion data from last week. The data is messy and you have a degrees of freedom problem, as in, we have too many features.
You’ve done most of the hard work already, so you should be ready to move forward with building your model.
Use the question/target variable you submitted from last week and build a model to answer the question you created for this dataset.
Build and optimize a kNN model to predict your target variable. Meaning use the tune set to select the correct k value.
Experiment with the threshold function, what happens at higher and lower thresholds. Document what you see in comments.
Evaluate the results using the confusion matrix (at the default threshold). Then talk through your question, summarize what concerns or positive elements do you have about the model?
Bonus: Adjust the function that selects k to output on Specificity instead of Accuracy
table(college$level)
##
## 2-year 4-year
## 1459 2339
table(college$control)
##
## Private for-profit Private not-for-profit Public
## 992 1248 1558
keeps <- c("level", "control", "hbcu", "flagship", "student_count", "aid_value", "pell_value")
college <- college[keeps]
str(college)
## tibble [3,798 × 7] (S3: tbl_df/tbl/data.frame)
## $ level : Factor w/ 2 levels "2-year","4-year": 2 2 2 2 2 2 1 2 2 2 ...
## $ control : Factor w/ 3 levels "Private for-profit",..: 3 3 2 3 3 3 3 3 3 2 ...
## $ hbcu : num [1:3798] 1 0 0 0 1 0 0 0 0 0 ...
## $ flagship : num [1:3798] 0 0 0 0 0 1 0 0 0 0 ...
## $ student_count: num [1:3798] 4051 11502 322 5696 5356 ...
## $ aid_value : num [1:3798] 7142 6088 2540 6647 7256 ...
## $ pell_value : num [1:3798] 71.2 35.1 68.4 32.8 82.7 21.1 65.1 40.1 16.9 21.4 ...
sum(is.na(college$aid_value))
## [1] 1
college <- college[complete.cases(college$aid_value),]
sum(is.na(college$aid_value))
## [1] 0
# Let's look at min-max scaling, placing the numbers between 0 and 1.
###Build our own normalizer, which is maybe how I would go if given the option. If you need to do multiple columns use lapply. See this referred to as a min-max scaler function.
normalize <- function(x){
# x is a numeric vector because the functions min and max require
#numeric inputs
(x - min(x)) / (max(x) - min(x))#numerator subtracts the minimum value of x from the entire column, denominator essentially calculates the range of x
}
(aidvalue_n <- normalize(college$aid_value))
## [1] 0.16586736 0.14033813 0.05440101 0.15387783 0.16862859 0.24453810
## [7] 0.11536598 0.09768445 0.20784285 0.48662985 0.09741801 0.10783316
## [13] 0.11204767 0.11243521 0.10955288 0.15508889 0.11032796 0.11255631
## [19] 0.10950443 0.11282275 0.08445962 0.27014000 0.07486799 0.14520661
## [25] 0.09855641 0.08949765 0.10403042 0.47512474 0.09284019 0.10124497
## [31] 0.10967398 0.22598460 0.15513733 0.20425810 0.16506806 0.08320012
## [37] 0.10478128 0.11132103 0.15923073 0.10793005 0.09511699 0.09368793
## [43] 0.09124158 0.31407741 0.05050138 0.08070532 0.11795766 0.14426198
## [49] 0.44618030 0.12505450 0.17516834 0.38608729 0.07544930 0.12176040
## [55] 0.10894734 0.09693359 0.10986775 0.12161508 0.10642833 0.17473235
## [61] 0.07305140 0.06384731 0.10645255 0.08336967 0.09162912 0.07900983
## [67] 0.08131086 0.09439035 0.19883253 0.11732791 0.24432011 0.05624183
## [73] 0.08014823 0.09545609 0.09191978 0.10713075 0.25400862 0.07549775
## [79] 0.16526183 0.10780894 0.08191639 0.06123141 0.07099259 0.09858063
## [85] 0.10233493 0.14830693 0.10783316 0.16785351 0.06510682 0.07399603
## [91] 0.10257714 0.07942160 0.12796105 0.12612023 0.27982851 0.09419658
## [97] 0.05270552 0.07140435 0.07210677 0.44329797 0.08511360 0.11696459
## [103] 0.13159425 0.15319963 0.23368696 0.39219106 0.16574626 0.17572543
## [109] 0.09274330 0.18044858 0.14922734 0.14297825 0.10015502 0.18093300
## [115] 0.16715109 0.10659788 0.17964928 0.08600979 0.08746306 0.13762535
## [121] 0.21542411 0.17693649 0.63435547 0.31647532 0.09446301 0.09986436
## [127] 0.15138304 0.36959260 0.07876762 0.15692971 0.45996221 0.07629705
## [133] 0.22772853 0.08729351 0.09845953 0.07978491 0.09385748 0.10940755
## [139] 0.25202248 0.08918277 0.19578065 0.10352177 0.14210628 0.14968755
## [145] 0.09736957 0.04294434 0.05243908 0.16647290 0.09288863 0.05091314
## [151] 0.07402025 0.27597733 0.30724701 0.06425907 0.07099259 0.10652521
## [157] 0.56459817 0.12626556 0.13094027 0.08135930 0.05817953 0.28397035
## [163] 0.42166836 0.70290171 0.35290413 0.17451436 0.15242455 0.26146878
## [169] 0.21297776 0.21944485 0.20922347 0.21387395 0.20832728 0.21917841
## [175] 0.20156954 0.21179092 0.20551761 0.21234801 0.22150366 0.20939301
## [181] 0.37470329 0.36106671 0.38201812 0.38739524 0.38841254 0.38015308
## [187] 0.37683476 0.41188296 0.40263043 0.11071550 0.35987986 0.21108850
## [193] 0.04153950 0.06166739 0.08385409 0.06907911 0.05059827 0.05389236
## [199] 0.06050477 0.53444267 0.15814077 0.32284552 0.23342053 0.06329022
## [205] 0.06423485 0.86469990 0.03398246 0.21106428 0.11495422 0.05631449
## [211] 0.11975004 0.05566051 0.06418641 0.04364676 0.06144940 0.04846679
## [217] 0.05151867 0.05403769 0.05735600 0.07232476 0.10986775 0.05287507
## [223] 0.45141210 0.06062588 0.05587851 0.06639054 0.06738362 0.16257327
## [229] 0.16845904 0.17148670 0.07365693 0.04197549 0.06253936 0.39003536
## [235] 0.05641137 0.05859129 0.07457734 0.06086809 0.04919343 0.06316911
## [241] 0.62524827 0.12653200 0.11752168 0.11643172 0.10855980 0.11674660
## [247] 0.45284116 0.20476675 0.30237853 0.08748728 0.04713462 0.08516204
## [253] 0.10795427 0.11279853 0.37862714 0.05924526 0.13675338 0.13261154
## [259] 0.38880008 0.19655573 0.04696507 0.04909655 0.03865717 0.30995979
## [265] 0.57121058 0.07091992 0.06278157 0.06421063 0.05725912 0.05970547
## [271] 0.05541830 0.38439180 0.05570896 0.05757400 0.06028678 0.13476723
## [277] 0.43862326 0.07796832 0.08964298 0.08005135 0.08230393 0.08802015
## [283] 0.47805552 0.07181611 0.49401734 0.07636971 0.04606889 0.59284019
## [289] 0.04335610 0.06493727 0.06554280 0.05566051 0.05379548 0.06939398
## [295] 0.43663712 0.05457056 0.11844209 0.05941481 0.08516204 0.09284019
## [301] 0.13232088 0.10337645 0.18461464 0.37586591 0.68955578 0.05856707
## [307] 0.05343216 0.41377222 0.05704113 0.41866492 0.10185051 0.31780749
## [313] 0.50898610 0.03458800 0.04727995 0.06200649 0.78140290 0.79034055
## [319] 0.13018941 0.35493872 0.87484862 0.08441118 0.11306496 0.03933537
## [325] 0.54226614 0.09424502 0.05626605 0.04851524 0.04730417 0.05156712
## [331] 0.05592695 0.11459090 0.04144262 0.04149106 0.22649324 0.54589934
## [337] 0.17088117 0.47011093 0.20704355 0.51276462 0.06815870 0.10725185
## [343] 0.10347333 0.30603594 0.04427651 0.20171487 0.04514848 0.08530737
## [349] 0.07896139 0.07959114 0.06171584 0.45460931 0.05672625 0.05125224
## [355] 0.74742043 0.08685753 0.07065349 0.07542508 0.06602722 0.30034394
## [361] 0.07397181 0.05493388 0.06486460 0.52795136 0.05195466 0.20384634
## [367] 0.09845953 0.37206317 0.08346655 0.05716223 0.28200843 0.72445865
## [373] 0.06222448 0.31761372 0.09630383 0.12064622 0.09976748 0.09286441
## [379] 0.05842174 0.06721407 0.04219348 0.06530059 0.08688175 0.04824880
## [385] 0.05512765 0.08646999 0.45991377 0.55769510 0.35607712 0.37315313
## [391] 0.06932132 0.26793586 0.15210967 0.16119266 0.05866395 0.11396115
## [397] 0.14050768 0.11824832 0.07651504 0.21922686 0.19430315 0.68391222
## [403] 0.12435208 0.09933149 0.07418980 0.11652861 0.19892942 0.09526232
## [409] 0.17734825 0.10700964 0.17536211 0.16262171 0.10659788 0.13777067
## [415] 0.09225888 0.08322434 0.51383035 0.26047571 0.11304074 0.12192995
## [421] 0.05791309 0.09678826 0.11052173 0.40439859 0.06520370 0.05965703
## [427] 0.03456377 0.08918277 0.14246960 0.10800271 0.10432108 0.12437630
## [433] 0.17901952 0.17158359 0.09431769 0.30065882 0.21033764 0.13566342
## [439] 0.09812043 0.09489900 0.13367728 0.13648694 0.27469360 0.11088505
## [445] 0.10030034 0.40156470 0.11325873 0.79051010 0.23395340 0.13350773
## [451] 0.11975004 0.52950153 0.09066027 0.39444364 0.09208933 0.09596473
## [457] 0.10419997 0.10516882 0.34934360 0.10083321 0.38313230 0.09790244
## [463] 0.10572591 0.10451485 0.16695732 0.08489561 0.41767185 0.34493533
## [469] 0.36700092 0.08831081 0.07879184 0.13699559 0.94140871 0.08755995
## [475] 0.90481035 0.25417817 0.98801046 0.07247009 0.07123480 0.06740784
## [481] 0.17829288 0.32628494 0.24637892 0.25374219 0.05151867 0.53219009
## [487] 0.40219445 0.38235722 0.10516882 0.40248510 0.65743836 0.75480793
## [493] 0.37092477 0.09584363 0.12476384 0.42459914 0.11076394 0.18701255
## [499] 0.33127452 0.23383229 0.33330911 0.08327278 0.08327278 0.08797171
## [505] 0.11342828 0.15392627 0.11129681 0.10066366 0.10802693 0.21600543
## [511] 0.08068110 0.09213777 0.39526716 0.09775711 0.26333382 0.22177009
## [517] 0.16642445 0.11987114 0.07782299 0.16649712 0.18824783 0.08903745
## [523] 0.09601318 0.09952526 0.09145957 0.47057114 0.11166013 0.10589546
## [529] 0.12539360 0.11122414 0.38131570 0.10277092 0.08094754 0.23242746
## [535] 0.14130698 0.10562903 0.12122753 0.07971225 0.08935232 0.09114470
## [541] 0.08659110 0.11638328 0.12270503 0.09102359 0.39986921 0.24584605
## [547] 0.11505111 0.08387831 0.05059827 0.10599235 0.08077799 0.09136269
## [553] 0.08869835 0.60080899 0.08581602 0.09569830 0.10737296 0.10347333
## [559] 0.10972242 0.30838541 0.24240663 0.10700964 0.09712736 0.30809475
## [565] 0.05965703 0.08186795 0.08366032 0.10596812 0.27278012 0.49600349
## [571] 0.16216151 0.07465000 0.04694085 0.08443540 0.08993363 0.08712396
## [577] 0.08942499 0.14024124 0.34168968 0.62512716 0.22286005 0.16426876
## [583] 0.10298891 0.11173279 0.24524052 0.19408516 0.13588141 0.10286780
## [589] 0.42568910 0.31589401 0.07990602 0.12612023 0.09460834 0.58818970
## [595] 0.18410599 0.10148719 0.08598556 0.12289880 0.21096740 0.11507533
## [601] 0.11977426 0.11417914 0.40112871 0.09453568 0.20961101 0.10793005
## [607] 0.09022429 0.10751829 0.42859565 0.06903066 0.23855544 0.30245119
## [613] 0.02615899 0.09489900 0.09293707 0.13970838 0.10509616 0.09882285
## [619] 0.11488156 0.09611006 0.36254420 0.09940416 0.10790583 0.15656639
## [625] 0.25691518 0.72014727 0.09020007 0.11916873 0.19900208 0.11347672
## [631] 0.14251804 0.13992637 0.11863586 0.13808555 0.17904374 0.09143535
## [637] 0.10010657 0.05573318 0.08983675 0.08918277 0.10083321 0.40088650
## [643] 0.08654265 0.15029308 0.09659449 0.10163251 0.39902146 0.41878603
## [649] 0.09041806 0.09099937 0.50348787 0.15734147 0.27740638 0.23119217
## [655] 0.09390592 0.29843046 0.13035896 0.31439229 0.11117570 0.32025384
## [661] 0.11546287 0.09608584 0.11873274 0.28101536 0.25398440 0.10482972
## [667] 0.11819987 0.32182822 0.11388849 0.43295548 0.14116165 0.25296711
## [673] 0.16015114 0.17117183 0.16228261 0.09126580 0.08484716 0.09351838
## [679] 0.08758417 0.08722085 0.10165674 0.09821731 0.08470184 0.14789517
## [685] 0.09279175 0.07295451 0.11497844 0.17565276 0.53587172 0.10931066
## [691] 0.09431769 0.14087100 0.33100809 0.12754929 0.13219978 0.14116165
## [697] 0.28813641 0.47585138 0.26984934 0.11388849 0.11369471 0.19674950
## [703] 0.32444412 0.13777067 0.16082934 0.73167660 0.09884707 0.09087826
## [709] 0.09162912 0.08477450 0.08659110 0.09669137 0.08164995 0.19708860
## [715] 0.34340939 0.11977426 0.06326600 0.06622100 0.36423969 0.11098193
## [721] 0.08666376 0.16642445 0.06597878 0.57048394 0.34263431 0.14121010
## [727] 0.30845807 0.12425520 0.13639006 0.10703386 0.28423679 0.27433028
## [733] 0.26054837 0.43232573 0.07724168 0.42835344 0.06774694 0.58770528
## [739] 0.08540425 0.08777794 0.08547692 0.12059778 0.06113453 0.09957371
## [745] 0.07884028 0.32713268 0.11921717 0.16669089 0.13147314 0.12301991
## [751] 0.49881316 0.07075038 0.60839025 0.06190961 0.07888873 0.28694957
## [757] 0.15734147 0.23097418 0.10996464 0.10260137 0.40028097 0.08634888
## [763] 0.11827254 0.29075231 0.08499249 0.31165528 0.20580826 0.09904084
## [769] 0.43150220 0.49752943 0.16826527 0.11284697 0.13130359 0.12512716
## [775] 0.17141404 0.37458218 0.23797413 0.18037591 0.09654604 0.70643802
## [781] 0.13348351 0.06866734 0.39018069 0.09642494 0.11471201 0.43019425
## [787] 0.08787482 0.12515138 0.12331057 0.06961198 0.31230926 0.10887468
## [793] 0.02586833 0.28503609 0.28070048 0.26699123 0.31243036 0.35573802
## [799] 0.16012692 0.07719324 0.05137335 0.31448917 0.16250061 0.04858790
## [805] 0.08838347 0.20595359 0.14060456 0.15637262 0.02945308 0.23732016
## [811] 0.32800465 0.08552536 0.24674224 0.06619677 0.16366323 0.39088311
## [817] 0.10565325 0.18398489 0.33471395 0.19943807 0.27963474 0.42595553
## [823] 0.17996415 0.03914160 0.57489222 0.72186698 0.50549823 0.38548176
## [829] 0.38318074 0.33454440 0.49762631 0.49869205 0.31519159 0.09625539
## [835] 0.12541782 0.17863198 0.13823088 0.28508453 0.20992588 0.21980817
## [841] 0.17252822 0.11003730 0.13215133 0.24383568 0.14019280 0.12658044
## [847] 0.12142131 0.10761517 0.12098532 0.08588868 0.09448724 0.06944243
## [853] 0.09603740 0.10090588 0.09642494 0.45150899 0.39371700 0.19965606
## [859] 0.27304655 0.09267064 0.71353485 0.33716030 0.12401298 0.11655283
## [865] 0.45436710 0.27684930 0.50201037 0.28840285 0.42157148 0.07806520
## [871] 0.31543380 0.41074456 0.48430461 0.23584266 0.48118006 0.15116504
## [877] 0.18534128 0.35704597 0.27537180 0.44257133 0.32061716 0.53863295
## [883] 0.56232137 0.07062927 0.42883786 0.25691518 0.37077944 0.58673642
## [889] 0.18645546 0.18228940 0.08763261 0.18376689 0.36467568 0.23291188
## [895] 0.72770431 0.13912706 0.13377416 0.09509277 0.08029356 0.07980914
## [901] 0.08554958 0.09659449 0.15152836 0.53463644 0.09049072 0.18362157
## [907] 0.10659788 0.38957516 0.50506225 0.41675144 0.17473235 0.13794022
## [913] 0.34636439 0.26224386 0.09858063 0.06457395 0.12134864 0.39030180
## [919] 0.10180206 0.08724507 0.30509131 0.06593034 0.41648501 0.08026934
## [925] 0.09080560 0.13815821 0.20927191 0.49740832 0.08014823 0.31107397
## [931] 0.04667442 0.27641331 0.06014145 0.30899094 0.34927094 0.32490433
## [937] 0.09417236 0.10390932 0.08419319 0.09654604 0.15111660 0.06992685
## [943] 0.11856319 0.10650099 0.14617546 0.06469505 0.09732113 0.11601996
## [949] 0.08135930 0.09971903 0.13391949 0.24465921 0.08988519 0.07380226
## [955] 0.13096449 0.32359638 0.08155307 0.09606162 0.06319333 0.07196144
## [961] 0.09947682 0.15416848 0.14774984 0.31976941 0.11345250 0.31008090
## [967] 0.06854624 0.08312745 0.15341762 0.31121930 0.26522308 0.07472267
## [973] 0.09063605 0.11396115 0.41944000 0.09790244 0.08465339 0.27542024
## [979] 0.09763600 0.12091266 0.23269389 0.28271085 0.30916049 0.12166352
## [985] 0.06355665 0.10594390 0.19459381 0.30283873 0.14847648 0.52942886
## [991] 0.64142809 0.15533110 0.24482876 0.47665068 0.15249721 0.51070581
## [997] 0.12142131 0.07477111 0.33531948 0.14263915 0.14474640 0.54633532
## [1003] 0.14368067 0.14491595 0.13936928 0.09858063 0.13801289 0.12251126
## [1009] 0.16201618 0.33144407 0.17308531 0.23790147 0.35670687 0.08591290
## [1015] 0.18849005 0.14271182 0.16916146 0.36499055 0.16448675 0.16531027
## [1021] 0.16981543 0.17776002 0.13890907 0.09080560 0.11141791 0.37470329
## [1027] 0.10606501 0.09003052 0.41897980 0.08547692 0.16678777 0.09749067
## [1033] 0.40158892 0.09766022 0.10623456 0.46311098 0.46148816 0.33025723
## [1039] 0.13995059 0.06094075 0.02245313 0.09838686 0.15874631 0.61778811
## [1045] 0.11258054 0.13001986 0.45761275 0.09986436 0.32633338 0.09654604
## [1051] 0.10359444 0.19343119 0.08937654 0.14108899 0.06922443 0.21520612
## [1057] 0.15625151 0.65261832 0.12243860 0.14406821 0.13532432 0.16717531
## [1063] 0.09506855 0.15380516 0.10865669 0.25219203 0.10763939 0.07268808
## [1069] 0.08448384 0.07886451 0.14062878 0.12699220 0.07205832 0.08884368
## [1075] 0.13411326 0.04362254 0.56084387 0.27292545 0.07704791 0.11681926
## [1081] 0.68197452 0.85423630 0.05822797 0.81148573 0.02155694 0.10017924
## [1087] 0.81812237 0.09925883 0.36763067 0.08748728 0.11098193 0.13903018
## [1093] 0.11601996 0.18715787 0.17773579 0.14801628 0.13437969 0.40449547
## [1099] 0.11027951 0.33311534 0.30746500 0.14709587 0.12214794 0.30903938
## [1105] 0.25882866 0.16201618 0.07954270 0.06152207 0.08150463 0.08269147
## [1111] 0.10306157 0.15969094 0.34936782 0.05972969 0.10172940 0.06941820
## [1117] 0.24337548 0.14007170 0.08630044 0.14651456 0.15794700 0.53243230
## [1123] 0.11427603 0.07569152 0.06176428 0.47795863 0.10243182 0.72484619
## [1129] 0.08690597 0.59153224 0.19546578 0.18088456 0.19033086 0.36719469
## [1135] 0.21743448 0.07854963 0.16419610 0.44012498 0.24075958 0.30596328
## [1141] 0.08266725 0.07770188 0.10575013 0.20130311 0.34563775 0.68199874
## [1147] 0.07043550 0.16317880 0.30094947 0.50271278 0.54175750 0.07062927
## [1153] 0.46744659 1.00000000 0.35312212 0.43649179 0.71811268 0.31814659
## [1159] 0.24543429 0.14070145 0.31880056 0.58676065 0.32752022 0.06685075
## [1165] 0.12493339 0.71663518 0.38562709 0.62793683 0.70789129 0.10926222
## [1171] 0.07331783 0.07760500 0.07777455 0.07293029 0.06699608 0.48282711
## [1177] 0.32398392 0.45843627 0.34445090 0.39829482 0.39887613 0.27636487
## [1183] 0.35057889 0.11878118 0.09611006 0.17252822 0.36247154 0.06963620
## [1189] 0.58881945 0.92251611 0.72249673 0.07697525 0.42864409 0.06348399
## [1195] 0.29794603 0.16107155 0.07113792 0.19238967 0.18732742 0.10945599
## [1201] 0.22276316 0.17877731 0.79290801 0.13326551 0.07695102 0.39151286
## [1207] 0.07104103 0.27004311 0.67608875 0.29353776 0.10286780 0.29784915
## [1213] 0.41415976 0.34188345 0.38984159 0.13510633 0.08194061 0.13394371
## [1219] 0.43627380 0.13978104 0.37264448 0.41474107 0.08651843 0.08286102
## [1225] 0.49409001 0.08567069 0.12001647 0.09368793 0.42743303 0.62146975
## [1231] 0.79961730 0.37608390 0.08135930 0.17143826 0.42130504 0.37426731
## [1237] 0.71384973 0.88838832 0.25129584 0.31855835 0.10834181 0.62219639
## [1243] 0.37896624 0.92077217 0.47764375 0.10044567 0.45225985 0.49125612
## [1249] 0.50627331 0.08491983 0.32303929 0.32446834 0.11742479 0.11393693
## [1255] 0.11161168 0.29746161 0.14179141 0.17868042 0.09322773 0.30838541
## [1261] 0.28004650 0.31795282 0.10114809 0.46376496 0.13113404 0.15373250
## [1267] 0.08840769 0.35011868 0.09141113 0.15278787 0.25824735 0.07629705
## [1273] 0.11400959 0.07573996 0.09143535 0.30201521 0.07925205 0.16923412
## [1279] 0.53044616 0.16860437 0.18255583 0.07857385 0.10463595 0.15930340
## [1285] 0.09271908 0.26900160 0.08964298 0.11662549 0.24620937 0.19544155
## [1291] 0.33178317 0.21036187 0.22656591 0.12667732 0.15978782 0.15516156
## [1297] 0.05117958 0.05352904 0.10432108 0.07624861 0.07702369 0.14028969
## [1303] 0.08906167 0.24521630 0.10783316 0.14748341 0.27060020 0.18664923
## [1309] 0.12423097 0.12691954 0.09291285 0.19050041 0.08722085 0.08208594
## [1315] 0.21789469 0.33686964 0.08220704 0.08259458 0.15576709 0.14821005
## [1321] 0.14346267 0.10700964 0.08848036 0.08298212 0.07159812 0.38836409
## [1327] 0.08116553 0.10427263 0.11994381 0.31206704 0.32953059 0.09225888
## [1333] 0.64271182 0.41495907 0.35256503 0.08368454 0.13132781 0.07881606
## [1339] 0.08416897 0.08700286 0.14070145 0.08109286 0.51574384 0.47064380
## [1345] 0.07588529 0.10555636 0.07188878 0.10078477 0.12372233 0.71615075
## [1351] 0.07632127 0.11178123 0.07508599 0.11124837 0.08257036 0.16160442
## [1357] 0.17892264 0.12490917 0.35663421 0.07930049 0.12132442 0.17177736
## [1363] 0.14959066 0.19268033 0.13735891 0.09884707 0.07210677 0.06658431
## [1369] 0.13035896 0.08307901 0.18408177 0.08247348 0.29179383 0.05604806
## [1375] 0.21370440 0.08862568 0.12580536 0.08092332 0.49447755 0.08339389
## [1381] 0.11015841 0.48139805 0.32679359 0.54892700 0.24296372 0.36394904
## [1387] 0.54660175 0.45296226 0.08676065 0.08148040 0.11006152 0.09661871
## [1393] 0.12771884 0.09228310 0.08397520 0.10492661 0.07753234 0.17470813
## [1399] 0.22293271 0.15782590 0.11606840 0.09521387 0.10185051 0.13067384
## [1405] 0.09468101 0.09596473 0.12808216 0.08169840 0.08944921 0.15886741
## [1411] 0.11393693 0.10289202 0.48515235 0.09317929 0.16543138 0.12246282
## [1417] 0.16383278 0.20130311 0.12754929 0.15000242 0.13224822 0.10766361
## [1423] 0.12212372 0.27898077 0.11027951 0.12452163 0.14530349 0.09061183
## [1429] 0.09407547 0.29918132 0.10262559 0.20881170 0.10233493 0.08845614
## [1435] 0.28888727 0.39868236 0.12219639 0.07474689 0.10499927 0.56391997
## [1441] 0.33645788 0.10998886 0.39616335 0.19529623 0.08077799 0.10303735
## [1447] 0.22145521 0.21535145 0.09802354 0.24090491 0.10640411 0.09378482
## [1453] 0.07864651 0.43380323 0.11008574 0.16983966 0.13910284 0.07048394
## [1459] 0.25475948 0.13907862 0.09942838 0.10054256 0.08649421 0.08019668
## [1465] 0.25475948 0.11948360 0.10376399 0.09393015 0.29906021 0.13295064
## [1471] 0.16165286 0.14213050 0.17160781 0.15167369 0.08169840 0.15562176
## [1477] 0.13796444 0.13236933 0.37746452 0.11924139 0.08562224 0.08620356
## [1483] 0.63292642 0.08864991 0.44053674 0.32093204 0.07729012 0.23966962
## [1489] 0.02456038 0.08484716 0.13668072 0.37819115 0.11439713 0.11783655
## [1495] 0.14397132 0.09124158 0.60928644 0.28866928 0.23162815 0.33963087
## [1501] 0.47231507 0.45487574 0.10579858 0.11202345 0.36760645 0.11836942
## [1507] 0.04226614 0.09908928 0.09223466 0.08700286 0.07624861 0.09150802
## [1513] 0.24463499 0.12641089 0.17073584 0.10172940 0.14697476 0.10432108
## [1519] 0.11669815 0.08990941 0.35753040 0.13510633 0.10872935 0.03177833
## [1525] 0.10909267 0.06239403 0.06878845 0.12115487 0.36373105 0.43288282
## [1531] 0.33241292 0.35038512 0.36537809 0.15472557 0.11771545 0.11735213
## [1537] 0.08257036 0.08303057 0.36964104 0.27236836 0.15651795 0.11817565
## [1543] 0.05665359 0.28159667 0.15513733 0.05507920 0.09463256 0.31267258
## [1549] 0.06973308 0.23298455 0.09557719 0.09012740 0.10964976 0.11849053
## [1555] 0.22005038 0.06801337 0.06244247 0.10589546 0.08792327 0.10240760
## [1561] 0.12168774 0.10616190 0.08981253 0.31872790 0.06849780 0.07530398
## [1567] 0.62139708 0.24422322 0.89294192 0.42522889 0.09196822 0.07266386
## [1573] 0.37460640 0.16690888 0.25093252 0.14464952 0.25776292 0.18236206
## [1579] 0.07762922 0.08576757 0.07421402 0.08702708 0.09526232 0.07135591
## [1585] 0.06786804 0.23288766 0.40439859 0.12028290 0.08208594 0.11190234
## [1591] 0.10584702 0.30228165 0.39858548 0.09250109 0.08707552 0.36273797
## [1597] 0.06108608 0.34885918 0.10604079 0.07995446 0.60805116 0.11212033
## [1603] 0.47117667 0.41803517 0.51806908 0.37274137 0.13433125 0.09475367
## [1609] 0.08140774 0.10221383 0.16867703 0.14513394 0.07244587 0.11284697
## [1615] 0.56086809 0.14048346 0.27420918 0.09807199 0.07653926 0.89294192
## [1621] 0.20445187 0.21128227 0.39802839 0.19788790 0.25093252 0.23097418
## [1627] 0.50716950 0.09567408 0.47909703 0.63840043 0.08504093 0.52698251
## [1633] 0.18543816 0.18972533 0.11882963 0.17054207 0.10691275 0.12108221
## [1639] 0.11999225 0.07467422 0.12352856 0.08523470 0.19476336 0.11836942
## [1645] 0.06072276 0.16918568 0.12050090 0.15840721 0.08298212 0.13903018
## [1651] 0.11422758 0.10570169 0.12059778 0.19352807 0.11243521 0.11379160
## [1657] 0.09991280 0.15625151 0.43746064 0.32623650 0.10553214 0.11703725
## [1663] 0.09528654 0.06299956 0.37644722 0.32257908 0.09732113 0.22988422
## [1669] 0.11977426 0.22295693 0.38555443 0.20173909 0.08547692 0.23598799
## [1675] 0.74330281 0.80390447 0.23075619 0.22230296 0.10134186 0.10974665
## [1681] 0.16264593 0.10274669 0.11459090 0.13326551 0.15751102 0.12294725
## [1687] 0.13355617 0.12798527 0.50637020 0.12086422 0.12192995 0.49389624
## [1693] 0.15247299 0.62515138 0.10412731 0.86973793 0.18429976 0.80061038
## [1699] 0.09676404 0.31385942 0.95693455 0.76948602 0.09901662 0.02581989
## [1705] 0.17802645 0.15290898 0.12045245 0.11335562 0.14578792 0.14256649
## [1711] 0.15378094 0.11560820 0.14474640 0.15256988 0.11919295 0.10296469
## [1717] 0.14077411 0.13687449 0.13854575 0.14263915 0.12776728 0.14690210
## [1723] 0.23388073 0.33829870 0.24269728 0.31860679 0.10112387 0.06830403
## [1729] 0.04614155 0.58114131 0.10744562 0.11677082 0.10141452 0.17952817
## [1735] 0.48830112 0.10579858 0.10979509 0.79930243 0.54543913 0.01472654
## [1741] 0.11151480 0.19791213 0.60582280 0.39485540 0.57108947 0.07915516
## [1747] 0.08489561 0.38325340 0.13181224 0.47401056 0.11585041 0.19672528
## [1753] 0.09867752 0.41210095 0.58070532 0.12939011 0.22198808 0.25873177
## [1759] 0.13924817 0.41992443 0.33287313 0.37361333 0.10998886 0.21179092
## [1765] 0.17817178 0.38930872 0.45722521 0.61408226 0.07409291 0.28060359
## [1771] 0.27498426 0.51625248 0.14578792 0.21334108 0.22581505 0.12246282
## [1777] 0.18272538 0.12355278 0.24012983 0.22867316 0.10032457 0.26425423
## [1783] 0.33481083 0.10686431 0.34231943 0.23298455 0.36080027 0.49513152
## [1789] 0.09809621 0.42559221 0.10579858 0.30240275 0.16264593 0.28702224
## [1795] 0.05885772 0.09187134 0.51240130 0.34743012 0.22232718 0.52039432
## [1801] 0.19643463 0.38482779 0.08077799 0.20747953 0.20324081 0.20718888
## [1807] 0.52354309 0.33730562 0.15915807 0.39914257 0.63014097 0.08591290
## [1813] 0.45756431 0.41658189 0.25192559 0.07971225 0.66165286 0.33001502
## [1819] 0.30913627 0.01782687 0.73647241 0.10492661 0.23509180 0.36581408
## [1825] 0.89238483 0.21045875 0.09257375 0.31567602 0.11931405 0.49181321
## [1831] 0.09594051 0.13374994 0.16339679 0.15344184 0.14208206 0.14447997
## [1837] 0.11817565 0.14990554 0.15872208 0.14934845 0.16322724 0.15414426
## [1843] 0.12524827 0.12253548 0.12582958 0.13794022 0.11815143 0.11497844
## [1849] 0.10541104 0.13559076 0.13522744 0.12767040 0.13871530 0.13554231
## [1855] 0.14435886 0.12737974 0.09533498 0.13273265 0.03843918 0.59346994
## [1861] 0.12764618 0.15310275 0.07537664 0.14331735 0.12643511 0.10822070
## [1867] 0.11279853 0.63774645 0.25032699 0.12251126 0.41890714 0.15884319
## [1873] 0.92648840 0.14893669 0.25919198 0.46790680 0.80991135 0.18584992
## [1879] 0.11437291 0.15177058 0.21106428 0.29152739 0.21891198 0.22382890
## [1885] 0.48578211 0.21956595 0.17851088 0.11306496 0.09504432 0.10928644
## [1891] 0.15804389 0.07452890 0.31424696 0.17863198 0.28968658 0.51346703
## [1897] 0.04827302 0.17831711 0.38516688 0.08850458 0.10034879 0.10039723
## [1903] 0.76180788 0.13689871 0.11032796 0.37526038 0.11132103 0.10243182
## [1909] 0.10696120 0.10548370 0.31051688 0.09119314 0.08203749 0.06571235
## [1915] 0.11032796 0.73913675 0.90141937 0.15557332 0.17754202 0.12442474
## [1921] 0.16976699 0.27723684 0.11105459 0.12381921 0.16395388 0.29109141
## [1927] 0.08581602 0.45288960 0.30586640 0.18107833 0.10357022 0.13188490
## [1933] 0.22545173 0.10381243 0.16945211 0.17211646 0.27888388 0.15295742
## [1939] 0.39776195 0.11580197 0.45267161 0.46282033 0.18391222 0.34091460
## [1945] 0.07791988 0.10749407 0.14956644 0.37688320 0.38790389 0.11391271
## [1951] 0.11093349 0.11321029 0.26575595 0.15874631 0.04757061 0.16758708
## [1957] 0.15680860 0.29860001 0.13752846 0.16535872 0.18713365 0.19260766
## [1963] 0.21147605 0.46008332 0.13803711 0.12721019 0.34643705 0.13651117
## [1969] 0.32141646 0.17000920 0.10674321 0.10841447 0.30526086 0.08470184
## [1975] 0.09778133 0.17315797 0.10066366 0.09499588 0.09213777 0.04866056
## [1981] 0.26452066 0.36511166 0.07845274 0.09659449 0.19968028 0.33306690
## [1987] 0.13137625 0.10957710 0.11255631 0.11008574 0.11345250 0.06166739
## [1993] 0.12793683 0.61420336 0.09066027 0.36445769 0.05008962 0.10846292
## [1999] 0.12427942 0.11129681 0.42932229 0.15356295 0.13299908 0.07501332
## [2005] 0.08363610 0.08680909 0.21331686 0.23414717 0.09250109 0.07675725
## [2011] 0.17262510 0.09451146 0.08545270 0.10022768 0.11420336 0.09899239
## [2017] 0.10802693 0.11086082 0.21455215 0.39378966 0.17395727 0.25497747
## [2023] 0.11323451 0.10788161 0.09681248 0.09388170 0.11836942 0.07963959
## [2029] 0.08540425 0.33071743 0.44305576 0.07569152 0.36249576 0.08584024
## [2035] 0.58569491 0.11899918 0.08351499 0.14738652 0.08850458 0.43995543
## [2041] 0.65041418 0.26783898 0.07847697 0.18715787 0.14472218 0.11652861
## [2047] 0.18466308 0.15719614 0.07162234 0.10512038 0.11083660 0.06115875
## [2053] 0.08821392 0.42697282 0.67233445 0.13188490 0.09959793 0.29675919
## [2059] 0.10250448 0.11122414 0.13302330 0.33340600 0.34372426 0.58366032
## [2065] 0.08375721 0.09005474 0.30160345 0.07639393 0.10306157 0.08276413
## [2071] 0.34595262 0.39771351 0.09661871 0.08794749 0.09182289 0.49551906
## [2077] 0.10751829 0.08918277 0.09090249 0.09129003 0.09015163 0.08591290
## [2083] 0.09659449 0.14399554 0.08462917 0.61480889 0.09736957 0.41212518
## [2089] 0.15680860 0.09967059 0.11769123 0.10957710 0.08203749 0.17807489
## [2095] 0.34219832 0.43460253 0.13178802 0.10512038 0.09792666 0.09959793
## [2101] 0.17429637 0.10202006 0.12224483 0.36213244 0.26921959 0.29857579
## [2107] 0.08104442 0.33241292 0.10885046 0.08533159 0.07484377 0.06573657
## [2113] 0.33328489 0.14147653 0.54514848 0.08145618 0.13394371 0.35358233
## [2119] 0.08399942 0.78678002 0.09775711 0.08358766 0.09843530 0.09828998
## [2125] 0.07900983 0.19076685 0.08516204 0.11914450 0.11153902 0.11364627
## [2131] 0.14268759 0.11403381 0.11938672 0.62001647 0.34396648 0.07365693
## [2137] 0.10487817 0.06946665 0.14169452 0.14261493 0.09739379 0.12922056
## [2143] 0.08789905 0.06718985 0.09346994 0.11570508 0.09000630 0.08777794
## [2149] 0.08039045 0.03962602 0.03468488 0.06762583 0.08138352 0.18226517
## [2155] 0.07835586 0.35365499 0.08729351 0.16327569 0.16237950 0.06726251
## [2161] 0.10153563 0.08944921 0.27585622 0.28869350 0.09574674 0.31182483
## [2167] 0.08663954 0.26362447 0.39703531 0.52223514 0.59640072 0.13733469
## [2173] 0.12955966 0.38206656 0.09732113 0.13249043 0.08334544 0.19800901
## [2179] 0.34040595 0.11844209 0.09511699 0.12464274 0.10531415 0.14527927
## [2185] 0.06406530 0.08273991 0.18129632 0.15034152 0.16497118 0.18737587
## [2191] 0.15472557 0.07733857 0.12331057 0.10952865 0.28452744 0.10102698
## [2197] 0.17252822 0.15230344 0.27527491 0.04577823 0.34396648 0.16640023
## [2203] 0.11846631 0.31342344 0.13956305 0.11265320 0.06595456 0.26076636
## [2209] 0.17148670 0.13140047 0.15831032 0.08467761 0.14956644 0.12771884
## [2215] 0.08942499 0.48071986 0.02928353 0.10916533 0.06554280 0.11512377
## [2221] 0.10107543 0.06961198 0.17211646 0.12016180 0.46977184 0.12767040
## [2227] 0.17933440 0.36574141 0.08499249 0.12030713 0.81494938 0.46618709
## [2233] 0.10056678 0.15094705 0.11548709 0.08867413 0.30186988 0.30826430
## [2239] 0.13505789 0.24536162 0.16339679 0.16916146 0.29208448 0.47628736
## [2245] 0.09824153 0.13694715 0.49895848 0.83137141 0.18197452 0.10444218
## [2251] 0.12662888 0.17187424 0.08484716 0.09555297 0.20067335 0.36796977
## [2257] 0.09480211 0.53594439 0.14547304 0.27224725 0.44957128 0.06375042
## [2263] 0.53679213 0.33640944 0.25020588 0.15932762 0.10364288 0.10170518
## [2269] 0.14358378 0.27452405 0.09136269 0.50944630 0.18497796 0.11873274
## [2275] 0.15545221 0.82805309 0.63985370 0.07741123 0.15976360 0.08753573
## [2281] 0.59891973 0.13193334 0.19570799 0.29913288 0.59984014 0.23361430
## [2287] 0.11417914 0.44416994 0.52470571 0.19284988 0.07641816 0.11975004
## [2293] 0.22847939 0.29707407 0.08528315 0.07983336 0.38170324 0.66485007
## [2299] 0.12323790 0.38233299 0.09286441 0.11195078 0.37390399 0.11878118
## [2305] 0.29860001 0.14259071 0.49215230 0.14925156 0.14225161 0.76103280
## [2311] 0.41297292 0.32180400 0.62723441 0.29944775 0.20769752 0.07513443
## [2317] 0.94177203 0.11996803 0.29533014 0.16136221 0.08654265 0.29436128
## [2323] 0.12679843 0.16700576 0.50312455 0.31189750 0.37223272 0.12534515
## [2329] 0.61158746 0.49215230 0.11396115 0.72847939 0.16780507 0.10470862
## [2335] 0.43336724 0.07588529 0.15215812 0.67899530 0.08983675 0.10640411
## [2341] 0.22804340 0.13006830 0.08584024 0.51138400 0.07498910 0.13900596
## [2347] 0.42099017 0.12430364 0.47565761 0.35382454 0.11800610 0.12556314
## [2353] 0.29026789 0.07365693 0.35837814 0.46311098 0.21842755 0.47824929
## [2359] 0.23475270 0.17962505 0.08741462 0.11730369 0.14329313 0.11342828
## [2365] 0.10582280 0.14743497 0.11444557 0.11432447 0.10730030 0.10918956
## [2371] 0.11052173 0.10630722 0.11640750 0.10650099 0.12745241 0.12159085
## [2377] 0.13789178 0.14348690 0.16618224 0.12507872 0.11657705 0.14523083
## [2383] 0.09923461 0.11071550 0.08949765 0.05890617 0.11173279 0.33277624
## [2389] 0.13203023 0.77980429 0.37528460 0.36864797 0.27776970 0.37310468
## [2395] 0.09104781 0.19951073 0.17293998 0.16017536 0.24037204 0.15726881
## [2401] 0.09875018 0.08247348 0.13568764 0.04325922 0.28639248 0.06530059
## [2407] 0.15886741 0.07230054 0.30186988 0.14573948 0.48144650 0.44620452
## [2413] 0.38281742 0.46686528 0.46579954 0.41653345 0.14733808 0.12696798
## [2419] 0.12658044 0.15772901 0.18996754 0.51286150 0.83241292 0.23046553
## [2425] 0.20156954 0.17247978 0.40018408 0.08969142 0.16550404 0.15416848
## [2431] 0.16717531 0.18049702 0.63096449 0.16874970 0.19565955 0.61333140
## [2437] 0.50029066 0.25773870 0.12103376 0.13210289 0.68335513 0.01937703
## [2443] 0.45591726 0.41437776 0.34328828 0.12689532 0.11565664 0.14312358
## [2449] 0.79189071 0.40771690 0.27188393 0.10877779 0.53688902 0.10700964
## [2455] 0.09654604 0.21634452 0.45378579 0.31306012 0.39919101 0.13437969
## [2461] 0.07191300 0.18066657 0.34285230 0.50431139 0.10340067 0.46536356
## [2467] 0.19534467 0.22290849 0.20450031 0.08082643 0.26522308 0.18459042
## [2473] 0.32754445 0.14200940 0.18391222 0.25032699 0.40100761 0.48447416
## [2479] 0.17029986 0.61115148 0.10863247 0.09419658 0.25468682 0.62786417
## [2485] 0.15181902 0.07515865 0.18219251 0.15467713 0.12931744 0.18006104
## [2491] 0.45264739 0.28975924 0.07515865 0.15521000 0.65007509 0.14259071
## [2497] 0.13251465 0.17267355 0.09860485 0.11115148 0.09833842 0.09056339
## [2503] 0.17657317 0.36961682 0.15896430 0.31427118 0.15300586 0.09661871
## [2509] 0.10235915 0.10439374 0.21038609 0.07600639 0.21191203 0.61480889
## [2515] 0.09405125 0.37351645 0.09632805 0.02339776 0.08593712 0.32599428
## [2521] 0.08569491 0.09625539 0.26548951 0.06641477 0.06718985 0.10543526
## [2527] 0.15511311 0.13278109 0.10902001 0.09594051 0.06849780 0.31448917
## [2533] 0.04732839 0.08075377 0.10185051 0.08831081 0.07031439 0.09397859
## [2539] 0.15717192 0.15412004 0.24916437 0.20297437 0.28290462 0.43646757
## [2545] 0.07549775 0.54158795 0.08370876 0.08554958 0.12561159 0.32572785
## [2551] 0.37123965 0.11078816 0.09317929 0.16114421 0.12004069 0.39773773
## [2557] 0.13827932 0.29753427 0.26534418 0.08281258 0.09865330 0.16029647
## [2563] 0.30739234 0.16669089 0.16693310 0.09150802 0.19728237 0.44765780
## [2569] 0.40299375 0.50850167 0.36155113 0.15317541 0.15169791 0.15646951
## [2575] 0.41847115 0.06978152 0.08787482 0.07339050 0.24088069 0.52255002
## [2581] 0.08310323 0.08361188 0.52911399 0.08671220 0.18311292 0.33149252
## [2587] 0.15952139 0.16894347 0.17504723 0.25313666 0.16342101 0.18238628
## [2593] 0.22046214 0.29399797 0.08169840 0.28181466 0.34413603 0.90774112
## [2599] 0.07494066 0.09267064 0.07038706 0.07302718 0.29985952 0.08671220
## [2605] 0.11493000 0.03616238 0.14326890 0.07622439 0.09630383 0.48864022
## [2611] 0.09589207 0.40560965 0.12941433 0.04589934 0.09451146 0.08346655
## [2617] 0.07200988 0.05692002 0.06127985 0.16715109 0.07465000 0.08399942
## [2623] 0.28612605 0.06275735 0.11572930 0.06857046 0.20888437 0.05873662
## [2629] 0.06144940 0.42554377 0.10017924 0.05001695 0.26299472 0.15336918
## [2635] 0.15002664 0.06370198 0.06307223 0.08959454 0.10267403 0.13767379
## [2641] 0.10025190 0.10308579 0.11369471 0.09739379 0.07881606 0.24032360
## [2647] 0.08506516 0.09252531 0.35803904 0.06740784 0.10541104 0.10732452
## [2653] 0.15659061 0.05585428 0.28251708 0.19720971 0.28469699 0.17853510
## [2659] 0.07598217 0.09211355 0.11912028 0.15729303 0.34367582 0.10981931
## [2665] 0.07305140 0.11817565 0.05527297 0.13050429 0.08390253 0.15220656
## [2671] 0.07719324 0.25674563 0.09131425 0.20905392 0.08574335 0.24221286
## [2677] 0.10209272 0.31797704 0.06101342 0.11388849 0.10025190 0.06617255
## [2683] 0.08632466 0.07210677 0.05474011 0.15843143 0.10325534 0.33391464
## [2689] 0.12255971 0.50624909 0.16049024 0.11037640 0.03344960 0.08545270
## [2695] 0.13864264 0.18291915 0.09889551 0.68710943 0.06038367 0.08336967
## [2701] 0.38250254 0.08845614 0.31688708 0.13421014 0.08409630 0.08399942
## [2707] 0.32144068 0.37228116 0.02957419 0.57905828 0.11948360 0.17458703
## [2713] 0.47667490 0.14661144 0.13731047 0.20801240 0.21559366 0.10928644
## [2719] 0.12670155 0.07886451 0.16804728 0.09189556 0.08567069 0.15971516
## [2725] 0.19730659 0.14549726 0.20183597 0.22484619 0.15891586 0.14089522
## [2731] 0.40992104 0.32725379 0.55369859 0.07966381 0.15351451 0.08521048
## [2737] 0.15290898 0.14392288 0.16170130 0.13358039 0.46277188 0.10281936
## [2743] 0.08257036 0.09930727 0.07891295 0.07418980 0.14426198 0.07036283
## [2749] 0.12197839 0.07603062 0.16085356 0.37417042 0.14927578 0.12612023
## [2755] 0.09722424 0.09802354 0.09916194 0.09889551 0.11291963 0.09812043
## [2761] 0.11509955 0.18570460 0.48251223 0.30150656 0.14157341 0.10567747
## [2767] 0.08191639 0.14331735 0.09339728 0.37455796 0.63360461 0.19129971
## [2773] 0.13500945 0.24683912 0.06120719 0.10044567 0.41122899 0.12767040
## [2779] 0.12602335 0.60657366 0.84156857 0.15467713 0.56011723 0.46226324
## [2785] 0.27009156 0.19229279 0.70675289 0.13847309 0.30596328 0.11357361
## [2791] 0.38591774 0.06702030 0.33389042 0.61446980 0.32265175 0.16618224
## [2797] 0.07317250 0.10606501 0.09053917 0.10194739 0.20433077 0.07486799
## [2803] 0.08709974 0.08634888 0.50564356 0.51148089 0.08312745 0.47851572
## [2809] 0.15295742 0.05958436 0.48168871 0.21045875 0.51162622 0.06745628
## [2815] 0.15525844 0.06496149 0.13050429 0.17499879 0.05764666 0.41667878
## [2821] 0.48398973 0.12822749 0.27912610 0.08494405 0.10802693 0.07535242
## [2827] 0.17427215 0.06190961 0.15959405 0.08695442 0.08448384 0.10889890
## [2833] 0.03470910 0.17555588 0.49544640 0.74594293 0.07481955 0.10306157
## [2839] 0.08634888 0.18846582 0.71830645 0.46424938 0.23482536 0.25839268
## [2845] 0.08058422 0.08554958 0.17240711 0.47846728 0.06505837 0.07014484
## [2851] 0.28149978 0.08039045 0.33338178 0.19972872 0.06806181 0.17037252
## [2857] 0.36850264 0.26389091 0.56781960 0.35530204 0.19360074 0.41716320
## [2863] 0.81950298 0.08702708 0.10521726 0.10994042 0.14392288 0.14341423
## [2869] 0.18195030 0.16363901 0.05352904 0.11819987 0.15785012 0.11434869
## [2875] 0.25115051 0.19834811 0.13142470 0.12551470 0.35149930 0.12188151
## [2881] 0.39289347 0.14937267 0.12735552 0.27418495 0.11970159 0.22227874
## [2887] 0.09799932 0.10926222 0.13718936 0.12679843 0.13241777 0.27181127
## [2893] 0.12696798 0.29528169 0.13026207 0.42072373 0.12721019 0.49019038
## [2899] 0.13345928 0.41866492 0.11931405 0.14593325 0.42573754 0.42065107
## [2905] 0.11875696 0.12057356 0.10933488 0.14077411 0.12922056 0.13454924
## [2911] 0.12037979 0.23802257 0.23024754 0.31843724 0.13716514 0.08603401
## [2917] 0.18267694 0.12280192 0.40032941 0.44780313 0.13551809 0.40335707
## [2923] 0.18136899 0.38313230 0.13847309 0.55411035 0.23322676 0.36523277
## [2929] 0.14135542 0.14203362 0.12306835 0.17526522 0.08998208 0.11049751
## [2935] 0.27399118 0.08152885 0.12958388 0.16240372 0.27263479 0.10109965
## [2941] 0.14118587 0.16291237 0.16194352 0.48549145 0.16242794 0.16102311
## [2947] 0.13493678 0.11975004 0.16647290 0.41374800 0.24359347 0.05909994
## [2953] 0.10093010 0.52792714 0.16114421 0.20733421 0.32347527 0.48779247
## [2959] 0.25037543 0.26941336 0.08579179 0.08690597 0.09615850 0.18764230
## [2965] 0.08516204 0.51206220 0.13881219 0.24618515 0.33602190 0.08731773
## [2971] 0.16172552 0.36256843 0.44579276 0.08034200 0.30819164 0.14387444
## [2977] 0.09218621 0.09150802 0.20159376 0.45313181 0.49263673 0.39698687
## [2983] 0.23191881 0.09436613 0.08731773 0.10596812 0.28295306 0.08831081
## [2989] 0.07455312 0.08753573 0.10906845 0.09073294 0.11187812 0.12113065
## [2995] 0.10172940 0.33103231 0.11248365 0.13680182 0.09216199 0.10604079
## [3001] 0.11945938 0.17686383 0.13903018 0.10354600 0.10168096 0.10797849
## [3007] 0.09523810 0.08230393 0.10155985 0.08838347 0.12522405 0.08550114
## [3013] 0.08969142 0.08155307 0.14489173 0.91583103 0.21070096 0.04505159
## [3019] 0.11141791 0.08697864 0.09923461 0.09698203 0.12786417 0.07174345
## [3025] 0.10621034 0.03422468 0.09894395 0.12696798 0.11107882 0.08823814
## [3031] 0.72327181 0.20873904 0.12067045 0.13796444 0.12730708 0.07903406
## [3037] 0.07573996 0.06992685 0.09082982 0.07566730 0.08482294 0.07876762
## [3043] 0.08118975 0.52492370 0.06091653 0.14816160 0.12304413 0.10257714
## [3049] 0.18955578 0.07266386 0.08574335 0.10667054 0.13057695 0.09303396
## [3055] 0.08663954 0.08615511 0.09560141 0.10800271 0.11003730 0.19381873
## [3061] 0.12057356 0.11420336 0.08068110 0.09773289 0.10528993 0.13135203
## [3067] 0.08082643 0.09426924 0.17659739 0.09606162 0.06205493 0.11115148
## [3073] 0.17749358 0.11522066 0.12820327 0.07181611 0.12449741 0.10904423
## [3079] 0.07084726 0.10349755 0.06416219 0.06609989 0.07130747 0.06774694
## [3085] 0.10897156 0.13873952 0.18623747 0.24519207 0.12752507 0.11115148
## [3091] 0.08547692 0.09816887 0.06946665 0.05016228 0.08574335 0.11035218
## [3097] 0.08739040 0.10669476 0.10492661 0.08654265 0.09831420 0.09378482
## [3103] 0.10020346 0.19616819 0.13011675 0.07973647 0.12716175 0.10231071
## [3109] 0.11352517 0.16296081 0.06132830 0.09330039 0.21523034 0.12602335
## [3115] 0.10768784 0.08462917 0.09463256 0.05474011 0.08189217 0.11817565
## [3121] 0.09511699 0.09763600 0.10301313 0.08751151 0.11141791 0.09976748
## [3127] 0.08382987 0.09790244 0.10553214 0.10885046 0.09397859 0.09097515
## [3133] 0.09446301 0.08760839 0.08126241 0.17453858 0.09884707 0.07857385
## [3139] 0.09744223 0.10037301 0.07300295 0.08034200 0.08012401 0.07530398
## [3145] 0.11158746 0.12764618 0.08370876 0.09528654 0.10986775 0.09397859
## [3151] 0.08901322 0.08923122 0.07091992 0.09659449 0.09218621 0.14850070
## [3157] 0.29780071 0.30807053 0.10553214 0.07009640 0.13592986 0.08123819
## [3163] 0.08770528 0.09678826 0.10383665 0.12980187 0.10175362 0.07576418
## [3169] 0.12318946 0.04129729 0.08288524 0.11342828 0.10470862 0.10330378
## [3175] 0.09015163 0.18621324 0.08775372 0.09787822 0.10015502 0.08179528
## [3181] 0.10107543 0.08128663 0.07263964 0.08240081 0.08986097 0.11776389
## [3187] 0.08775372 0.08051155 0.10083321 0.07423824 0.12423097 0.07646660
## [3193] 0.09821731 0.11081238 0.08676065 0.16431720 0.07864651 0.11882963
## [3199] 0.08995785 0.04275057 0.17572543 0.68548661 0.03984401 0.05144601
## [3205] 0.01574384 0.05440101 0.01421789 0.09429347 0.09925883 0.08937654
## [3211] 0.11749746 0.07876762 0.09017585 0.09889551 0.08058422 0.11342828
## [3217] 0.12226905 0.11793344 0.10187473 0.09625539 0.11604418 0.15550065
## [3223] 0.13873952 0.20365257 0.06748050 0.08852880 0.07559463 0.08700286
## [3229] 0.08089909 0.08538003 0.07329361 0.07196144 0.07210677 0.23174926
## [3235] 0.09843530 0.11454246 0.08734196 0.13973260 0.09107203 0.08378143
## [3241] 0.09601318 0.13331396 0.11606840 0.11195078 0.08954609 0.09327617
## [3247] 0.21285666 0.12268081 0.07733857 0.08973986 0.13091605 0.11560820
## [3253] 0.09577096 0.09458412 0.09245265 0.11149058 0.14733808 0.18071501
## [3259] 0.08424163 0.08712396 0.07261541 0.08424163 0.08579179 0.09720002
## [3265] 0.12171196 0.08663954 0.09957371 0.07779877 0.07535242 0.32517076
## [3271] 0.09644916 0.11163591 0.14058034 0.07881606 0.15031730 0.10826915
## [3277] 0.12018602 0.05343216 0.10720341 0.08244926 0.08567069 0.08860146
## [3283] 0.10088165 0.08860146 0.07821053 0.07932471 0.08421741 0.09034540
## [3289] 0.08678487 0.09441457 0.10633144 0.07053238 0.11989536 0.11454246
## [3295] 0.08644577 0.18040014 0.08167418 0.09075716 0.08705130 0.08758417
## [3301] 0.08755995 0.07942160 0.17456281 0.07927627 0.21789469 0.15378094
## [3307] 0.11539020 0.02799981 0.08973986 0.05607228 0.08453229 0.09422080
## [3313] 0.09346994 0.11761856 0.17199535 0.10153563 0.13285375 0.02654653
## [3319] 0.08014823 0.10049411 0.11279853 0.10528993 0.10553214 0.10473284
## [3325] 0.13689871 0.11190234 0.09310662 0.13898174 0.09354261 0.08450807
## [3331] 0.09453568 0.12815482 0.14615124 0.09269486 0.09242843 0.08661532
## [3337] 0.08475028 0.08375721 0.07372959 0.10751829 0.20200552 0.15181902
## [3343] 0.10083321 0.08075377 0.07036283 0.08755995 0.08160151 0.09722424
## [3349] 0.12839704 0.09918616 0.13685026 0.02007945 0.09732113 0.06663276
## [3355] 0.12098532 0.09422080 0.11652861 0.11454246 0.08947343 0.09342150
## [3361] 0.09114470 0.11941094 0.07828320 0.07636971 0.09785399 0.17306109
## [3367] 0.18555927 0.08138352 0.09087826 0.08792327 0.07760500 0.09572252
## [3373] 0.08387831 0.09107203 0.10233493 0.08971564 0.09727268 0.05486121
## [3379] 0.03114857 0.10347333 0.07208255 0.06648743 0.10051834 0.10080899
## [3385] 0.07854963 0.17456281 0.08894056 0.11275008 0.07239742 0.06554280
## [3391] 0.09470523 0.11899918 0.08424163 0.07942160 0.08770528 0.11170857
## [3397] 0.08009979 0.07435935 0.07322095 0.08683331 0.09850797 0.09688514
## [3403] 0.12498183 0.12171196 0.09383326 0.08617933 0.09993702 0.10105120
## [3409] 0.07481955 0.11090927 0.07636971 0.08196483 0.08920700 0.08467761
## [3415] 0.13471879 0.10369132 0.09535920 0.26597394 0.09322773 0.07581262
## [3421] 0.07673303 0.14312358 0.07879184 0.09451146 0.09577096 0.21070096
## [3427] 0.06951509 0.09485055 0.08569491 0.11759434 0.10097854 0.09228310
## [3433] 0.07910672 0.08419319 0.10565325 0.08797171 0.09349416 0.11715836
## [3439] 0.10008235 0.07389914 0.08680909 0.08719663 0.09407547 0.08966720
## [3445] 0.11536598 0.12498183 0.04684397 0.07695102 0.06958775 0.36656494
## [3451] 0.09615850 0.08450807 0.07823475 0.11907184 0.11752168 0.09904084
## [3457] 0.08981253 0.08673642 0.09300974 0.01550162 0.10998886 0.33648210
## [3463] 0.00000000 0.09913772 0.09044228 0.10085743 0.08676065 0.08479872
## [3469] 0.20404011 0.09269486 0.09439035 0.14431042 0.70631691 0.09109626
## [3475] 0.08869835 0.08787482 0.08995785 0.08429007 0.09049072 0.06079543
## [3481] 0.10989197 0.10015502 0.09785399 0.24153466 0.14508550 0.08310323
## [3487] 0.09594051 0.11132103 0.06345977 0.09700625 0.09921039 0.07004796
## [3493] 0.09676404 0.14094366 0.09175023 0.11015841 0.09327617 0.12481229
## [3499] 0.10698542 0.12459429 0.10720341 0.16252483 0.15576709 0.01516252
## [3505] 0.08908589 0.11110304 0.10371555 0.07840430 0.09402703 0.11204767
## [3511] 0.11061861 0.09053917 0.08588868 0.10686431 0.10468440 0.09133847
## [3517] 0.06806181 0.09291285 0.09492322 0.09753912 0.09402703 0.09114470
## [3523] 0.11156324 0.09615850 0.04272635 0.11996803 0.17325486 0.04447028
## [3529] 0.11367049 0.14443153 0.06968464 0.09112048 0.04357409 0.12490917
## [3535] 0.09865330 0.09221043 0.09843530 0.11323451 0.09049072 0.08198905
## [3541] 0.08971564 0.10914111 0.11570508 0.12137286 0.40791067 0.08896478
## [3547] 0.08911011 0.09717580 0.09129003 0.13748002 0.08353921 0.08973986
## [3553] 0.10243182 0.07632127 0.08397520 0.08923122 0.10284358 0.07886451
## [3559] 0.08666376 0.10521726 0.09664293 0.10829337 0.15097127 0.31075910
## [3565] 0.09204089 0.06985419 0.10943177 0.07808942 0.07624861 0.14506128
## [3571] 0.12779150 0.36741268 0.08889212 0.19408516 0.16860437 0.10400620
## [3577] 0.23560045 0.27256213 0.09044228 0.11643172 0.07421402 0.08947343
## [3583] 0.09099937 0.08232815 0.08736618 0.11841787 0.11078816 0.11318607
## [3589] 0.10696120 0.13304752 0.10090588 0.09385748 0.08431430 0.09889551
## [3595] 0.09170179 0.08363610 0.08085065 0.08818970 0.07481955 0.19842077
## [3601] 0.08911011 0.09281597 0.11197500 0.09831420 0.14559415 0.06709296
## [3607] 0.13898174 0.05897883 0.09005474 0.07513443 0.13949038 0.08983675
## [3613] 0.09586785 0.03349804 0.13859420 0.16124110 0.09218621 0.07993024
## [3619] 0.15625151 0.11306496 0.10877779 0.09308240 0.10761517 0.10616190
## [3625] 0.08380565 0.08303057 0.09000630 0.09640072 0.10582280 0.10199583
## [3631] 0.06728673 0.07729012 0.04468827 0.06668120 0.11161168 0.07968803
## [3637] 0.09497166 0.35704597 0.11410648 0.11379160 0.13600252 0.14900935
## [3643] 0.10722763 0.15031730 0.15031730 0.10260137 0.10238337 0.08259458
## [3649] 0.15169791 0.19224434 0.11296808 0.13360461 0.10475706 0.10746984
## [3655] 0.11735213 0.09480211 0.10853558 0.12251126 0.14353534 0.17027564
## [3661] 0.08862568 0.09581941 0.09354261 0.09468101 0.08181950 0.07813787
## [3667] 0.09308240 0.10410309 0.09782977 0.09153224 0.08625200 0.09778133
## [3673] 0.12205106 0.08569491 0.10989197 0.12222061 0.11718258 0.10686431
## [3679] 0.10395776 0.08254614 0.09003052 0.08186795 0.04657753 0.13360461
## [3685] 0.20924769 0.28036138 0.04982318 0.10403042 0.10168096 0.08809282
## [3691] 0.10960132 0.09572252 0.10185051 0.11841787 0.05972969 0.08409630
## [3697] 0.09581941 0.07997869 0.08753573 0.09380904 0.08533159 0.08501671
## [3703] 0.09640072 0.12512716 0.10572591 0.07653926 0.02281645 0.10344911
## [3709] 0.11369471 0.10918956 0.11282275 0.10553214 0.11829676 0.11805455
## [3715] 0.10984353 0.08363610 0.46998983 0.05071937 0.07331783 0.06750472
## [3721] 0.10463595 0.10182628 0.11577775 0.09223466 0.06762583 0.08690597
## [3727] 0.03512086 0.06404108 0.25868333 0.13580875 0.09366371 0.08809282
## [3733] 0.06537325 0.10168096 0.07934893 0.09463256 0.16603691 0.10107543
## [3739] 0.12338323 0.10100276 0.08416897 0.11136947 0.09497166 0.10851136
## [3745] 0.12202684 0.08625200 0.08877101 0.07990602 0.10027612 0.08160151
## [3751] 0.24909170 0.09007896 0.09630383 0.12670155 0.08729351 0.12788839
## [3757] 0.10359444 0.11919295 0.10291624 0.08525893 0.04936298 0.12614446
## [3763] 0.11832098 0.11485734 0.09664293 0.12922056 0.08273991 0.09053917
## [3769] 0.10807538 0.12532093 0.10570169 0.11442135 0.13084339 0.13803711
## [3775] 0.14007170 0.12226905 0.11374316 0.10802693 0.08768105 0.11938672
## [3781] 0.11086082 0.08528315 0.10051834 0.05769510 0.10398198 0.10139030
## [3787] 0.04313811 0.03587172 0.07176767 0.11810299 0.02172649 0.10696120
## [3793] 0.11059439 0.22043792 0.07259119 0.07605484 0.12316524
#Let's check just to be sure
aidvalue_density <- density(college$aid_value)
plot(aidvalue_density)
aidvalue_density_n <- density(aidvalue_n)
plot(aidvalue_density_n)
abc <- names(select_if(college, is.numeric))# select function to find the numeric variables and create a character string
abc
## [1] "hbcu" "flagship" "student_count" "aid_value"
## [5] "pell_value"
#Use lapply to normalize the numeric values
college[abc] <- lapply(college[abc], normalize)#use apply again with the normalizer function we created.
str(college)
## tibble [3,797 × 7] (S3: tbl_df/tbl/data.frame)
## $ level : Factor w/ 2 levels "2-year","4-year": 2 2 2 2 2 2 1 2 2 2 ...
## $ control : Factor w/ 3 levels "Private for-profit",..: 3 3 2 3 3 3 3 3 3 2 ...
## $ hbcu : num [1:3797] 1 0 0 0 1 0 0 0 0 0 ...
## $ flagship : num [1:3797] 0 0 0 0 0 1 0 0 0 0 ...
## $ student_count: num [1:3797] 0.02368 0.06748 0.00176 0.03335 0.03135 ...
## $ aid_value : num [1:3797] 0.1659 0.1403 0.0544 0.1539 0.1686 ...
## $ pell_value : num [1:3797] 0.712 0.351 0.684 0.328 0.827 0.211 0.651 0.401 0.169 0.214 ...
# Next let's one-hot encode those factor variables/character
class(college)
## [1] "tbl_df" "tbl" "data.frame"
?one_hot#what issue will we run into here?
## starting httpd help server ... done
college_1h <- one_hot(as.data.table(college),cols = "auto",sparsifyNAs = FALSE,naCols = FALSE,dropCols = TRUE,dropUnusedLevels = TRUE)#one_hot function requires a data.table class so we coerce the format.
?one_hot# looks at the various arguments
str(college_1h)#what looks different?
## Classes 'data.table' and 'data.frame': 3797 obs. of 10 variables:
## $ level_2-year : int 0 0 0 0 0 0 1 0 0 0 ...
## $ level_4-year : int 1 1 1 1 1 1 0 1 1 1 ...
## $ control_Private for-profit : int 0 0 0 0 0 0 0 0 0 0 ...
## $ control_Private not-for-profit: int 0 0 1 0 0 0 0 0 0 1 ...
## $ control_Public : int 1 1 0 1 1 1 1 1 1 0 ...
## $ hbcu : num 1 0 0 0 1 0 0 0 0 0 ...
## $ flagship : num 0 0 0 0 0 1 0 0 0 0 ...
## $ student_count : num 0.02368 0.06748 0.00176 0.03335 0.03135 ...
## $ aid_value : num 0.1659 0.1403 0.0544 0.1539 0.1686 ...
## $ pell_value : num 0.712 0.351 0.684 0.328 0.827 0.211 0.651 0.401 0.169 0.214 ...
## - attr(*, ".internal.selfref")=<externalptr>
#Essentially the target to which we are trying to out perform with our model. Percentage represented by the positive class. Continuous we are going to turn this into a Boolean to be used for classification by selecting the top quartile of values.
(box <- boxplot(college_1h$aid_value, horizontal = TRUE))
## $stats
## [,1]
## [1,] 0.00000000
## [2,] 0.09020007
## [3,] 0.11899918
## [4,] 0.21917841
## [5,] 0.41212518
##
## $n
## [1] 3797
##
## $conf
## [,1]
## [1,] 0.1156920
## [2,] 0.1223063
##
## $out
## [1] 0.4866299 0.4751247 0.4461803 0.4432980 0.6343555 0.4599622 0.5645982
## [8] 0.4216684 0.7029017 0.5344427 0.8646999 0.4514121 0.6252483 0.4528412
## [15] 0.5712106 0.4386233 0.4780555 0.4940173 0.5928402 0.4366371 0.6895558
## [22] 0.4137722 0.4186649 0.5089861 0.7814029 0.7903406 0.8748486 0.5422661
## [29] 0.5458993 0.4701109 0.5127646 0.4546093 0.7474204 0.5279514 0.7244587
## [36] 0.4599138 0.5576951 0.6839122 0.5138304 0.7905101 0.5295015 0.4176719
## [43] 0.9414087 0.9048103 0.9880105 0.5321901 0.6574384 0.7548079 0.4245991
## [50] 0.4705711 0.6008090 0.4960035 0.6251272 0.4256891 0.5881897 0.4285956
## [57] 0.7201473 0.4187860 0.5034879 0.4329555 0.5358717 0.4758514 0.7316766
## [64] 0.5704839 0.4323257 0.4283534 0.5877053 0.4988132 0.6083903 0.4315022
## [71] 0.4975294 0.7064380 0.4301943 0.4259555 0.5748922 0.7218670 0.5054982
## [78] 0.4976263 0.4986921 0.4515090 0.7135349 0.4543671 0.5020104 0.4215715
## [85] 0.4843046 0.4811801 0.4425713 0.5386330 0.5623214 0.4288379 0.5867364
## [92] 0.7277043 0.5346364 0.5050622 0.4167514 0.4164850 0.4974083 0.4194400
## [99] 0.5294289 0.6414281 0.4766507 0.5107058 0.5463353 0.4189798 0.4631110
## [106] 0.4614882 0.6177881 0.4576128 0.6526183 0.5608439 0.6819745 0.8542363
## [113] 0.8114857 0.8181224 0.5324323 0.4779586 0.7248462 0.5915322 0.4401250
## [120] 0.6819987 0.5027128 0.5417575 0.4674466 1.0000000 0.4364918 0.7181127
## [127] 0.5867606 0.7166352 0.6279368 0.7078913 0.4828271 0.4584363 0.5888195
## [134] 0.9225161 0.7224967 0.4286441 0.7929080 0.6760887 0.4141598 0.4362738
## [141] 0.4147411 0.4940900 0.4274330 0.6214697 0.7996173 0.4213050 0.7138497
## [148] 0.8883883 0.6221964 0.9207722 0.4776438 0.4522598 0.4912561 0.5062733
## [155] 0.4637650 0.5304462 0.6427118 0.4149591 0.5157438 0.4706438 0.7161508
## [162] 0.4944775 0.4813981 0.5489270 0.5466018 0.4529623 0.4851524 0.5639200
## [169] 0.4338032 0.6329264 0.4405367 0.6092864 0.4723151 0.4548757 0.4328828
## [176] 0.6213971 0.8929419 0.4252289 0.6080512 0.4711767 0.4180352 0.5180691
## [183] 0.5608681 0.8929419 0.5071695 0.4790970 0.6384004 0.5269825 0.4374606
## [190] 0.7433028 0.8039045 0.5063702 0.4938962 0.6251514 0.8697379 0.8006104
## [197] 0.9569346 0.7694860 0.5811413 0.4883011 0.7993024 0.5454391 0.6058228
## [204] 0.5710895 0.4740106 0.5807053 0.4199244 0.4572252 0.6140823 0.5162525
## [211] 0.4951315 0.4255922 0.5124013 0.5203943 0.5235431 0.6301410 0.4575643
## [218] 0.4165819 0.6616529 0.7364724 0.8923848 0.4918132 0.5934699 0.6377465
## [225] 0.4189071 0.9264884 0.4679068 0.8099114 0.4857821 0.5134670 0.7618079
## [232] 0.7391368 0.9014194 0.4528896 0.4526716 0.4628203 0.4600833 0.6142034
## [239] 0.4293223 0.4430558 0.5856949 0.4399554 0.6504142 0.4269728 0.6723344
## [246] 0.5836603 0.4955191 0.6148089 0.4346025 0.5451485 0.7867800 0.6200165
## [253] 0.5222351 0.5964007 0.4807199 0.4697718 0.8149494 0.4661871 0.4762874
## [260] 0.4989585 0.8313714 0.5359444 0.4495713 0.5367921 0.5094463 0.8280531
## [267] 0.6398537 0.5989197 0.5998401 0.4441699 0.5247057 0.6648501 0.4921523
## [274] 0.7610328 0.4129729 0.6272344 0.9417720 0.5031245 0.6115875 0.4921523
## [281] 0.7284794 0.4333672 0.6789953 0.5113840 0.4209902 0.4756576 0.4631110
## [288] 0.4782493 0.7798043 0.4814465 0.4462045 0.4668653 0.4657995 0.4165334
## [295] 0.5128615 0.8324129 0.6309645 0.6133314 0.5002907 0.6833551 0.4559173
## [302] 0.4143778 0.7918907 0.5368890 0.4537858 0.5043114 0.4653636 0.4844742
## [309] 0.6111515 0.6278642 0.4526474 0.6500751 0.6148089 0.4364676 0.5415879
## [316] 0.4476578 0.5085017 0.4184712 0.5225500 0.5291140 0.9077411 0.4886402
## [323] 0.4255438 0.5062491 0.6871094 0.5790583 0.4766749 0.5536986 0.4627719
## [330] 0.4825122 0.6336046 0.6065737 0.8415686 0.5601172 0.4622632 0.7067529
## [337] 0.6144698 0.5056436 0.5114809 0.4785157 0.4816887 0.5116262 0.4166788
## [344] 0.4839897 0.4954464 0.7459429 0.7183064 0.4642494 0.4784673 0.5678196
## [351] 0.4171632 0.8195030 0.4207237 0.4901904 0.4186649 0.4257375 0.4206511
## [358] 0.4478031 0.5541104 0.4854914 0.4137480 0.5279271 0.4877925 0.5120622
## [365] 0.4457928 0.4531318 0.4926367 0.9158310 0.7232718 0.5249237 0.6854866
## [372] 0.7063169 0.4699898
##
## $group
## [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [149] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [186] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [223] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [260] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [297] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [334] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [371] 1 1 1
##
## $names
## [1] "1"
box$stats
## [,1]
## [1,] 0.00000000
## [2,] 0.09020007
## [3,] 0.11899918
## [4,] 0.21917841
## [5,] 0.41212518
fivenum(college$aid_value)
## [1] 0.00000000 0.09020007 0.11899918 0.21917841 1.00000000
?fivenum#thanks Tukey!
#added this a predictor versus replacing the numeric version
(college_1h$aidvalue_f <- cut(college_1h$aid_value,c(-1,0.2191784,1),labels = c(0,1)))#why the NA? If we want two segments we input three numbers, start, cut and stop values
## [1] 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0
## [38] 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
## [75] 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0
## [112] 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## [149] 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 1 1 1 1 1
## [186] 1 1 1 1 0 1 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [223] 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 1
## [260] 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0
## [297] 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0
## [334] 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0
## [371] 1 1 0 1 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
## [3738] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [3775] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
## Levels: 0 1
?cut
View(college_1h)
#So no let's check the prevalence
(prevalence <- table(college_1h$aidvalue_f)[[2]]/length(college_1h$aidvalue_f))#we are using [[]] to pull at the second entry/column in the table
## [1] 0.2501975
table(college_1h$aidvalue_f)
##
## 0 1
## 2847 950
length(college_1h)
## [1] 11
# Training|Evaluation, Tune|Evaluation, Test|Evaluation
# Divide up our data into three parts, Training, Tuning, and Test
#There is not a easy way to create 3 partitions using the createDataPartitions
#so we are going to use it twice. Mostly because we want to stratify on the variable we are working to predict. What does that mean?
part_index_1 <- caret::createDataPartition(college_1h$aidvalue_f,
times=1,#number of splits
p = 0.70,#percentage of split
groups=1,
list=FALSE)
View(part_index_1)
dim(college_1h)
## [1] 3797 11
train <- college_1h[part_index_1,]#index the 70%
tune_and_test <- college_1h[-part_index_1, ]#index everything but the %70
#The we need to use the function again to create the tuning set
tune_and_test_index <- createDataPartition(tune_and_test$aidvalue_f,
p = .5,
list = FALSE,
times = 1)
tune <- tune_and_test[tune_and_test_index, ]
test <- tune_and_test[-tune_and_test_index, ]
dim(train)
## [1] 2658 11
dim(tune)
## [1] 570 11
dim(test)
## [1] 569 11
table(train$aidvalue_f)#check the prevalance
##
## 0 1
## 1993 665
table(test$aidvalue_f)
##
## 0 1
## 427 142
table(tune$aidvalue_f)# same as above
##
## 0 1
## 427 143
# Let's train the classifier for k = 9 using the class package.
# k-Nearest Neighbor is a randomized algorithm, so make sure to
# use set.seed() to make your results repeatable.
set.seed(1984)
college_9NN <- knn(train = train,#<- training set cases
test = tune, #<- tune set cases
cl = train$aidvalue_f,#<- category for true classification
k = 9,#<- number of neighbors considered
use.all = TRUE,
prob = TRUE)# provides the output in probabilities
# View the output.
str(college_9NN)
## Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## - attr(*, "prob")= num [1:570] 1 1 1 1 1 1 1 1 1 1 ...
table(college_9NN)
## college_9NN
## 0 1
## 427 143
table(tune$aidvalue_f)
##
## 0 1
## 427 143
college_9NN
## [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0
## [38] 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0
## [75] 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 0 1 0 1 0 1 0 0
## [112] 0 1 0 0 0 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0
## [149] 0 0 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 0 1 1 1 0 1 0 0
## [186] 0 0 1 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0
## [223] 1 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0
## [260] 0 0 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0
## [297] 0 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 1 0
## [334] 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0
## [371] 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1
## [408] 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1
## [445] 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [482] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [519] 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## [556] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## attr(,"prob")
## [1] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [8] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [15] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [22] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [29] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [36] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [43] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [50] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [64] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [71] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [78] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [85] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [92] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [99] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [106] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [113] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [120] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [127] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [134] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [141] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [148] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [155] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [162] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [169] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [176] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [183] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [190] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [197] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [204] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [211] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [218] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [225] 1.0000000 1.0000000 1.0000000 0.7777778 1.0000000 1.0000000 1.0000000
## [232] 1.0000000 1.0000000 1.0000000 0.7777778 1.0000000 1.0000000 1.0000000
## [239] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [246] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [253] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [260] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [267] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [274] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [281] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [288] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [295] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [302] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [309] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [316] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [323] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [330] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [337] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [344] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [351] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [358] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [365] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [372] 1.0000000 1.0000000 0.7777778 1.0000000 1.0000000 1.0000000 1.0000000
## [379] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [386] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [393] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [400] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [407] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [414] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [421] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [428] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [435] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [442] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [449] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [456] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [463] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [470] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [477] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [484] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [491] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [498] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [505] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [512] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [519] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [526] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [533] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [540] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [547] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.7777778
## [554] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [561] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## [568] 1.0000000 1.0000000 1.0000000
## Levels: 0 1
View(as.tibble(college_9NN))
## Warning: `as.tibble()` was deprecated in tibble 2.0.0.
## Please use `as_tibble()` instead.
## The signature and semantics have changed, see `?as_tibble`.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
View(as.tibble(attr(college_9NN,"prob")))
# How does the kNN classification compare to the true class?
# Let's take a look at the confusion matrix by combining the
# predictions from college_3NN to the original data set.
kNN_res = table(college_9NN,
tune$aidvalue_f)
kNN_res
##
## college_9NN 0 1
## 0 427 0
## 1 0 143
sum(kNN_res) #<- the total is all the test examples
## [1] 570
# Select the true positives and true negatives by selecting
# only the cells where the row and column names are the same.
kNN_res[row(kNN_res) == col(kNN_res)]#essentially the left to right diagonal
## [1] 427 143
# Calculate the accuracy rate by dividing the correct classifications
# by the total number of classifications.
kNN_acc = sum(kNN_res[row(kNN_res) == col(kNN_res)]) / sum(kNN_res)
kNN_acc
## [1] 1
# 99.82% accuracy rate is represented by this ML model.
confusionMatrix(as.factor(college_9NN), as.factor(tune$aidvalue_f), positive = "1", dnn=c("Prediction", "Actual"), mode = "sens_spec")
## Confusion Matrix and Statistics
##
## Actual
## Prediction 0 1
## 0 427 0
## 1 0 143
##
## Accuracy : 1
## 95% CI : (0.9935, 1)
## No Information Rate : 0.7491
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 1
##
## Mcnemar's Test P-Value : NA
##
## Sensitivity : 1.0000
## Specificity : 1.0000
## Pos Pred Value : 1.0000
## Neg Pred Value : 1.0000
## Prevalence : 0.2509
## Detection Rate : 0.2509
## Detection Prevalence : 0.2509
## Balanced Accuracy : 1.0000
##
## 'Positive' Class : 1
##
# So our ability to "predict" a student receiving financial aid over 0.2191784 is at roughly 99.82% so that's really solid. This means that out of 10 students, we classify 9ish correctly! Which is why in this case we would want to tune this model on TPR (Sensitivity), to get it has high as possible while sacrificing Specificity. I believe that if we were to reevaluate a similar data set with no columns that have overlap or any relatedness, our accuracy with this model may be lower.
#Reference for confusion matrix: https://www.rdocumentation.org/packages/caret/versions/6.0-86/topics/confusionMatrix
# How does "k" affect classification accuracy? Let's create a function
# to calculate classification accuracy based on the number of "k."
chooseK = function(k, train_set, val_set, train_class, val_class){
# Build knn with k neighbors considered.
set.seed(1)
class_knn = knn(train = train_set, #<- training set cases
test = val_set, #<- test set cases
cl = train_class, #<- category for classification
k = k, #<- number of neighbors considered
use.all = TRUE) #<- control ties between class assignments
# If true, all distances equal to the kth
# largest are included
conf_mat = table(class_knn, val_class)
# Calculate the accuracy.
accu = sum(conf_mat[row(conf_mat) == col(conf_mat)]) / sum(conf_mat)
cbind(k = k, accuracy = accu)
}
# The sapply() function plugs in several values into our chooseK function.
#sapply(x, fun...) "fun" here is passing a function to our k-function
# function(x)[function] allows you to apply a series of numbers
# to a function without running a for() loop! Returns a matrix.
knn_different_k = sapply(seq(1, 21, by = 2), #<- set k to be odd number from 1 to 21
function(x) chooseK(x,
train_set = train,
val_set = tune,
train_class = train$aidvalue_f,
val_class = tune$aidvalue_f))
View(knn_different_k)
#A bit more of a explanation...
seq(1,21, by=2)#just creates a series of numbers
## [1] 1 3 5 7 9 11 13 15 17 19 21
sapply(seq(1, 21, by=2), function(x) x+1)#sapply returns a new vector using the series of numbers and some calculation that is repeated over the vector of numbers
## [1] 2 4 6 8 10 12 14 16 18 20 22
# Reformatting the results to graph
View(knn_different_k)
class(knn_different_k)#matrix
## [1] "matrix" "array"
knn_different_k = tibble(k = knn_different_k[1,],
accuracy = knn_different_k[2,])
View(test)
View(knn_different_k)
# Plot accuracy vs. k.
ggplot(knn_different_k,
aes(x = k, y = accuracy)) +
geom_line(color = "orange", size = 1.5) +
geom_point(size = 3)
dev.off()
## null device
## 1
# After trying to optimize the k-value I ran into a few weird points. First off, for k-values of 1 - 7, the accuracy was 1.000, but from k-values of 9 - 21, the accuracy slightly decreased to 0.9964912. I found it weird that the model was perfectly accurate at low k values and decreased in accuracy as k-values got larger. Additionally, I learned that the reasoning behind this observation is that this can occur when several columns have a lot of overlap and are highly related to one another. Finally, I believe that a good k-value for this dataset would be 9, because it is not as overfitted as a k-value of 1 - 7.
str(college_9NN)
## Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## - attr(*, "prob")= num [1:570] 1 1 1 1 1 1 1 1 1 1 ...
college_prob_1 <- tibble(attr(college_9NN, "prob"))
View(college_prob_1)
final_model <- tibble(k_prob=college_prob_1$`attr(college_9NN, "prob")`,pred=college_9NN,target=tune$aidvalue_f)
View(final_model)
#Need to convert this to the likelihood to be in the poss class.
final_model$pos_prec <- ifelse(final_model$pred == 0, 1-final_model$k_prob, final_model$k_prob)
View(final_model)
#Needs to be a factor to be correctly
final_model$target <- as.factor(final_model$target)
densityplot(final_model$pos_prec)
#confusionMatrix from Caret package
confusionMatrix(final_model$pred, final_model$target, positive = "1", dnn=c("Prediction", "Actual"), mode = "sens_spec")
## Confusion Matrix and Statistics
##
## Actual
## Prediction 0 1
## 0 427 0
## 1 0 143
##
## Accuracy : 1
## 95% CI : (0.9935, 1)
## No Information Rate : 0.7491
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 1
##
## Mcnemar's Test P-Value : NA
##
## Sensitivity : 1.0000
## Specificity : 1.0000
## Pos Pred Value : 1.0000
## Neg Pred Value : 1.0000
## Prevalence : 0.2509
## Detection Rate : 0.2509
## Detection Prevalence : 0.2509
## Balanced Accuracy : 1.0000
##
## 'Positive' Class : 1
##
adjust_thres <- function(x, y, z) {
#x=pred_probablities, y=threshold, z=tune_outcome
thres <- as.factor(ifelse(x > y, 1,0))
confusionMatrix(thres, z, positive = "1", dnn=c("Prediction", "Actual"), mode = "everything")
}
str(final_model)
## tibble [570 × 4] (S3: tbl_df/tbl/data.frame)
## $ k_prob : num [1:570] 1 1 1 1 1 1 1 1 1 1 ...
## $ pred : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## ..- attr(*, "prob")= num [1:570] 1 1 1 1 1 1 1 1 1 1 ...
## $ target : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pos_prec: num [1:570] 0 0 0 0 0 0 0 0 0 0 ...
adjust_thres(final_model$pos_prec,.40,as.factor(final_model$target))
## Confusion Matrix and Statistics
##
## Actual
## Prediction 0 1
## 0 427 0
## 1 0 143
##
## Accuracy : 1
## 95% CI : (0.9935, 1)
## No Information Rate : 0.7491
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 1
##
## Mcnemar's Test P-Value : NA
##
## Sensitivity : 1.0000
## Specificity : 1.0000
## Pos Pred Value : 1.0000
## Neg Pred Value : 1.0000
## Precision : 1.0000
## Recall : 1.0000
## F1 : 1.0000
## Prevalence : 0.2509
## Detection Rate : 0.2509
## Detection Prevalence : 0.2509
## Balanced Accuracy : 1.0000
##
## 'Positive' Class : 1
##
# After graphing the density curve, it seems to be necessary to adjust the threshold to be 0.40 as it seems there are a decent amount of data values within that range of values.