## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:MASS':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
##      crim zn indus chas   nox    rm  age    dis rad tax ptratio  black lstat
## 1 0.00632 18  2.31    0 0.538 6.575 65.2 4.0900   1 296    15.3 396.90  4.98
## 2 0.02731  0  7.07    0 0.469 6.421 78.9 4.9671   2 242    17.8 396.90  9.14
## 3 0.02729  0  7.07    0 0.469 7.185 61.1 4.9671   2 242    17.8 392.83  4.03
## 4 0.03237  0  2.18    0 0.458 6.998 45.8 6.0622   3 222    18.7 394.63  2.94
## 5 0.06905  0  2.18    0 0.458 7.147 54.2 6.0622   3 222    18.7 396.90  5.33
## 6 0.02985  0  2.18    0 0.458 6.430 58.7 6.0622   3 222    18.7 394.12  5.21
##   medv
## 1 24.0
## 2 21.6
## 3 34.7
## 4 33.4
## 5 36.2
## 6 28.7
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## 
## Call:
## glm(formula = crime_factor ~ poly(rad, 3) + poly(nox, 3) + poly(tax, 
##     3) + poly(age, 3) + poly(dis, 3) + poly(indus, 3), family = "binomial", 
##     data = boston_training)
## 
## Coefficients:
##                   Estimate Std. Error    z value Pr(>|z|)    
## (Intercept)     -3.790e+14  3.339e+06 -113518879   <2e-16 ***
## poly(rad, 3)1    8.745e+16  4.751e+08  184071758   <2e-16 ***
## poly(rad, 3)2    8.225e+15  1.075e+08   76514466   <2e-16 ***
## poly(rad, 3)3    1.953e+15  7.773e+07   25122280   <2e-16 ***
## poly(nox, 3)1    1.888e+16  1.771e+08  106597240   <2e-16 ***
## poly(nox, 3)2    1.054e+15  1.016e+08   10377240   <2e-16 ***
## poly(nox, 3)3    2.177e+15  9.908e+07   21975041   <2e-16 ***
## poly(tax, 3)1   -6.941e+16  4.130e+08 -168075367   <2e-16 ***
## poly(tax, 3)2   -3.403e+16  1.859e+08 -183065250   <2e-16 ***
## poly(tax, 3)3    1.628e+16  8.421e+07  193318513   <2e-16 ***
## poly(age, 3)1   -1.028e+15  1.234e+08   -8335643   <2e-16 ***
## poly(age, 3)2    2.885e+15  7.958e+07   36254178   <2e-16 ***
## poly(age, 3)3    1.990e+15  7.152e+07   27820397   <2e-16 ***
## poly(dis, 3)1   -4.984e+15  1.606e+08  -31035200   <2e-16 ***
## poly(dis, 3)2    3.258e+15  9.902e+07   32900446   <2e-16 ***
## poly(dis, 3)3    1.957e+15  8.154e+07   23994946   <2e-16 ***
## poly(indus, 3)1  1.115e+16  1.411e+08   78989311   <2e-16 ***
## poly(indus, 3)2  4.318e+15  1.171e+08   36885916   <2e-16 ***
## poly(indus, 3)3  8.514e+15  1.210e+08   70376384   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance:  560.06  on 403  degrees of freedom
## Residual deviance: 2811.40  on 385  degrees of freedom
## AIC: 2849.4
## 
## Number of Fisher Scoring iterations: 25
## Loading required package: lattice
## Warning in confusionMatrix.default(predict_binary_glm$predicted_value,
## predict_binary_glm$actual_value): Levels are not in the same order for
## reference and data. Refactoring data to match.
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction Low High
##       Low   49    4
##       High   2   47
##                                           
##                Accuracy : 0.9412          
##                  95% CI : (0.8764, 0.9781)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.8824          
##                                           
##  Mcnemar's Test P-Value : 0.6831          
##                                           
##             Sensitivity : 0.9608          
##             Specificity : 0.9216          
##          Pos Pred Value : 0.9245          
##          Neg Pred Value : 0.9592          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4804          
##    Detection Prevalence : 0.5196          
##       Balanced Accuracy : 0.9412          
##                                           
##        'Positive' Class : Low             
## 
## Call:
## lda(crime_factor ~ poly(rad, 3) + poly(nox, 3) + poly(tax, 3) + 
##     poly(age, 3) + poly(dis, 3) + poly(indus, 3), data = boston_training)
## 
## Prior probabilities of groups:
##  Low High 
##  0.5  0.5 
## 
## Group means:
##      poly(rad, 3)1 poly(rad, 3)2 poly(rad, 3)3 poly(nox, 3)1 poly(nox, 3)2
## Low    -0.02986818    0.00527937   -0.00410086     -0.035856    0.01135621
## High    0.02986818   -0.00527937    0.00410086      0.035856   -0.01135621
##      poly(nox, 3)3 poly(tax, 3)1 poly(tax, 3)2 poly(tax, 3)3 poly(age, 3)1
## Low    0.003725802   -0.02961653   0.002564994 -0.0006208593   -0.03045625
## High  -0.003725802    0.02961653  -0.002564994  0.0006208593    0.03045625
##      poly(age, 3)2 poly(age, 3)3 poly(dis, 3)1 poly(dis, 3)2 poly(dis, 3)3
## Low   -0.009153263   0.001180473    0.02998473   -0.01131224    0.00113431
## High   0.009153263  -0.001180473   -0.02998473    0.01131224   -0.00113431
##      poly(indus, 3)1 poly(indus, 3)2 poly(indus, 3)3
## Low      -0.02966437      0.01012727      0.01050137
## High      0.02966437     -0.01012727     -0.01050137
## 
## Coefficients of linear discriminants:
##                         LD1
## poly(rad, 3)1    54.0984813
## poly(rad, 3)2     3.3023799
## poly(rad, 3)3     1.6940323
## poly(nox, 3)1    24.9539062
## poly(nox, 3)2    -9.7129156
## poly(nox, 3)3     0.9273337
## poly(tax, 3)1   -45.9158270
## poly(tax, 3)2   -20.7927520
## poly(tax, 3)3     9.3380422
## poly(age, 3)1     5.0154409
## poly(age, 3)2     5.0754930
## poly(age, 3)3     0.6445356
## poly(dis, 3)1     4.3726330
## poly(dis, 3)2    -2.6098746
## poly(dis, 3)3     4.6884000
## poly(indus, 3)1   7.0953914
## poly(indus, 3)2   8.0702091
## poly(indus, 3)3  -2.6227889

