Observation
- Cubist with committees = 25 and neighbors = 3 is top model
- Finalize by creating stand alone Cubist model
# prepare data transform using training data
library(Cubist)
set.seed(7)
x <- dataset[,1:13]
y <- dataset[,14]
preprocessParams <- preProcess(x, method=c("BoxCox"))
transX <- predict(preprocessParams, x)
# train the final model
finalModel <- cubist(x=transX, y=y, committees=25)
summary(finalModel)
##
## Call:
## cubist.default(x = transX, y = y, committees = 25)
##
##
## Cubist [Release 2.07 GPL Edition] Sat Sep 19 15:10:22 2020
## ---------------------------------
##
## Target attribute `outcome'
##
## Read 407 cases (14 attributes) from undefined.data
##
## Model 1:
##
## Rule 1/1: [84 cases, mean 14.29, range 5 to 27.5, est err 1.97]
##
## if
## nox > -0.4864544
## then
## outcome = 35.08 - 2.45 crim - 4.31 lstat + 2.1e-005 b
##
## Rule 1/2: [163 cases, mean 19.37, range 7 to 31, est err 2.10]
##
## if
## nox <= -0.4864544
## lstat > 2.848535
## then
## outcome = 186.8 - 2.34 lstat - 3.3 dis - 88 tax + 2 rad + 4.4 rm
## - 0.033 ptratio - 0.0116 age + 3.3e-005 b
##
## Rule 1/3: [24 cases, mean 21.65, range 18.2 to 25.3, est err 1.19]
##
## if
## rm <= 3.326479
## dis > 1.345056
## lstat <= 2.848535
## then
## outcome = 43.83 + 14.5 rm - 2.29 lstat - 3.8 dis - 30 tax
## - 0.014 ptratio - 1.4 nox + 0.017 zn + 0.4 rad + 0.15 crim
## - 0.0025 age + 8e-006 b
##
## Rule 1/4: [7 cases, mean 27.66, range 20.7 to 50, est err 7.89]
##
## if
## rm > 3.326479
## ptratio > 193.545
## lstat <= 2.848535
## then
## outcome = 19.64 + 7.8 rm - 3.4 dis - 1.62 lstat + 0.27 crim - 0.006 age
## + 0.023 zn - 7 tax - 0.003 ptratio
##
## Rule 1/5: [141 cases, mean 30.60, range 15 to 50, est err 2.09]
##
## if
## rm > 3.326479
## ptratio <= 193.545
## then
## outcome = 137.95 + 21.7 rm - 3.43 lstat - 4.9 dis - 87 tax - 0.0162 age
## - 0.039 ptratio + 0.06 crim + 0.005 zn
##
## Rule 1/6: [8 cases, mean 32.16, range 22.1 to 50, est err 8.67]
##
## if
## rm <= 3.326479
## dis <= 1.345056
## lstat <= 2.848535
## then
## outcome = -19.71 + 18.58 lstat - 15.9 dis + 5.6 rm
##
## Model 2:
##
## Rule 2/1: [23 cases, mean 10.57, range 5 to 15, est err 3.06]
##
## if
## crim > 2.086391
## dis <= 0.6604174
## b > 67032.41
## then
## outcome = 37.22 - 4.83 crim - 7 dis - 1.9 lstat - 1.9e-005 b - 0.7 rm
##
## Rule 2/2: [70 cases, mean 14.82, range 5 to 50, est err 3.90]
##
## if
## rm <= 3.620525
## dis <= 0.6604174
## then
## outcome = 74.6 - 21 dis - 5.09 lstat - 15 tax - 0.0017 age + 6e-006 b
##
## Rule 2/3: [18 cases, mean 18.03, range 7.5 to 50, est err 6.81]
##
## if
## crim > 2.086391
## dis <= 0.6604174
## b <= 67032.41
## then
## outcome = 94.95 - 40.1 dis - 8.15 crim - 7.14 lstat - 3.5e-005 b
## - 1.3 rm
##
## Rule 2/4: [258 cases, mean 20.74, range 9.5 to 36.2, est err 1.92]
##
## if
## rm <= 3.620525
## dis > 0.6604174
## lstat > 1.805082
## then
## outcome = 61.89 - 2.56 lstat + 5.5 rm - 2.8 dis + 7.3e-005 b
## - 0.0132 age - 26 tax - 0.11 indus - 0.004 ptratio + 0.05 crim
##
## Rule 2/5: [37 cases, mean 31.66, range 10.4 to 50, est err 3.70]
##
## if
## rm > 3.620525
## lstat > 1.805082
## then
## outcome = 370.03 - 180 tax - 2.19 lstat - 1.7 dis + 2.6 rm
## - 0.016 ptratio - 0.25 indus + 0.12 crim - 0.0021 age
## + 9e-006 b - 0.5 nox
##
## Rule 2/6: [42 cases, mean 38.23, range 22.8 to 50, est err 3.70]
##
## if
## lstat <= 1.805082
## then
## outcome = -73.87 + 32.4 rm - 9.4e-005 b - 1.8 dis + 0.028 zn
## - 0.013 ptratio
##
## Rule 2/7: [4 cases, mean 40.20, range 37.6 to 42.8, est err 7.33]
##
## if
## rm > 4.151791
## dis > 1.114486
## then
## outcome = 35.8
##
## Rule 2/8: [8 cases, mean 47.45, range 41.3 to 50, est err 10.01]
##
## if
## dis <= 1.114486
## lstat <= 1.805082
## then
## outcome = 48.96 + 7.53 crim - 4.1e-005 b - 0.8 dis + 1.2 rm + 0.008 zn
##
## Model 3:
##
## Rule 3/1: [81 cases, mean 13.93, range 5 to 23.2, est err 2.24]
##
## if
## nox > -0.4864544
## lstat > 2.848535
## then
## outcome = 55.03 - 0.0631 age - 2.11 crim + 12 nox - 4.16 lstat
## + 3.2e-005 b
##
## Rule 3/2: [163 cases, mean 19.37, range 7 to 31, est err 2.29]
##
## if
## nox <= -0.4864544
## lstat > 2.848535
## then
## outcome = 77.73 - 0.059 ptratio + 5.8 rm - 3.2 dis - 0.0139 age
## - 1.15 lstat - 30 tax - 1.1 nox + 0.4 rad
##
## Rule 3/3: [62 cases, mean 24.01, range 18.2 to 50, est err 3.56]
##
## if
## rm <= 3.448196
## lstat <= 2.848535
## then
## outcome = 94.86 + 18.2 rm + 0.63 crim - 68 tax - 2.3 dis - 3 nox
## - 0.0098 age - 0.41 indus - 0.011 ptratio
##
## Rule 3/4: [143 cases, mean 28.76, range 16.5 to 50, est err 2.53]
##
## if
## dis > 0.9547035
## lstat <= 2.848535
## then
## outcome = 269.46 + 17.9 rm - 6.1 dis - 153 tax + 0.96 crim - 0.0217 age
## - 5.5 nox - 0.62 indus - 0.028 ptratio - 0.89 lstat + 0.4 rad
## + 0.004 zn
##
## Rule 3/5: [10 cases, mean 35.13, range 21.9 to 50, est err 9.31]
##
## if
## dis <= 0.6492998
## lstat <= 2.848535
## then
## outcome = 58.69 - 56.8 dis - 8.4 nox
##
## Rule 3/6: [10 cases, mean 41.67, range 22 to 50, est err 9.89]
##
## if
## dis > 0.6492998
## dis <= 0.9547035
## lstat <= 2.848535
## then
## outcome = 47.93
##
## Model 4:
##
## Rule 4/1: [69 cases, mean 12.69, range 5 to 27.5, est err 2.55]
##
## if
## dis <= 0.719156
## lstat > 3.508535
## then
## outcome = 180.13 - 7.2 dis + 0.039 age - 3.78 lstat - 83 tax
##
## Rule 4/2: [164 cases, mean 19.42, range 12 to 31, est err 1.96]
##
## if
## dis > 0.719156
## lstat > 2.848535
## then
## outcome = 52.75 + 7.1 rm - 2.05 lstat - 3.6 dis + 8.2e-005 b
## - 0.0152 age - 25 tax + 0.5 rad - 1.2 nox - 0.008 ptratio
##
## Rule 4/3: [11 cases, mean 20.39, range 15 to 27.9, est err 3.51]
##
## if
## dis <= 0.719156
## lstat > 2.848535
## lstat <= 3.508535
## then
## outcome = 21.69
##
## Rule 4/4: [63 cases, mean 23.22, range 16.5 to 31.5, est err 1.67]
##
## if
## rm <= 3.483629
## dis > 0.9731624
## lstat <= 2.848535
## then
## outcome = 59.35 - 3.96 lstat - 3.1 dis + 1 rm - 14 tax + 0.3 rad
## - 0.7 nox - 0.005 ptratio + 6e-006 b
##
## Rule 4/5: [8 cases, mean 33.08, range 22 to 50, est err 23.91]
##
## if
## rm > 3.369183
## dis <= 0.9731624
## lstat > 2.254579
## lstat <= 2.848535
## then
## outcome = -322.28 + 64.9 lstat + 56.8 rm - 30.2 dis
##
## Rule 4/6: [7 cases, mean 33.87, range 22.1 to 50, est err 13.21]
##
## if
## rm <= 3.369183
## dis <= 0.9731624
## lstat <= 2.848535
## then
## outcome = -52.11 + 43.45 lstat - 30.8 dis
##
## Rule 4/7: [91 cases, mean 34.43, range 21.9 to 50, est err 3.32]
##
## if
## rm > 3.483629
## lstat <= 2.848535
## then
## outcome = -33.09 + 22 rm - 5.02 lstat - 0.038 ptratio - 0.9 dis
## + 0.005 zn
##
## Rule 4/8: [22 cases, mean 36.99, range 21.9 to 50, est err 13.21]
##
## if
## dis <= 0.9731624
## lstat <= 2.848535
## then
## outcome = 80.3 - 17.43 lstat - 0.134 ptratio + 2.5 rm - 1.2 dis
## + 0.008 zn
##
## Model 5:
##
## Rule 5/1: [84 cases, mean 14.29, range 5 to 27.5, est err 2.81]
##
## if
## nox > -0.4864544
## then
## outcome = 56.48 + 28.5 nox - 0.0875 age - 3.58 crim - 5.9 dis
## - 2.96 lstat + 0.073 ptratio + 1.7e-005 b
##
## Rule 5/2: [163 cases, mean 19.37, range 7 to 31, est err 2.38]
##
## if
## nox <= -0.4864544
## lstat > 2.848535
## then
## outcome = 61.59 - 0.064 ptratio + 5.9 rm - 3.1 dis - 0.0142 age
## - 0.77 lstat - 21 tax
##
## Rule 5/3: [163 cases, mean 29.94, range 16.5 to 50, est err 3.65]
##
## if
## lstat <= 2.848535
## then
## outcome = 264.17 + 21.9 rm - 8 dis - 155 tax - 0.0317 age
## - 0.032 ptratio + 0.29 crim - 1.6 nox - 0.25 indus
##
## Rule 5/4: [10 cases, mean 35.13, range 21.9 to 50, est err 11.79]
##
## if
## dis <= 0.6492998
## lstat <= 2.848535
## then
## outcome = 68.19 - 73.4 dis + 1.1 rm + 0.11 crim - 0.6 nox - 0.1 indus
## - 0.0017 age - 0.12 lstat
##
## Model 6:
##
## Rule 6/1: [71 cases, mean 15.57, range 5 to 50, est err 4.42]
##
## if
## dis <= 0.6443245
## lstat > 1.793385
## then
## outcome = 45.7 - 20.6 dis - 5.38 lstat
##
## Rule 6/2: [159 cases, mean 19.53, range 8.3 to 36.2, est err 2.08]
##
## if
## rm <= 3.329365
## dis > 0.6443245
## then
## outcome = 24.33 + 8.8 rm + 0.000118 b - 0.0146 age - 2.5 dis
## - 0.95 lstat + 0.37 crim - 0.32 indus + 0.02 zn - 16 tax
## + 0.2 rad - 0.5 nox - 0.004 ptratio
##
## Rule 6/3: [175 cases, mean 27.80, range 9.5 to 50, est err 2.95]
##
## if
## rm > 3.329365
## dis > 0.6443245
## then
## outcome = 0.11 + 18.7 rm - 3.11 lstat + 8.1e-005 b - 1.1 dis + 0.19 crim
## - 20 tax - 0.19 indus + 0.3 rad - 0.7 nox - 0.005 ptratio
## + 0.006 zn
##
## Rule 6/4: [8 cases, mean 32.50, range 21.9 to 50, est err 10.34]
##
## if
## dis <= 0.6443245
## lstat > 1.793385
## lstat <= 2.894121
## then
## outcome = 69.38 - 71.2 dis - 0.14 lstat
##
## Rule 6/5: [34 cases, mean 37.55, range 22.8 to 50, est err 3.55]
##
## if
## rm <= 4.151791
## lstat <= 1.793385
## then
## outcome = -125.14 + 41.7 rm + 4.3 rad + 1.48 indus - 0.014 ptratio
##
## Rule 6/6: [7 cases, mean 43.66, range 37.6 to 50, est err 3.12]
##
## if
## rm > 4.151791
## lstat <= 1.793385
## then
## outcome = -137.67 + 44.6 rm - 0.064 ptratio
##
## Model 7:
##
## Rule 7/1: [84 cases, mean 14.29, range 5 to 27.5, est err 2.91]
##
## if
## nox > -0.4864544
## then
## outcome = 46.85 - 3.45 crim - 0.0621 age + 14.2 nox + 4.4 dis
## - 2.01 lstat + 2.5e-005 b
##
## Rule 7/2: [323 cases, mean 24.66, range 7 to 50, est err 3.68]
##
## if
## nox <= -0.4864544
## then
## outcome = 57.59 - 0.065 ptratio - 4.4 dis + 6.8 rm - 0.0143 age
## - 1.36 lstat - 19 tax - 0.8 nox - 0.12 crim + 0.09 indus
##
## Rule 7/3: [132 cases, mean 28.24, range 16.5 to 50, est err 2.55]
##
## if
## dis > 1.063503
## lstat <= 2.848535
## then
## outcome = 270.92 + 24.5 rm - 0.0418 age - 165 tax - 5.7 dis
## - 0.028 ptratio + 0.26 crim + 0.017 zn
##
## Rule 7/4: [7 cases, mean 36.01, range 23.3 to 50, est err 3.87]
##
## if
## dis <= 0.6002641
## lstat <= 2.848535
## then
## outcome = 57.18 - 69.5 dis - 6.5 nox + 1.9 rm - 0.015 ptratio
##
## Rule 7/5: [24 cases, mean 37.55, range 21.9 to 50, est err 8.66]
##
## if
## dis > 0.6002641
## dis <= 1.063503
## lstat <= 2.848535
## then
## outcome = -3.76 - 14.8 dis - 2.93 crim - 0.16 ptratio + 17.5 rm - 15 nox
##
## Model 8:
##
## Rule 8/1: [80 cases, mean 13.75, range 5 to 27.9, est err 3.51]
##
## if
## dis <= 0.719156
## lstat > 2.848535
## then
## outcome = 123.46 - 11.3 dis - 5.06 lstat - 45 tax + 0.9 rad + 1.7e-005 b
##
## Rule 8/2: [164 cases, mean 19.42, range 12 to 31, est err 2.05]
##
## if
## dis > 0.719156
## lstat > 2.848535
## then
## outcome = 227.11 - 120 tax + 6.4 rm + 9.3e-005 b - 3.3 dis + 2 rad
## - 0.0183 age - 0.93 lstat + 0.05 crim - 0.3 nox
##
## Rule 8/3: [163 cases, mean 29.94, range 16.5 to 50, est err 3.54]
##
## if
## lstat <= 2.848535
## then
## outcome = 158.14 - 5.73 lstat + 10.8 rm - 4 dis - 83 tax - 4.1 nox
## + 0.61 crim - 0.54 indus + 1 rad + 3.6e-005 b
##
## Rule 8/4: [7 cases, mean 36.01, range 23.3 to 50, est err 11.44]
##
## if
## dis <= 0.6002641
## lstat <= 2.848535
## then
## outcome = 72.89 - 87.2 dis + 0.6 rm - 0.13 lstat
##
## Rule 8/5: [47 cases, mean 38.44, range 15 to 50, est err 5.71]
##
## if
## rm > 3.726352
## then
## outcome = 602.95 - 10.4 lstat + 21 rm - 326 tax - 0.093 ptratio
##
## Model 9:
##
## Rule 9/1: [81 cases, mean 13.93, range 5 to 23.2, est err 2.91]
##
## if
## nox > -0.4864544
## lstat > 2.848535
## then
## outcome = 41.11 - 3.98 crim - 4.42 lstat + 6.7 nox
##
## Rule 9/2: [163 cases, mean 19.37, range 7 to 31, est err 2.49]
##
## if
## nox <= -0.4864544
## lstat > 2.848535
## then
## outcome = 44.98 - 0.068 ptratio - 4.4 dis + 6.6 rm - 1.25 lstat
## - 0.0118 age - 0.9 nox - 12 tax - 0.08 crim + 0.06 indus
##
## Rule 9/3: [132 cases, mean 28.24, range 16.5 to 50, est err 2.35]
##
## if
## dis > 1.063503
## lstat <= 2.848535
## then
## outcome = 157.67 + 22.2 rm - 0.0383 age - 104 tax - 0.033 ptratio
## - 2.2 dis
##
## Rule 9/4: [7 cases, mean 30.76, range 21.9 to 50, est err 6.77]
##
## if
## dis <= 1.063503
## b <= 66469.73
## lstat <= 2.848535
## then
## outcome = 48.52 - 56.1 dis - 12.9 nox - 0.032 ptratio + 2.7 rm
##
## Rule 9/5: [24 cases, mean 39.09, range 22 to 50, est err 6.20]
##
## if
## dis <= 1.063503
## b > 66469.73
## lstat <= 2.848535
## then
## outcome = -5.49 - 34.8 dis - 20.7 nox + 18.2 rm - 0.051 ptratio
##
## Model 10:
##
## Rule 10/1: [327 cases, mean 19.45, range 5 to 50, est err 2.77]
##
## if
## rm <= 3.617282
## lstat > 1.805082
## then
## outcome = 270.78 - 4.09 lstat - 131 tax + 2.9 rad + 5.3e-005 b - 0.6 dis
## - 0.16 indus + 0.7 rm - 0.3 nox
##
## Rule 10/2: [38 cases, mean 31.57, range 10.4 to 50, est err 4.71]
##
## if
## rm > 3.617282
## lstat > 1.805082
## then
## outcome = 308.44 - 150 tax - 2.63 lstat + 1.6 rad - 1.9 dis - 0.49 indus
## + 2.5 rm + 3e-005 b - 1.2 nox + 0.14 crim - 0.005 ptratio
##
## Rule 10/3: [35 cases, mean 37.15, range 22.8 to 50, est err 2.76]
##
## if
## rm <= 4.151791
## lstat <= 1.805082
## then
## outcome = -71.65 + 33.4 rm - 0.017 ptratio - 0.34 lstat + 0.2 rad
## - 0.3 dis - 7 tax - 0.4 nox
##
## Rule 10/4: [10 cases, mean 42.63, range 21.9 to 50, est err 7.11]
##
## if
## rm > 4.151791
## then
## outcome = -92.51 + 32.8 rm - 0.03 ptratio
##
## Model 11:
##
## Rule 11/1: [84 cases, mean 14.29, range 5 to 27.5, est err 4.13]
##
## if
## nox > -0.4864544
## then
## outcome = 42.75 - 4.12 crim + 18.1 nox - 0.045 age + 6.8 dis
## - 1.86 lstat
##
## Rule 11/2: [244 cases, mean 17.56, range 5 to 31, est err 4.29]
##
## if
## lstat > 2.848535
## then
## outcome = 34.83 - 5.2 dis - 0.058 ptratio - 0.0228 age + 5.8 rm
## - 0.56 lstat - 0.07 crim - 0.4 nox - 5 tax
##
## Rule 11/3: [163 cases, mean 29.94, range 16.5 to 50, est err 3.49]
##
## if
## lstat <= 2.848535
## then
## outcome = 151.5 + 23.3 rm - 5.5 dis + 1.01 crim - 0.0211 age
## - 0.052 ptratio - 98 tax + 0.031 zn
##
## Rule 11/4: [10 cases, mean 35.13, range 21.9 to 50, est err 25.19]
##
## if
## dis <= 0.6492998
## lstat <= 2.848535
## then
## outcome = 130.87 - 157.1 dis - 15.76 crim
##
## Model 12:
##
## Rule 12/1: [80 cases, mean 13.75, range 5 to 27.9, est err 4.76]
##
## if
## dis <= 0.719156
## lstat > 2.894121
## then
## outcome = 182.68 - 6.03 lstat - 7.6 dis - 76 tax + 1.3 rad - 0.52 indus
## + 2.6e-005 b
##
## Rule 12/2: [300 cases, mean 19.10, range 5 to 50, est err 2.76]
##
## if
## rm <= 3.50716
## lstat > 1.793385
## then
## outcome = 83.61 - 3 lstat + 9.6e-005 b - 0.0072 age - 33 tax + 0.7 rad
## + 0.32 indus
##
## Rule 12/3: [10 cases, mean 24.25, range 15.7 to 36.2, est err 13.88]
##
## if
## rm <= 3.50716
## tax <= 1.865769
## then
## outcome = 35.46
##
## Rule 12/4: [10 cases, mean 32.66, range 21.9 to 50, est err 6.28]
##
## if
## dis <= 0.719156
## lstat > 1.793385
## lstat <= 2.894121
## then
## outcome = 82.78 - 69.5 dis - 3.66 indus
##
## Rule 12/5: [89 cases, mean 32.75, range 13.4 to 50, est err 3.39]
##
## if
## rm > 3.50716
## dis > 0.719156
## then
## outcome = 313.22 + 13.7 rm - 174 tax - 3.06 lstat + 4.8e-005 b - 1.5 dis
## - 0.41 indus + 0.7 rad - 0.0055 age + 0.22 crim
##
## Rule 12/6: [34 cases, mean 37.55, range 22.8 to 50, est err 3.25]
##
## if
## rm <= 4.151791
## lstat <= 1.793385
## then
## outcome = -86.8 + 36 rm - 0.3 lstat - 5 tax
##
## Rule 12/7: [7 cases, mean 43.66, range 37.6 to 50, est err 5.79]
##
## if
## rm > 4.151791
## lstat <= 1.793385
## then
## outcome = -158.68 + 47.4 rm - 0.02 ptratio
##
## Model 13:
##
## Rule 13/1: [84 cases, mean 14.29, range 5 to 27.5, est err 2.87]
##
## if
## nox > -0.4864544
## then
## outcome = 54.69 - 3.79 crim - 0.0644 age + 11.4 nox - 2.53 lstat
##
## Rule 13/2: [8 cases, mean 17.76, range 7 to 27.9, est err 13.69]
##
## if
## nox <= -0.4864544
## age > 296.3423
## b <= 60875.57
## then
## outcome = -899.55 + 3.0551 age
##
## Rule 13/3: [31 cases, mean 17.94, range 7 to 27.9, est err 5.15]
##
## if
## nox <= -0.4864544
## b <= 60875.57
## lstat > 2.848535
## then
## outcome = 44.43 - 3.51 lstat - 0.054 ptratio - 1.4 dis - 0.26 crim
## - 0.0042 age - 0.21 indus + 0.9 rm
##
## Rule 13/4: [163 cases, mean 19.37, range 7 to 31, est err 3.37]
##
## if
## nox <= -0.4864544
## lstat > 2.848535
## then
## outcome = -5.76 + 0.000242 b + 8.9 rm - 5.2 dis - 0.0209 age
## - 0.042 ptratio - 0.63 indus
##
## Rule 13/5: [163 cases, mean 29.94, range 16.5 to 50, est err 3.45]
##
## if
## lstat <= 2.848535
## then
## outcome = 178.84 + 23.8 rm - 0.0343 age - 4.5 dis - 114 tax + 0.88 crim
## - 0.048 ptratio + 0.026 zn
##
## Rule 13/6: [7 cases, mean 36.01, range 23.3 to 50, est err 14.09]
##
## if
## dis <= 0.6002641
## lstat <= 2.848535
## then
## outcome = 45.82 - 70.3 dis - 9.9 nox + 5.1 rm + 1.5 rad
##
## Rule 13/7: [31 cases, mean 37.21, range 21.9 to 50, est err 7.73]
##
## if
## dis <= 1.063503
## lstat <= 2.848535
## then
## outcome = 95.05 - 4.52 lstat - 7.5 dis + 8.8 rm - 0.064 ptratio
## - 6.2 nox - 36 tax
##
## Model 14:
##
## Rule 14/1: [49 cases, mean 16.06, range 8.4 to 22.7, est err 3.17]
##
## if
## nox > -0.4205732
## lstat > 2.848535
## then
## outcome = 12.83 + 42.3 nox - 4.77 lstat + 9.7 rm + 7.8e-005 b
##
## Rule 14/2: [78 cases, mean 16.36, range 5 to 50, est err 5.17]
##
## if
## dis <= 0.6604174
## then
## outcome = 110.6 - 10.4 dis - 4.85 lstat + 0.0446 age - 46 tax + 0.8 rad
##
## Rule 14/3: [57 cases, mean 18.40, range 9.5 to 31, est err 2.43]
##
## if
## nox > -0.9365134
## nox <= -0.4205732
## age > 245.2507
## dis > 0.6604174
## lstat > 2.848535
## then
## outcome = 206.69 - 0.1012 age - 7.05 lstat + 12.2 nox - 67 tax + 0.3 rad
## + 0.5 rm - 0.3 dis
##
## Rule 14/4: [230 cases, mean 20.19, range 9.5 to 36.2, est err 2.09]
##
## if
## rm <= 3.483629
## dis > 0.6492998
## then
## outcome = 119.15 - 2.61 lstat + 5.2 rm - 57 tax - 1.8 dis - 2.4 nox
## + 0.7 rad + 0.24 crim + 0.003 age - 0.007 ptratio + 9e-006 b
##
## Rule 14/5: [48 cases, mean 20.28, range 10.2 to 24.5, est err 2.13]
##
## if
## nox > -0.9365134
## nox <= -0.4205732
## age <= 245.2507
## dis > 0.6604174
## lstat > 2.848535
## then
## outcome = 19.4 - 1.91 lstat + 1.02 indus - 0.013 age + 2.7 rm + 2.6 nox
## - 0.009 ptratio
##
## Rule 14/6: [44 cases, mean 20.69, range 14.4 to 29.6, est err 2.26]
##
## if
## nox <= -0.9365134
## lstat > 2.848535
## then
## outcome = 87.55 - 0.000315 b - 6.5 dis + 2.6 rad - 0.59 lstat - 18 tax
##
## Rule 14/7: [102 cases, mean 32.44, range 13.4 to 50, est err 3.35]
##
## if
## rm > 3.483629
## dis > 0.6492998
## then
## outcome = 126.92 + 22.7 rm - 4.68 lstat - 85 tax - 0.036 ptratio
## - 1.1 dis + 0.007 zn
##
## Rule 14/8: [84 cases, mean 33.40, range 21 to 50, est err 2.44]
##
## if
## rm > 3.483629
## tax <= 1.896025
## then
## outcome = 347.12 + 25.2 rm - 213 tax - 3.5 lstat - 0.013 ptratio
##
## Rule 14/9: [10 cases, mean 35.13, range 21.9 to 50, est err 12.13]
##
## if
## dis <= 0.6492998
## lstat <= 2.848535
## then
## outcome = 72.65 - 77.8 dis
##
## Model 15:
##
## Rule 15/1: [28 cases, mean 12.35, range 5 to 27.9, est err 4.09]
##
## if
## crim > 2.405809
## b > 16084.5
## then
## outcome = 53.45 - 7.8 crim - 3.5 lstat - 0.0189 age
##
## Rule 15/2: [11 cases, mean 13.56, range 8.3 to 27.5, est err 5.99]
##
## if
## crim > 2.405809
## b <= 16084.5
## then
## outcome = 8.73 + 0.001756 b
##
## Rule 15/3: [244 cases, mean 17.56, range 5 to 31, est err 2.73]
##
## if
## lstat > 2.848535
## then
## outcome = 103.02 - 0.0251 age - 2.37 lstat - 3.5 dis + 6.8e-005 b + 4 rm
## - 0.035 ptratio - 41 tax - 0.25 crim
##
## Rule 15/4: [131 cases, mean 28.22, range 16.5 to 50, est err 2.59]
##
## if
## dis > 1.086337
## lstat <= 2.848535
## then
## outcome = 267.07 + 17.7 rm - 0.0421 age - 150 tax - 5.5 dis + 0.88 crim
## - 0.035 ptratio + 0.031 zn - 0.12 lstat - 0.3 nox
##
## Rule 15/5: [13 cases, mean 33.08, range 22 to 50, est err 4.44]
##
## if
## nox <= -0.7229691
## dis <= 1.086337
## lstat <= 2.848535
## then
## outcome = 148.52 - 0.002365 b - 85.9 nox - 1 dis + 0.16 crim + 0.8 rm
## + 0.007 zn - 0.0016 age - 7 tax - 0.003 ptratio
##
## Rule 15/6: [7 cases, mean 36.01, range 23.3 to 50, est err 7.00]
##
## if
## dis <= 0.6002641
## lstat <= 2.848535
## then
## outcome = 50.55 - 68.1 dis - 11.4 nox + 0.00012 b + 1 rm - 0.008 ptratio
##
## Rule 15/7: [12 cases, mean 41.77, range 21.9 to 50, est err 9.73]
##
## if
## nox > -0.7229691
## dis > 0.6002641
## lstat <= 2.848535
## then
## outcome = 13.74 - 92 nox - 40.5 dis - 0.023 ptratio + 2.6 rm
##
## Model 16:
##
## Rule 16/1: [60 cases, mean 15.95, range 7.2 to 27.5, est err 3.16]
##
## if
## nox > -0.4344906
## then
## outcome = 46.98 - 6.53 lstat - 6.9 dis - 1.1 rm
##
## Rule 16/2: [45 cases, mean 16.89, range 5 to 50, est err 5.45]
##
## if
## nox <= -0.4344906
## dis <= 0.6557049
## then
## outcome = 35.33 - 37 dis - 51.7 nox - 7.38 lstat - 0.4 rm
##
## Rule 16/3: [128 cases, mean 19.97, range 9.5 to 36.2, est err 2.52]
##
## if
## rm <= 3.626081
## dis > 0.6557049
## dis <= 1.298828
## lstat > 2.133251
## then
## outcome = 61.65 - 3.35 lstat + 4.9 dis + 1.6 rm - 1.3 nox - 22 tax
## + 0.5 rad + 1.8e-005 b + 0.09 crim - 0.004 ptratio
##
## Rule 16/4: [140 cases, mean 21.93, range 12.7 to 35.1, est err 2.19]
##
## if
## rm <= 3.626081
## dis > 1.298828
## then
## outcome = 54.16 - 3.58 lstat + 2.2 rad - 1.6 dis - 1.9 nox + 1.8 rm
## - 17 tax + 1.3e-005 b + 0.06 crim - 0.003 ptratio
##
## Rule 16/5: [30 cases, mean 21.97, range 14.4 to 29.1, est err 2.41]
##
## if
## rm <= 3.626081
## dis > 1.298828
## tax <= 1.879832
## lstat > 2.133251
## then
## outcome = -1065.35 + 566 tax + 8.7 rm - 0.13 lstat - 0.2 dis - 0.3 nox
##
## Rule 16/6: [22 cases, mean 30.88, range 10.4 to 50, est err 4.51]
##
## if
## rm > 3.626081
## lstat > 2.133251
## then
## outcome = 42.24 + 18.7 rm - 1.5 indus - 1.84 lstat - 2.5 nox - 1.6 dis
## - 39 tax + 0.7 rad - 0.012 ptratio + 0.0035 age + 1.2e-005 b
## + 0.11 crim
##
## Rule 16/7: [73 cases, mean 34.52, range 20.6 to 50, est err 3.36]
##
## if
## lstat <= 2.133251
## then
## outcome = 50.6 + 19.6 rm - 2.77 lstat - 3.2 nox - 1.7 dis - 45 tax
## + 1 rad + 0.007 age - 0.014 ptratio
##
## Model 17:
##
## Rule 17/1: [116 cases, mean 15.37, range 5 to 27.9, est err 2.55]
##
## if
## crim > 0.4779842
## lstat > 2.944963
## then
## outcome = 35.96 - 3.68 crim - 3.41 lstat + 0.3 nox
##
## Rule 17/2: [112 cases, mean 19.13, range 7 to 31, est err 2.14]
##
## if
## crim <= 0.4779842
## lstat > 2.944963
## then
## outcome = 184.65 - 0.0365 age + 9 rm - 4.1 dis - 97 tax + 8.4e-005 b
## - 0.024 ptratio
##
## Rule 17/3: [9 cases, mean 28.37, range 15 to 50, est err 11.17]
##
## if
## dis <= 0.9547035
## b <= 66469.73
## lstat <= 2.944963
## then
## outcome = -1.12 + 0.000454 b
##
## Rule 17/4: [179 cases, mean 29.28, range 15 to 50, est err 3.35]
##
## if
## lstat <= 2.944963
## then
## outcome = 278.16 + 20 rm - 7.4 dis - 0.0356 age - 161 tax + 0.051 zn
## - 0.61 lstat + 0.17 crim - 0.008 ptratio
##
## Rule 17/5: [23 cases, mean 36.10, range 15 to 50, est err 10.83]
##
## if
## dis <= 0.9547035
## lstat <= 2.944963
## then
## outcome = 233.74 - 8.5 dis + 12.1 rm + 1.15 crim - 2.42 lstat - 113 tax
## - 0.0221 age + 0.068 zn - 0.031 ptratio
##
## Model 18:
##
## Rule 18/1: [84 cases, mean 14.29, range 5 to 27.5, est err 2.44]
##
## if
## nox > -0.4864544
## then
## outcome = 41.55 - 6.2 lstat + 14.6 nox + 3.8e-005 b
##
## Rule 18/2: [163 cases, mean 19.37, range 7 to 31, est err 2.44]
##
## if
## nox <= -0.4864544
## lstat > 2.848535
## then
## outcome = 172.79 - 3.67 lstat + 3.1 rad - 3.5 dis - 72 tax - 0.72 indus
## - 0.033 ptratio - 1.2 nox + 0.0027 age + 0.6 rm + 0.05 crim
## + 5e-006 b
##
## Rule 18/3: [106 cases, mean 25.41, range 16.5 to 50, est err 2.76]
##
## if
## rm <= 3.626081
## lstat <= 2.848535
## then
## outcome = 10.71 - 4.6 dis - 2.21 lstat + 2.3 rad + 5.5 rm - 5.3 nox
## - 0.83 indus - 0.003 ptratio
##
## Rule 18/4: [4 cases, mean 33.47, range 30.1 to 36.2, est err 5.61]
##
## if
## rm <= 3.626081
## tax <= 1.863917
## lstat <= 2.848535
## then
## outcome = 36.84
##
## Rule 18/5: [10 cases, mean 35.13, range 21.9 to 50, est err 17.40]
##
## if
## dis <= 0.6492998
## lstat <= 2.848535
## then
## outcome = 84.58 - 94.7 dis - 0.15 lstat
##
## Rule 18/6: [57 cases, mean 38.38, range 21.9 to 50, est err 3.97]
##
## if
## rm > 3.626081
## lstat <= 2.848535
## then
## outcome = 100.34 + 22.3 rm - 5.79 lstat - 0.062 ptratio - 69 tax
## + 0.3 rad - 0.5 nox - 0.3 dis + 0.0011 age
##
## Model 19:
##
## Rule 19/1: [26 cases, mean 12.40, range 5 to 27.9, est err 4.43]
##
## if
## crim > 2.449098
## b > 16084.5
## then
## outcome = 97.51 - 7.79 crim - 0.1204 age - 17.4 dis - 4.9 lstat
##
## Rule 19/2: [11 cases, mean 13.56, range 8.3 to 27.5, est err 5.20]
##
## if
## crim > 2.449098
## b <= 16084.5
## then
## outcome = 8.68 + 0.001502 b
##
## Rule 19/3: [201 cases, mean 18.25, range 7 to 31, est err 2.24]
##
## if
## crim <= 2.449098
## lstat > 2.877961
## then
## outcome = 172.29 - 0.0304 age + 8.2 rm + 5.5 nox - 88 tax + 6e-005 b
## - 0.02 ptratio - 0.75 lstat - 0.15 crim - 0.6 dis + 0.3 rad
##
## Rule 19/4: [162 cases, mean 29.47, range 16.5 to 50, est err 2.99]
##
## if
## dis > 0.6002641
## lstat <= 2.877961
## then
## outcome = 271.89 + 13.8 rm - 7.3 dis - 145 tax - 0.0205 age - 2.02 lstat
## + 0.048 zn + 0.52 crim - 0.017 ptratio + 0.6 rad + 1.5e-005 b
##
## Rule 19/5: [7 cases, mean 36.01, range 23.3 to 50, est err 3.93]
##
## if
## dis <= 0.6002641
## lstat <= 2.877961
## then
## outcome = 53.12 - 62.1 dis - 10.4 nox + 0.4 rm + 0.04 crim
##
## Model 20:
##
## Rule 20/1: [43 cases, mean 11.04, range 5 to 17.9, est err 3.14]
##
## if
## rm <= 3.620525
## dis <= 0.6604174
## lstat > 3.982242
## then
## outcome = 8.18 - 11.4 dis + 3.75 lstat - 0.4 nox - 5 tax
##
## Rule 20/2: [240 cases, mean 20.32, range 9.5 to 36.2, est err 2.08]
##
## if
## rm <= 3.620525
## dis > 0.6604174
## lstat > 2.150069
## then
## outcome = 39.71 - 7.9 nox - 2.79 lstat - 4.9 dis - 0.032 ptratio
## + 1.4 rad + 5.5e-005 b + 0.39 indus - 7 tax
##
## Rule 20/3: [26 cases, mean 20.61, range 10.9 to 50, est err 4.37]
##
## if
## rm <= 3.620525
## dis <= 0.6604174
## lstat > 2.150069
## lstat <= 3.982242
## then
## outcome = 62.02 - 51.7 dis - 5.65 lstat + 7.4e-005 b
##
## Rule 20/4: [65 cases, mean 33.32, range 20.6 to 50, est err 3.52]
##
## if
## rm <= 4.151791
## lstat <= 2.150069
## then
## outcome = -103.08 + 40.9 rm - 0.000129 b - 1.5 dis
##
## Rule 20/5: [69 cases, mean 36.04, range 10.4 to 50, est err 4.66]
##
## if
## rm > 3.620525
## then
## outcome = -21.74 + 24.5 rm - 2.94 crim + 8.8 nox - 1.2 lstat - 0.9 dis
## - 0.01 ptratio - 16 tax + 0.003 age + 0.3 rad
##
## Rule 20/6: [10 cases, mean 37.47, range 22.8 to 50, est err 9.95]
##
## if
## rm <= 4.151791
## age > 181.8879
## lstat <= 2.150069
## then
## outcome = -166.99 + 0.2594 age + 37.4 rm + 1.69 crim - 1e-005 b
##
## Rule 20/7: [10 cases, mean 42.63, range 21.9 to 50, est err 8.33]
##
## if
## rm > 4.151791
## then
## outcome = 48.42
##
## Model 21:
##
## Rule 21/1: [111 cases, mean 15.18, range 5 to 27.9, est err 2.73]
##
## if
## crim > 0.8389344
## lstat > 2.874713
## then
## outcome = 79.78 - 4.03 crim - 4.36 lstat - 3 rm - 15 tax - 0.0021 age
## + 0.5 nox - 0.3 dis - 0.002 ptratio
##
## Rule 21/2: [128 cases, mean 19.39, range 7 to 31, est err 2.17]
##
## if
## crim <= 0.8389344
## lstat > 2.874713
## then
## outcome = 202.82 + 12.3 rm - 0.0331 age - 111 tax - 3.9 dis - 0.3 lstat
## - 0.003 ptratio + 0.1 rad
##
## Rule 21/3: [158 cases, mean 29.42, range 16.5 to 50, est err 2.74]
##
## if
## dis > 0.6492998
## lstat <= 2.874713
## then
## outcome = 303.06 + 18 rm + 1.8 crim - 169 tax - 5.8 dis - 0.024 age
## + 0.059 zn - 0.026 ptratio - 0.44 lstat + 0.2 rad
##
## Rule 21/4: [10 cases, mean 35.13, range 21.9 to 50, est err 9.13]
##
## if
## dis <= 0.6492998
## lstat <= 2.874713
## then
## outcome = 86.12 - 67.1 dis - 0.3 lstat - 11 tax + 0.5 rm - 0.003 ptratio
## + 0.1 rad
##
## Model 22:
##
## Rule 22/1: [44 cases, mean 11.41, range 5 to 27.5, est err 3.15]
##
## if
## dis <= 0.6604174
## lstat > 3.982242
## then
## outcome = 19.03 - 16.6 dis
##
## Rule 22/2: [4 cases, mean 16.27, range 10.4 to 21.9, est err 5.40]
##
## if
## nox > -0.514963
## rm > 3.620525
## then
## outcome = 29.14 - 1 crim - 6.9e-005 b + 3.6 nox - 0.9 dis
##
## Rule 22/3: [257 cases, mean 20.70, range 9.5 to 36.2, est err 2.27]
##
## if
## rm <= 3.620525
## dis > 0.6604174
## lstat > 1.810901
## then
## outcome = -46.13 - 2.61 lstat - 3.7 dis + 8.4e-005 b - 0.036 ptratio
## - 3.5 nox + 40 tax - 0.12 indus + 0.4 rm + 0.05 crim
## + 0.0011 age
##
## Rule 22/4: [27 cases, mean 20.85, range 10.9 to 50, est err 4.63]
##
## if
## rm <= 3.620525
## dis <= 0.6604174
## lstat <= 3.982242
## then
## outcome = 52.17 - 45.1 dis - 2.8 lstat
##
## Rule 22/5: [36 cases, mean 36.96, range 22.8 to 50, est err 4.13]
##
## if
## rm <= 4.151791
## lstat <= 1.810901
## then
## outcome = -27.9 - 0.001054 b + 39.5 rm - 0.46 lstat - 0.8 nox - 0.5 dis
## - 0.005 ptratio + 0.06 crim + 0.0012 age - 0.05 indus
##
## Rule 22/6: [65 cases, mean 37.25, range 22 to 50, est err 6.02]
##
## if
## nox <= -0.514963
## rm > 3.620525
## then
## outcome = 2.34 - 3.67 crim - 0.000378 b + 20 nox + 19.4 rm - 0.28 lstat
## - 0.3 dis - 0.07 indus - 0.003 ptratio
##
## Rule 22/7: [7 cases, mean 43.66, range 37.6 to 50, est err 3.90]
##
## if
## rm > 4.151791
## lstat <= 1.810901
## then
## outcome = -214.13 + 60.5 rm
##
## Model 23:
##
## Rule 23/1: [109 cases, mean 15.09, range 5 to 27.9, est err 2.74]
##
## if
## crim > 0.8389344
## lstat > 2.944963
## then
## outcome = 40.38 - 4.39 crim - 4.17 lstat
##
## Rule 23/2: [119 cases, mean 19.16, range 7 to 31, est err 2.24]
##
## if
## crim <= 0.8389344
## lstat > 2.944963
## then
## outcome = 239.9 + 10.5 rm - 0.0319 age - 127 tax + 4.1 nox - 0.67 lstat
## - 0.6 dis - 0.005 ptratio + 0.2 rad
##
## Rule 23/3: [179 cases, mean 29.28, range 15 to 50, est err 3.42]
##
## if
## lstat <= 2.944963
## then
## outcome = 320.79 + 16.5 rm - 7.1 dis - 176 tax - 3.37 lstat + 1.39 crim
## - 3.8 nox + 0.053 zn - 0.0123 age + 0.3 rad - 0.006 ptratio
##
## Rule 23/4: [7 cases, mean 34.30, range 15 to 50, est err 17.41]
##
## if
## dis <= 0.5709795
## lstat <= 2.944963
## then
## outcome = 124.74 - 75.4 dis - 0.99 lstat + 1.9 rm - 31 tax + 0.18 crim
## - 1.1 nox + 0.007 zn + 0.1 rad
##
## Model 24:
##
## Rule 24/1: [166 cases, mean 17.18, range 5 to 50, est err 3.28]
##
## if
## dis <= 1.298828
## tax > 1.88548
## lstat > 2.150069
## then
## outcome = 252.44 + 9.2 dis - 5.21 lstat - 8.6 rm - 102 tax - 0.6 nox
## + 0.2 rad - 0.004 ptratio - 0.06 crim - 0.005 zn
##
## Rule 24/2: [12 cases, mean 20.71, range 10.2 to 50, est err 12.37]
##
## if
## rm <= 3.620525
## dis <= 0.3457151
## then
## outcome = 80.88 - 207.9 dis + 67.4 nox - 9.28 lstat + 20.3 rm
##
## Rule 24/3: [115 cases, mean 20.73, range 12.7 to 29.1, est err 2.09]
##
## if
## rm <= 3.620525
## dis > 1.298828
## lstat > 2.150069
## then
## outcome = 27.31 - 2.58 lstat + 9.2e-005 b + 1.9 rad - 0.033 ptratio
## - 2.3 nox - 0.0083 age - 1.3 dis - 0.23 crim - 0.018 zn - 1 rm
##
## Rule 24/4: [35 cases, mean 22.89, range 15.7 to 36.2, est err 3.64]
##
## if
## rm <= 3.620525
## dis <= 1.298828
## tax <= 1.88548
## lstat > 2.150069
## then
## outcome = 49.32 + 5.6 dis - 0.074 ptratio - 1.52 lstat + 0.8 rad - 2 nox
## + 1.4e-005 b - 0.13 crim - 0.8 rm - 0.14 indus - 0.01 zn
## - 10 tax
##
## Rule 24/5: [24 cases, mean 30.70, range 10.4 to 50, est err 5.20]
##
## if
## rm > 3.620525
## lstat > 2.150069
## then
## outcome = -46.43 + 30.7 rm - 0.00041 b - 3.05 indus - 0.33 lstat
## - 0.4 dis + 0.2 rad - 0.5 nox - 0.004 ptratio
##
## Rule 24/6: [65 cases, mean 33.32, range 20.6 to 50, est err 2.87]
##
## if
## rm <= 4.151791
## lstat <= 2.150069
## then
## outcome = -85.87 + 34.3 rm - 4 dis - 0.36 lstat - 0.6 nox
## - 0.004 ptratio + 0.1 rad
##
## Rule 24/7: [9 cases, mean 41.81, range 21.9 to 50, est err 7.59]
##
## if
## rm > 4.151791
## lstat <= 2.150069
## then
## outcome = 43.78
##
## Model 25:
##
## Rule 25/1: [19 cases, mean 8.79, range 5 to 12.7, est err 4.00]
##
## if
## crim > 2.407675
## nox > -0.4800246
## then
## outcome = 21.36 - 3.2 nox - 0.39 crim + 0.0058 age - 0.58 lstat - 8 tax
##
## Rule 25/2: [19 cases, mean 16.54, range 10.2 to 27.9, est err 4.36]
##
## if
## crim > 2.407675
## nox <= -0.4800246
## then
## outcome = 43.31 - 40 nox - 4.74 crim + 0.0706 age - 4.63 lstat - 19 tax
## + 0.9 rm - 0.3 dis - 0.003 ptratio
##
## Rule 25/3: [238 cases, mean 17.39, range 5 to 31, est err 3.08]
##
## if
## lstat > 2.877961
## then
## outcome = 246.99 + 9 rm - 132 tax - 0.0218 age + 6.4e-005 b + 0.56 crim
## + 0.52 indus - 0.02 ptratio - 0.8 lstat - 1.3 dis
##
## Rule 25/4: [7 cases, mean 20.73, range 15.7 to 29.6, est err 11.95]
##
## if
## tax <= 1.857866
## lstat > 2.877961
## then
## outcome = 20.94 + 22.1 dis - 3.23 lstat
##
## Rule 25/5: [169 cases, mean 29.74, range 16.5 to 50, est err 3.58]
##
## if
## lstat <= 2.877961
## then
## outcome = 282.59 + 17.5 rm - 157 tax - 4.4 dis - 2.25 lstat + 0.86 crim
## - 0.0192 age - 0.032 ptratio + 0.3 rad - 0.6 nox + 0.007 zn
## + 7e-006 b
##
## Rule 25/6: [10 cases, mean 35.13, range 21.9 to 50, est err 17.83]
##
## if
## dis <= 0.6492998
## lstat <= 2.877961
## then
## outcome = -30.57 - 75 dis + 0.3557 age + 0.4 rm - 0.13 lstat
##
##
## Evaluation on training data (407 cases):
##
## Average |error| 1.71
## Relative |error| 0.26
## Correlation coefficient 0.97
##
##
## Attribute usage:
## Conds Model
##
## 78% 86% lstat
## 39% 88% dis
## 35% 80% rm
## 21% 58% nox
## 9% 61% crim
## 3% 78% tax
## 2% 51% b
## 1% 72% ptratio
## 1% 67% age
## 46% rad
## 34% indus
## 23% zn
##
##
## Time: 0.3 secs
# transform the validation dataset
set.seed(7)
valX <- validation[,1:13]
trans_valX <- predict(preprocessParams, valX)
valY <- validation[,14]
# use final model to make predictions on the validation dataset
predictions <- predict(finalModel, newdata=trans_valX, neighbors = 3)
preds <- data.frame(predict(finalModel, newdata=trans_valX, neighbors = 3))
preds$row_num <- seq.int(nrow(preds))
# move row_num to beginning
preds <- preds %>% relocate(row_num, .before = predict.finalModel..newdata...trans_valX..neighbors...3.)
# calculate RMSE
rmse <- RMSE(predictions, valY)
r2 <- R2(predictions, valY)
print(rmse)
## [1] 3.222509
## [1] 0.9064533