## New names:
## • `` -> `...1`
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction Low High
##       Low   46    1
##       High   5   50
##                                           
##                Accuracy : 0.9412          
##                  95% CI : (0.8764, 0.9781)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.8824          
##                                           
##  Mcnemar's Test P-Value : 0.2207          
##                                           
##             Sensitivity : 0.9020          
##             Specificity : 0.9804          
##          Pos Pred Value : 0.9787          
##          Neg Pred Value : 0.9091          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4510          
##    Detection Prevalence : 0.4608          
##       Balanced Accuracy : 0.9412          
##                                           
##        'Positive' Class : Low             
## 
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## 
## Attaching package: 'e1071'
## The following object is masked from 'package:rsample':
## 
##     permutations
## 
## Naive Bayes Classifier for Discrete Predictors
## 
## Call:
## naiveBayes.default(x = X, y = Y, laplace = laplace)
## 
## A-priori probabilities:
## Y
##  Low High 
##  0.5  0.5 
## 
## Conditional probabilities:
##       rad
## Y           [,1]     [,2]
##   Low   4.168317 1.645554
##   High 14.475248 9.592798
## 
##       nox
## Y           [,1]       [,2]
##   Low  0.4709698 0.05651158
##   High 0.6326337 0.09464589
## 
##       tax
## Y          [,1]      [,2]
##   Low  306.1089  83.91098
##   High 503.1485 168.82912
## 
##       age
## Y          [,1]     [,2]
##   Low  50.87376 24.98412
##   High 85.07129 18.87520
## 
##       indus
## Y           [,1]     [,2]
##   Low   6.998465 5.471512
##   High 15.143713 5.522585
## New names:
## • `` -> `...1`
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction Low High
##       Low   47   11
##       High   4   40
##                                           
##                Accuracy : 0.8529          
##                  95% CI : (0.7691, 0.9153)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : 8.267e-14       
##                                           
##                   Kappa : 0.7059          
##                                           
##  Mcnemar's Test P-Value : 0.1213          
##                                           
##             Sensitivity : 0.9216          
##             Specificity : 0.7843          
##          Pos Pred Value : 0.8103          
##          Neg Pred Value : 0.9091          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4608          
##    Detection Prevalence : 0.5686          
##       Balanced Accuracy : 0.8529          
##                                           
##        'Positive' Class : Low             
## 

## [1] Low  Low  Low  High Low  Low 
## Levels: Low High
## New names:
## • `` -> `...1`
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction Low High
##       Low   48    1
##       High   3   50
##                                           
##                Accuracy : 0.9608          
##                  95% CI : (0.9026, 0.9892)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.9216          
##                                           
##  Mcnemar's Test P-Value : 0.6171          
##                                           
##             Sensitivity : 0.9412          
##             Specificity : 0.9804          
##          Pos Pred Value : 0.9796          
##          Neg Pred Value : 0.9434          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4706          
##    Detection Prevalence : 0.4804          
##       Balanced Accuracy : 0.9608          
##                                           
##        'Positive' Class : Low             
## 
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## 
## Attaching package: 'ISLR2'
## The following object is masked _by_ '.GlobalEnv':
## 
##     Boston
## The following object is masked from 'package:MASS':
## 
##     Boston
## 
## Call:
## glm(formula = default ~ income + balance, family = "binomial", 
##     data = Default)
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -1.154e+01  4.348e-01 -26.545  < 2e-16 ***
## income       2.081e-05  4.985e-06   4.174 2.99e-05 ***
## balance      5.647e-03  2.274e-04  24.836  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 2920.6  on 9999  degrees of freedom
## Residual deviance: 1579.0  on 9997  degrees of freedom
## AIC: 1585
## 
## Number of Fisher Scoring iterations: 8
## [1] 0.0248
## [1] 0.0256
## [1] 0.0254
## [1] 0.0222
## [1] 0.0262
## [1] 1188.832
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## Loaded glmnet 4.1-9
## [1] 1539.344
## [1] 1539.344
## [1] 1497.048
## 19 x 1 sparse Matrix of class "dgCMatrix"
##                        s0
## (Intercept) -586.05287161
## (Intercept)    .         
## PrivateYes  -563.25598510
## Accept         1.21205847
## Enroll         .         
## Top10perc     35.58069720
## Top25perc     -6.29046439
## F.Undergrad    0.06094957
## P.Undergrad    .         
## Outstate      -0.03740620
## Room.Board     0.14301915
## Books          .         
## Personal       .         
## PhD           -4.28904039
## Terminal      -4.48542960
## S.F.Ratio      .         
## perc.alumni   -6.65372612
## Expend         0.07473866
## Grad.Rate      8.41829047
## 
## Attaching package: 'pls'
## The following object is masked from 'package:caret':
## 
##     R2
## The following object is masked from 'package:stats':
## 
##     loadings

## [1] NaN

## [1] NaN
## Warning in mean.default(y): argument is not numeric or logical: returning NA
## Warning in mean.default(y): argument is not numeric or logical: returning NA
## Warning in mean.default(y): argument is not numeric or logical: returning NA
## Warning in mean.default(y): argument is not numeric or logical: returning NA
## Warning in mean.default(y): argument is not numeric or logical: returning NA

## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning in install.packages("ISLR", repos = "https://cloud.r-project.org"):
## installation of package 'ISLR' had non-zero exit status
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning in install.packages("ISLR"): installation of package 'ISLR' had
## non-zero exit status
## [1] "R version 4.4.3 (2025-02-28)"
## Warning: package 'cluster' in library '/opt/R/4.4.3/lib/R/library' will not be
## updated
## Warning: package 'foreign' in library '/opt/R/4.4.3/lib/R/library' will not be
## updated
## Warning: package 'lattice' in library '/opt/R/4.4.3/lib/R/library' will not be
## updated
## Warning: package 'MASS' in library '/opt/R/4.4.3/lib/R/library' will not be
## updated
## Warning: package 'Matrix' in library '/opt/R/4.4.3/lib/R/library' will not be
## updated
## Warning: package 'mgcv' in library '/opt/R/4.4.3/lib/R/library' will not be
## updated
## Warning: package 'nlme' in library '/opt/R/4.4.3/lib/R/library' will not be
## updated
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Downloading GitHub repo cran/ISLR@HEAD
## Running `R CMD build`...
## * checking for file ‘/tmp/RtmpfWz520/remotes1da110b5669/cran-ISLR-b72e0ce/DESCRIPTION’ ... OK
## * preparing ‘ISLR’:
## * checking DESCRIPTION meta-information ... OK
## * checking for LF line-endings in source and make files and shell scripts
## * checking for empty or unneeded directories
## * building ‘ISLR_1.4.tar.gz’
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning in i.p(...): installation of package
## '/tmp/RtmpfWz520/file1da77b6cfa2/ISLR_1.4.tar.gz' had non-zero exit status
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## system (cmd0): /opt/R/4.4.3/lib/R/bin/R CMD INSTALL
## foundpkgs: ISLR, /tmp/RtmpfWz520/downloaded_packages/ISLR_1.4.tar.gz
## files: /tmp/RtmpfWz520/downloaded_packages/ISLR_1.4.tar.gz
## Warning in install.packages("ISLR", verbose = TRUE): installation of package
## 'ISLR' had non-zero exit status
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning in install.packages("ISLR", repos = "https://cloud.r-project.org"):
## installation of package 'ISLR' had non-zero exit status
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)