library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Problem 3.

# Define a sequence of pm1 values ranging from 0 to 1
pm1 <- seq(0, 1, length.out = 100)

# Calculate classification error (misclassification rate)
classification_error <- pmin(pm1, 1 - pm1)

# Calculate Gini index
gini_index <- 2 * pm1 * (1 - pm1)

# Calculate entropy
entropy <- -(pm1 * log2(pm1) + (1 - pm1) * log2(1 - pm1))
entropy[is.na(entropy)] <- 0  # Handle NaN at pm1 = 0 or 1

# Plot all three measures on the same graph
plot(pm1, classification_error, type = "l", col = "red", lwd = 2, ylim = c(0, 1),
     ylab = "Value", xlab = expression(hat(p)[m1]), main = "Comparison of Classification Error, Gini Index, and Entropy")
lines(pm1, gini_index, col = "blue", lwd = 2)
lines(pm1, entropy, col = "green", lwd = 2)

# Add a legend
legend("top", legend = c("Classification Error", "Gini Index", "Entropy"),
       col = c("red", "blue", "green"), lwd = 2)

Problem 8.

# Load necessary libraries
library(ISLR2)
## Warning: package 'ISLR2' was built under R version 4.4.2
# Set seed for reproducibility
set.seed(123)

# Load the Carseats dataset
data("Carseats")

# Create a logical vector for training data (sample 70% of the data)
train_indices <- sample(1:nrow(Carseats), size = 0.7 * nrow(Carseats))

# Define training and test sets
train_set <- Carseats[train_indices, ]
test_set <- Carseats[-train_indices, ]

# Verify dimensions
dim(train_set)
## [1] 280  11
dim(test_set)
## [1] 120  11
library(rpart)    # For regression trees
library(rpart.plot) # For plotting trees
## Warning: package 'rpart.plot' was built under R version 4.4.3
set.seed(123)  # Ensuring reproducibility

# Define the regression tree model using Sales as the response variable
tree_model <- rpart(Sales ~ ., data = train_set, method = "anova")

# Plot the tree
rpart.plot(tree_model, type = 3, box.palette = "auto", main = "Regression Tree for Carseats Sales")

Key Observations: Shelf Location (ShelfLoc) appears as a primary predictor, meaning that the placement of a car seat in a store significantly influences sales.

Price thresholds create multiple splits, suggesting a nonlinear relationship between price and sales.

Competitor Pricing and Advertising contribute to further refinements, showing their role in consumer purchasing behavior.

Final sales values at the terminal nodes indicate estimated sales figures given certain conditions.

# Make predictions on the test set
predictions <- predict(tree_model, newdata = test_set)

# Calculate Mean Squared Error (MSE)
mse <- mean((test_set$Sales - predictions)^2)

# Print Test MSE
print(paste("Test MSE:", round(mse, 3)))
## [1] "Test MSE: 3.784"
# Print the complexity parameter table for the existing tree
printcp(tree_model)
## 
## Regression tree:
## rpart(formula = Sales ~ ., data = train_set, method = "anova")
## 
## Variables actually used in tree construction:
## [1] Advertising Age         CompPrice   Price       ShelveLoc  
## 
## Root node error: 2227.2/280 = 7.9544
## 
## n= 280 
## 
##          CP nsplit rel error  xerror     xstd
## 1  0.254622      0   1.00000 1.00918 0.085101
## 2  0.092152      1   0.74538 0.75739 0.059194
## 3  0.070902      2   0.65323 0.74164 0.057680
## 4  0.043245      3   0.58232 0.63935 0.048819
## 5  0.036049      4   0.53908 0.66730 0.052488
## 6  0.032271      5   0.50303 0.65513 0.052615
## 7  0.024286      7   0.43849 0.59571 0.048930
## 8  0.017482      8   0.41420 0.59585 0.051104
## 9  0.015915      9   0.39672 0.61621 0.054947
## 10 0.015626     10   0.38080 0.61960 0.054730
## 11 0.014133     11   0.36518 0.61359 0.053556
## 12 0.013544     12   0.35104 0.60831 0.052986
## 13 0.012653     14   0.32396 0.60314 0.053118
## 14 0.010461     15   0.31130 0.60120 0.053374
## 15 0.010000     16   0.30084 0.60557 0.054340
# Find the optimal cp value that minimizes cross-validation error
optimal_cp <- tree_model$cptable[which.min(tree_model$cptable[, "xerror"]), "CP"]
# Prune the tree using the optimal cp value
pruned_tree <- prune(tree_model, cp = optimal_cp)

# Plot the pruned tree
rpart.plot(pruned_tree, type = 3, box.palette = "auto", main = "Pruned Regression Tree")

# Make predictions with the pruned tree
pred_pruned <- predict(pruned_tree, newdata = test_set)

# Compute MSE
mse_pruned <- mean((test_set$Sales - pred_pruned)^2)

print(paste("Test MSE after pruning:", round(mse_pruned, 3)))
## [1] "Test MSE after pruning: 4.353"

Yes, pruning the tree improves the test MSE from 3.784 to 4.353.

library(randomForest)  # For bagging
## Warning: package 'randomForest' was built under R version 4.4.2
## randomForest 4.7-1.2
## Type rfNews() to see new features/changes/bug fixes.
## 
## Attaching package: 'randomForest'
## The following object is masked from 'package:dplyr':
## 
##     combine
## The following object is masked from 'package:ggplot2':
## 
##     margin
set.seed(123)

# Fit a bagging model using all predictors
bagging_model <- randomForest(Sales ~ ., data = train_set, mtry = ncol(train_set) - 1, importance = TRUE)

# Make predictions on the test set
pred_bagging <- predict(bagging_model, newdata = test_set)

# Compute Test MSE
mse_bagging <- mean((test_set$Sales - pred_bagging)^2)

print(paste("Test MSE from Bagging:", round(mse_bagging, 3)))
## [1] "Test MSE from Bagging: 2.282"
# Compute importance scores
importance_scores <- importance(bagging_model)

# Print importance scores
print(importance_scores)
##                %IncMSE IncNodePurity
## CompPrice   34.4262904    257.760843
## Income       7.4645949    113.727916
## Advertising 20.4003141    147.788939
## Population  -3.0115418     66.776729
## Price       64.3523306    630.500603
## ShelveLoc   72.8822146    689.811838
## Age         17.7747876    182.686692
## Education    3.4693027     63.408518
## Urban       -0.8360222      8.755624
## US           0.2868891      8.107184
# Visualize importance
varImpPlot(bagging_model, main = "Variable Importance in Bagging Model")

# Fit a random forest model with default mtry (square root of predictors)
rf_model <- randomForest(Sales ~ ., data = train_set, importance = TRUE)

# Make predictions on the test set
pred_rf <- predict(rf_model, newdata = test_set)

# Compute Test MSE
mse_rf <- mean((test_set$Sales - pred_rf)^2)

print(paste("Test MSE from Random Forest:", round(mse_rf, 3)))
## [1] "Test MSE from Random Forest: 2.692"
# Compute importance scores
importance_scores <- importance(rf_model)

# Print importance scores
print(importance_scores)
##                %IncMSE IncNodePurity
## CompPrice   17.9902437     222.21680
## Income       3.6577330     169.69669
## Advertising 14.2225258     183.83686
## Population   1.0498450     129.38996
## Price       39.7464114     487.82721
## ShelveLoc   49.0222535     524.36703
## Age         18.2668763     254.34247
## Education    0.5565258     102.26841
## Urban        0.2414523      20.69624
## US           3.1190731      21.13234
# Visualize importance
varImpPlot(rf_model, main = "Variable Importance in Random Forest")

# Fit random forests with different mtry values
rf_model_small <- randomForest(Sales ~ ., data = train_set, mtry = 2, importance = TRUE)
rf_model_large <- randomForest(Sales ~ ., data = train_set, mtry = ncol(train_set) - 1, importance = TRUE)

# Compute error rates
mse_small <- mean((test_set$Sales - predict(rf_model_small, newdata = test_set))^2)
mse_large <- mean((test_set$Sales - predict(rf_model_large, newdata = test_set))^2)

print(paste("MSE for small mtry (2 variables):", round(mse_small, 3)))
## [1] "MSE for small mtry (2 variables): 3.157"
print(paste("MSE for large mtry (all variables):", round(mse_large, 3)))
## [1] "MSE for large mtry (all variables): 2.287"

Effects of mtry on Error Rate Small mtry (few variables per split) → Reduces correlation between trees, often improving generalization.

Large mtry (many predictors per split) → Can mimic bagging, capturing complexity but increasing variance.

library(dbarts)
## Warning: package 'dbarts' was built under R version 4.4.3
## 
## Attaching package: 'dbarts'
## The following object is masked from 'package:tidyr':
## 
##     extract
set.seed(123)

# Prepare data
X_train <- subset(train_set, select = -Sales)  # Predictors
y_train <- train_set$Sales                      # Response variable
X_test <- subset(test_set, select = -Sales)     # Test predictors

# Fit BART model
bart_model <- bart(x.train = X_train, y.train = y_train, x.test = X_test)
## 
## Running BART with numeric y
## 
## number of trees: 200
## number of chains: 1, default number of threads 1
## tree thinning rate: 1
## Prior:
##  k prior fixed to 2.000000
##  degrees of freedom in sigma prior: 3.000000
##  quantile in sigma prior: 0.900000
##  scale in sigma prior: 0.000765
##  power and base for tree prior: 2.000000 0.950000
##  use quantiles for rule cut points: false
##  proposal probabilities: birth/death 0.50, swap 0.10, change 0.40; birth 0.50
## data:
##  number of training observations: 280
##  number of test observations: 120
##  number of explanatory variables: 12
##  init sigma: 1.009719, curr sigma: 1.009719
## 
## Cutoff rules c in x<=c vs x>c
## Number of cutoffs: (var: number of possible c):
## (1: 100) (2: 100) (3: 100) (4: 100) (5: 100) 
## (6: 100) (7: 100) (8: 100) (9: 100) (10: 100) 
## (11: 100) (12: 100) 
## Running mcmc loop:
## iteration: 100 (of 1000)
## iteration: 200 (of 1000)
## iteration: 300 (of 1000)
## iteration: 400 (of 1000)
## iteration: 500 (of 1000)
## iteration: 600 (of 1000)
## iteration: 700 (of 1000)
## iteration: 800 (of 1000)
## iteration: 900 (of 1000)
## iteration: 1000 (of 1000)
## total seconds in loop: 0.794638
## 
## Tree sizes, last iteration:
## [1] 3 5 2 2 2 2 2 2 3 2 2 1 2 2 3 3 2 2 
## 4 3 2 3 2 3 2 2 3 2 2 2 2 3 3 2 2 2 2 2 
## 2 2 2 2 2 2 2 3 2 2 2 4 2 5 4 2 2 2 2 2 
## 1 3 3 2 2 3 2 3 2 2 2 3 2 2 2 2 2 3 3 1 
## 2 2 3 3 2 2 2 2 2 2 3 2 3 3 3 3 2 2 3 2 
## 2 2 2 1 2 2 5 2 3 2 2 2 3 2 2 3 2 1 2 2 
## 2 4 2 2 5 4 3 2 2 3 3 2 2 2 2 4 2 3 2 3 
## 2 2 2 2 2 3 3 3 2 3 2 3 3 2 2 3 2 1 1 2 
## 3 3 2 2 4 1 2 1 2 4 2 2 3 4 3 2 2 2 2 2 
## 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 3 
## 2 3 
## 
## Variable Usage, last iteration (var:count):
## (1: 27) (2: 23) (3: 21) (4: 26) (5: 36) 
## (6: 22) (7: 19) (8: 21) (9: 23) (10: 18) 
## (11: 19) (12: 15) 
## DONE BART
# Extract test predictions
pred_bart <- bart_model$yhat.test.mean

# Compute Mean Squared Error (MSE)
mse_bart <- mean((test_set$Sales - pred_bart)^2)

print(paste("Test MSE from BART:", round(mse_bart, 3)))
## [1] "Test MSE from BART: 1.636"
# Check variable importance scores
bart_model$varcount  # Number of times each variable was used for splitting
##         CompPrice Income Advertising Population Price ShelveLoc.Bad
##    [1,]        26     27          17         26    29            30
##    [2,]        28     21          17         27    30            30
##    [3,]        28     23          15         22    32            26
##    [4,]        30     19          18         24    32            25
##    [5,]        35     20          21         24    33            24
##    [6,]        36     22          25         27    35            23
##    [7,]        34     21          20         28    33            22
##    [8,]        32     25          21         32    31            18
##    [9,]        33     24          20         30    33            17
##   [10,]        31     24          20         30    31            19
##   [11,]        26     27          23         27    29            18
##   [12,]        26     23          26         28    26            17
##   [13,]        27     25          25         26    28            21
##   [14,]        31     25          22         24    28            26
##   [15,]        24     23          22         25    29            22
##   [16,]        22     22          21         29    30            24
##   [17,]        27     18          25         30    30            25
##   [18,]        25     23          21         28    32            23
##   [19,]        26     21          20         27    32            24
##   [20,]        21     21          20         23    32            26
##   [21,]        19     20          21         21    33            25
##   [22,]        20     21          25         23    36            24
##   [23,]        19     19          23         19    40            19
##   [24,]        19     20          26         20    39            24
##   [25,]        20     17          23         16    40            23
##   [26,]        20     18          26         16    43            22
##   [27,]        20     19          24         15    39            24
##   [28,]        27     19          27         17    38            25
##   [29,]        26     21          25         15    36            24
##   [30,]        26     19          24         21    34            20
##   [31,]        26     19          23         21    35            23
##   [32,]        29     25          27         19    38            22
##   [33,]        29     25          27         21    36            22
##   [34,]        29     25          25         20    36            20
##   [35,]        30     27          27         17    38            12
##   [36,]        26     32          23         17    37            11
##   [37,]        24     32          24         17    39            15
##   [38,]        21     32          24         17    36            18
##   [39,]        23     28          20         17    38            16
##   [40,]        23     26          22         17    37            19
##   [41,]        28     20          20         18    35            21
##   [42,]        27     16          19         21    33            22
##   [43,]        28     16          23         20    31            23
##   [44,]        25     13          23         21    29            21
##   [45,]        27     16          25         22    30            25
##   [46,]        27     16          21         20    29            23
##   [47,]        27     18          23         19    30            24
##   [48,]        23     18          23         19    30            26
##   [49,]        22     17          22         17    31            26
##   [50,]        25     19          19         18    31            25
##   [51,]        22     18          23         21    28            24
##   [52,]        25     18          24         24    30            21
##   [53,]        21     19          21         23    30            22
##   [54,]        21     20          20         23    36            24
##   [55,]        26     20          19         21    31            22
##   [56,]        26     17          23         19    29            23
##   [57,]        24     16          20         23    29            21
##   [58,]        28     18          19         20    29            19
##   [59,]        27     20          18         24    36            19
##   [60,]        31     20          19         23    34            19
##   [61,]        22     24          14         26    28            19
##   [62,]        24     27          15         23    34            21
##   [63,]        22     23          17         19    34            21
##   [64,]        23     21          20         20    34            23
##   [65,]        23     21          23         23    29            23
##   [66,]        24     20          23         23    30            22
##   [67,]        24     20          23         20    30            23
##   [68,]        26     25          25         19    30            24
##   [69,]        21     22          25         23    32            22
##   [70,]        21     23          21         27    32            23
##   [71,]        24     27          26         27    29            23
##   [72,]        27     24          26         24    30            25
##   [73,]        25     26          31         23    31            25
##   [74,]        23     29          26         25    29            26
##   [75,]        26     28          24         21    29            20
##   [76,]        28     25          26         21    31            19
##   [77,]        24     23          21         19    34            23
##   [78,]        26     22          23         24    34            19
##   [79,]        21     20          23         22    34            22
##   [80,]        20     21          23         20    35            24
##   [81,]        18     22          24         21    39            25
##   [82,]        19     25          19         25    33            27
##   [83,]        21     24          23         26    35            26
##   [84,]        21     25          21         29    32            27
##   [85,]        21     22          21         32    31            27
##   [86,]        24     23          19         31    35            27
##   [87,]        24     22          18         31    36            26
##   [88,]        28     23          17         27    34            26
##   [89,]        24     18          23         26    34            24
##   [90,]        21     17          22         23    36            25
##   [91,]        26     21          25         21    33            23
##   [92,]        29     18          27         19    34            22
##   [93,]        30     16          27         22    31            25
##   [94,]        30     14          25         23    29            23
##   [95,]        28     16          26         21    31            24
##   [96,]        26     17          26         21    32            23
##   [97,]        25     15          24         24    31            22
##   [98,]        26     13          26         21    33            21
##   [99,]        30     14          27         22    32            21
##  [100,]        32     17          24         24    35            23
##  [101,]        30     13          24         27    34            25
##  [102,]        28     18          23         27    29            24
##  [103,]        28     18          26         26    32            23
##  [104,]        27     20          26         25    34            28
##  [105,]        28     19          26         29    32            29
##  [106,]        28     19          30         28    30            25
##  [107,]        27     19          25         22    28            24
##  [108,]        24     14          22         23    29            23
##  [109,]        24     12          19         26    30            26
##  [110,]        27     13          25         24    29            26
##  [111,]        28     17          25         26    27            27
##  [112,]        28     18          25         28    28            30
##  [113,]        22     17          26         26    28            32
##  [114,]        26     21          22         26    27            32
##  [115,]        24     16          22         27    29            34
##  [116,]        27     15          21         24    33            33
##  [117,]        22     18          26         24    33            33
##  [118,]        21     19          30         27    34            29
##  [119,]        25     24          23         27    36            25
##  [120,]        29     17          23         25    36            26
##  [121,]        26     18          21         23    34            27
##  [122,]        24     17          28         16    36            24
##  [123,]        24     18          30         22    33            21
##  [124,]        18     21          27         25    32            22
##  [125,]        15     20          24         21    36            25
##  [126,]        19     20          21         23    34            22
##  [127,]        24     18          23         23    35            18
##  [128,]        26     24          23         18    35            17
##  [129,]        29     26          25         18    31            17
##  [130,]        26     24          30         15    30            17
##  [131,]        24     27          25         16    33            18
##  [132,]        27     18          25         20    29            19
##  [133,]        29     18          26         19    33            24
##  [134,]        28     18          24         17    36            20
##  [135,]        24     15          25         17    38            19
##  [136,]        26     17          26         15    35            19
##  [137,]        24     19          27         20    32            22
##  [138,]        23     22          25         26    33            21
##  [139,]        20     19          24         26    35            19
##  [140,]        25     17          27         26    31            21
##  [141,]        25     20          23         26    36            17
##  [142,]        26     21          25         25    32            18
##  [143,]        25     19          24         24    30            18
##  [144,]        28     18          24         22    33            19
##  [145,]        28     23          25         23    29            19
##  [146,]        29     20          29         25    32            20
##  [147,]        28     19          28         20    30            22
##  [148,]        29     18          30         21    28            17
##  [149,]        33     19          31         21    33            17
##  [150,]        32     20          27         18    32            18
##  [151,]        31     18          28         21    30            20
##  [152,]        32     13          27         18    32            22
##  [153,]        30     13          27         15    33            23
##  [154,]        30     15          23         20    28            27
##  [155,]        28     16          20         23    31            25
##  [156,]        29     17          21         25    31            28
##  [157,]        31     17          22         25    28            30
##  [158,]        32     20          30         21    33            26
##  [159,]        31     17          32         20    30            25
##  [160,]        30     16          29         22    31            24
##  [161,]        28     15          30         20    31            25
##  [162,]        28     16          32         22    31            25
##  [163,]        27     14          28         22    32            28
##  [164,]        31     17          29         23    32            26
##  [165,]        31     17          29         21    33            26
##  [166,]        28     16          25         24    34            21
##  [167,]        26     13          25         24    32            17
##  [168,]        25     18          24         24    29            17
##  [169,]        22     11          29         21    35            17
##  [170,]        29     12          26         18    35            18
##  [171,]        27     12          32         16    35            21
##  [172,]        28      9          35         15    32            21
##  [173,]        31     11          32         13    32            23
##  [174,]        34      9          31         16    33            26
##  [175,]        32     19          30         16    27            21
##  [176,]        28     15          25         16    33            24
##  [177,]        32     15          23         18    35            22
##  [178,]        31     14          22         15    33            23
##  [179,]        32     20          20         15    32            25
##  [180,]        29     23          16         12    37            24
##  [181,]        27     24          15         11    38            25
##  [182,]        23     23          15         12    32            30
##  [183,]        25     28          18         12    29            29
##  [184,]        25     26          19         15    32            25
##  [185,]        28     24          18         21    36            25
##  [186,]        33     27          19         21    35            28
##  [187,]        35     25          19         21    34            27
##  [188,]        34     25          25         21    37            27
##  [189,]        29     28          23         22    31            29
##  [190,]        30     32          22         23    31            26
##  [191,]        28     31          25         24    31            29
##  [192,]        30     30          22         23    35            29
##  [193,]        34     30          24         19    36            31
##  [194,]        38     30          22         15    36            22
##  [195,]        34     34          19         20    35            23
##  [196,]        34     30          18         21    32            21
##  [197,]        29     28          20         25    37            23
##  [198,]        29     23          24         22    39            23
##  [199,]        39     22          25         18    37            21
##  [200,]        41     19          24         18    38            18
##  [201,]        41     23          22         17    38            21
##  [202,]        35     20          21         16    36            19
##  [203,]        35     21          17         16    36            16
##  [204,]        36     23          17         18    34            15
##  [205,]        33     24          19         18    30            17
##  [206,]        31     21          20         21    28            19
##  [207,]        32     21          22         17    30            18
##  [208,]        28     20          24         18    33            18
##  [209,]        30     23          25         18    34            20
##  [210,]        31     22          26         15    37            19
##  [211,]        26     25          28         16    38            19
##  [212,]        31     23          32         18    39            20
##  [213,]        29     21          29         17    38            21
##  [214,]        30     20          29         17    37            18
##  [215,]        29     22          32         18    38            17
##  [216,]        25     24          35         17    37            19
##  [217,]        24     25          34         18    36            21
##  [218,]        24     23          32         18    33            25
##  [219,]        26     27          31         13    33            21
##  [220,]        28     25          31         15    34            18
##  [221,]        28     24          31         17    32            16
##  [222,]        27     25          33         17    34            17
##  [223,]        27     25          32         10    36            15
##  [224,]        28     21          32         14    39            14
##  [225,]        30     21          32         12    41            17
##  [226,]        27     21          33         12    38            15
##  [227,]        28     23          31         14    40            13
##  [228,]        31     20          23         12    38            15
##  [229,]        28     19          22         15    42            19
##  [230,]        30     16          22         17    39            20
##  [231,]        28     14          19         14    35            21
##  [232,]        28     14          22         14    33            22
##  [233,]        26     19          20         15    31            20
##  [234,]        28     15          21         17    31            20
##  [235,]        30     18          16         13    32            21
##  [236,]        36     17          14         15    33            21
##  [237,]        33     16          21         15    26            21
##  [238,]        29     16          21         19    32            18
##  [239,]        31     15          18         16    36            16
##  [240,]        33     20          21         16    37            18
##  [241,]        31     17          19         21    36            20
##  [242,]        29     18          19         21    36            20
##  [243,]        34     19          17         20    38            22
##  [244,]        33     17          18         23    37            22
##  [245,]        32     18          20         25    33            25
##  [246,]        32     20          19         25    33            24
##  [247,]        31     19          22         21    31            21
##  [248,]        30     19          22         22    31            20
##  [249,]        30     19          24         18    32            18
##  [250,]        31     19          20         19    32            21
##  [251,]        31     14          18         17    36            22
##  [252,]        27     17          19         22    30            23
##  [253,]        23     20          20         21    32            23
##  [254,]        25     22          21         24    30            24
##  [255,]        24     24          20         25    28            29
##  [256,]        26     25          20         23    24            31
##  [257,]        29     20          21         22    27            28
##  [258,]        24     17          25         21    30            25
##  [259,]        24     17          25         25    29            23
##  [260,]        22     13          24         19    29            26
##  [261,]        25     17          25         23    33            25
##  [262,]        26     16          25         20    34            23
##  [263,]        30     17          25         19    34            29
##  [264,]        32     15          25         23    34            24
##  [265,]        33     16          25         23    37            20
##  [266,]        36     18          24         24    29            16
##  [267,]        31     18          26         22    27            19
##  [268,]        32     22          26         17    26            20
##  [269,]        30     22          24         16    30            15
##  [270,]        32     22          20         18    34            15
##  [271,]        29     19          20         23    33            16
##  [272,]        34     24          19         21    33            17
##  [273,]        34     20          24         24    34            16
##  [274,]        35     21          23         28    32            18
##  [275,]        31     25          21         26    40            20
##  [276,]        29     21          20         26    39            16
##  [277,]        29     18          20         28    36            16
##  [278,]        29     20          19         33    34            16
##  [279,]        33     20          20         25    35            20
##  [280,]        31     20          23         22    36            22
##  [281,]        31     19          21         22    35            19
##  [282,]        27     23          16         22    37            22
##  [283,]        25     20          15         22    34            22
##  [284,]        29     22          17         21    33            23
##  [285,]        31     22          19         23    31            23
##  [286,]        33     20          20         23    29            23
##  [287,]        36     24          19         21    33            23
##  [288,]        32     22          16         18    40            19
##  [289,]        28     21          19         17    38            17
##  [290,]        31     23          20         18    38            15
##  [291,]        32     21          23         19    37            16
##  [292,]        28     22          22         23    34            16
##  [293,]        33     15          19         24    33            16
##  [294,]        32     20          21         24    33            17
##  [295,]        32     25          18         24    37            19
##  [296,]        28     25          22         31    34            20
##  [297,]        31     24          21         27    31            20
##  [298,]        31     16          20         30    35            25
##  [299,]        31     16          25         31    29            22
##  [300,]        28     19          23         26    33            24
##  [301,]        29     20          22         26    30            21
##  [302,]        29     25          19         26    31            17
##  [303,]        30     18          21         24    33            18
##  [304,]        29     18          19         23    40            19
##  [305,]        29     22          16         27    37            19
##  [306,]        30     22          18         25    40            15
##  [307,]        31     23          18         19    37            16
##  [308,]        27     22          20         19    33            12
##  [309,]        27     24          21         20    30            13
##  [310,]        26     24          24         19    35            14
##  [311,]        28     25          24         18    34            13
##  [312,]        24     23          25         22    32            11
##  [313,]        23     23          26         18    34            13
##  [314,]        24     27          18         20    32            19
##  [315,]        19     23          17         24    35            16
##  [316,]        20     24          18         22    34            17
##  [317,]        23     23          17         24    34            16
##  [318,]        24     27          22         20    32            18
##  [319,]        21     30          25         21    33            17
##  [320,]        22     24          30         23    30            17
##  [321,]        24     24          27         21    30            21
##  [322,]        22     24          28         26    30            25
##  [323,]        22     22          27         20    30            27
##  [324,]        27     20          26         21    34            22
##  [325,]        25     21          23         21    30            19
##  [326,]        31     18          20         25    26            23
##  [327,]        26     21          20         23    25            20
##  [328,]        27     19          22         23    28            24
##  [329,]        31     24          19         24    27            20
##  [330,]        33     18          21         22    30            19
##  [331,]        31     20          19         20    30            24
##  [332,]        33     19          16         20    31            26
##  [333,]        31     20          17         21    30            24
##  [334,]        32     21          18         22    28            22
##  [335,]        33     22          16         19    28            22
##  [336,]        33     29          19         18    27            21
##  [337,]        35     28          17         19    24            23
##  [338,]        32     23          14         16    26            23
##  [339,]        25     24          18         16    27            27
##  [340,]        20     25          21         22    29            28
##  [341,]        23     22          20         18    29            30
##  [342,]        26     21          20         18    36            30
##  [343,]        22     22          22         19    36            25
##  [344,]        23     18          15         20    38            29
##  [345,]        28     20          18         22    38            27
##  [346,]        26     19          20         21    33            30
##  [347,]        30     21          23         22    31            22
##  [348,]        33     21          22         27    33            23
##  [349,]        30     22          21         25    32            20
##  [350,]        28     22          21         29    34            22
##  [351,]        25     20          23         26    41            18
##  [352,]        24     18          21         25    37            20
##  [353,]        24     20          22         29    36            19
##  [354,]        23     16          24         25    33            21
##  [355,]        24     18          25         22    31            20
##  [356,]        30     18          23         18    30            20
##  [357,]        29     20          26         17    34            19
##  [358,]        30     20          21         18    31            21
##  [359,]        28     19          21         19    31            21
##  [360,]        23     21          25         23    32            21
##  [361,]        29     21          21         24    33            20
##  [362,]        27     17          22         23    35            19
##  [363,]        25     24          20         22    35            16
##  [364,]        29     27          20         27    34            18
##  [365,]        30     26          21         27    33            21
##  [366,]        32     27          19         28    34            19
##  [367,]        30     24          20         29    36            18
##  [368,]        26     24          22         25    30            21
##  [369,]        25     29          23         30    35            20
##  [370,]        24     25          19         31    32            17
##  [371,]        25     24          21         29    31            20
##  [372,]        27     22          21         28    31            23
##  [373,]        27     22          24         28    32            17
##  [374,]        29     22          23         27    31            18
##  [375,]        26     21          23         27    27            17
##  [376,]        24     20          26         28    28            18
##  [377,]        23     21          25         32    33            18
##  [378,]        22     19          24         29    36            20
##  [379,]        28     21          24         29    35            17
##  [380,]        28     20          24         24    33            20
##  [381,]        28     20          20         25    32            22
##  [382,]        25     18          21         21    36            22
##  [383,]        27     19          24         19    34            19
##  [384,]        31     19          32         16    33            22
##  [385,]        35     19          29         19    29            23
##  [386,]        29     23          32         20    30            24
##  [387,]        30     25          28         18    30            27
##  [388,]        30     22          26         16    29            24
##  [389,]        26     22          27         16    30            24
##  [390,]        24     23          26         19    30            22
##  [391,]        25     24          25         19    27            26
##  [392,]        25     23          22         17    32            22
##  [393,]        26     26          25         12    37            23
##  [394,]        27     30          21         14    37            25
##  [395,]        27     25          23         17    34            26
##  [396,]        21     22          26         15    32            26
##  [397,]        22     21          29         14    33            22
##  [398,]        22     23          25         12    37            21
##  [399,]        25     24          24         18    34            27
##  [400,]        27     17          26         19    36            26
##  [401,]        28     18          25         23    35            24
##  [402,]        27     19          28         21    38            21
##  [403,]        27     13          29         22    34            22
##  [404,]        27     15          30         19    33            21
##  [405,]        26     19          27         20    32            21
##  [406,]        27     22          30         18    33            23
##  [407,]        29     18          25         20    31            24
##  [408,]        28     18          30         23    31            28
##  [409,]        25     18          28         23    33            29
##  [410,]        24     19          30         17    35            28
##  [411,]        23     21          31         15    37            27
##  [412,]        29     24          32         12    33            28
##  [413,]        32     22          28         12    33            27
##  [414,]        31     28          26         12    32            25
##  [415,]        32     30          20         11    35            23
##  [416,]        32     27          21         17    34            22
##  [417,]        30     28          23         19    37            23
##  [418,]        28     33          20         18    35            27
##  [419,]        27     29          21         17    34            25
##  [420,]        30     30          18         17    34            25
##  [421,]        32     26          20         15    31            24
##  [422,]        36     31          18         17    29            24
##  [423,]        32     30          21         16    32            26
##  [424,]        27     32          19         23    33            25
##  [425,]        29     30          21         22    37            23
##  [426,]        31     30          26         23    38            24
##  [427,]        30     29          29         27    35            23
##  [428,]        30     28          27         22    34            26
##  [429,]        30     30          25         16    39            20
##  [430,]        30     28          26         15    34            23
##  [431,]        29     30          27         15    35            24
##  [432,]        27     31          26         19    33            23
##  [433,]        27     31          20         16    28            24
##  [434,]        29     31          20         18    25            24
##  [435,]        31     33          22         20    25            21
##  [436,]        31     34          20         23    25            22
##  [437,]        30     35          18         26    27            25
##  [438,]        30     35          20         28    32            22
##  [439,]        28     33          21         33    32            17
##  [440,]        26     33          22         28    34            18
##  [441,]        29     29          22         28    29            17
##  [442,]        29     26          26         32    28            16
##  [443,]        28     29          28         24    28            17
##  [444,]        26     26          27         27    30            15
##  [445,]        26     24          25         25    32            17
##  [446,]        26     24          24         27    30            20
##  [447,]        27     23          28         27    31            23
##  [448,]        27     28          24         23    33            18
##  [449,]        26     31          25         26    32            17
##  [450,]        28     33          25         24    34            16
##  [451,]        28     31          25         23    37            13
##  [452,]        22     34          24         24    34            14
##  [453,]        23     36          24         25    36            11
##  [454,]        23     34          22         22    32            14
##  [455,]        27     31          25         20    33            15
##  [456,]        22     30          28         29    30            12
##  [457,]        23     30          28         27    37            13
##  [458,]        18     31          25         26    35            17
##  [459,]        22     27          26         25    36            19
##  [460,]        24     25          23         26    32            14
##  [461,]        26     25          25         28    32            15
##  [462,]        30     24          26         25    34            14
##  [463,]        30     25          25         27    35            18
##  [464,]        34     20          23         25    34            18
##  [465,]        27     22          23         23    34            21
##  [466,]        23     22          24         26    33            20
##  [467,]        28     26          22         23    29            20
##  [468,]        29     28          22         25    29            19
##  [469,]        32     26          23         25    32            14
##  [470,]        29     26          22         23    33            17
##  [471,]        28     27          17         20    29            22
##  [472,]        28     28          15         21    33            21
##  [473,]        30     31          19         21    34            21
##  [474,]        26     31          17         20    30            21
##  [475,]        27     31          18         21    31            21
##  [476,]        24     30          21         19    31            19
##  [477,]        27     28          20         20    30            18
##  [478,]        30     26          22         18    36            18
##  [479,]        26     26          25         21    37            21
##  [480,]        27     30          23         18    35            23
##  [481,]        29     29          21         21    33            21
##  [482,]        24     35          24         17    34            20
##  [483,]        26     30          21         19    32            18
##  [484,]        27     29          20         15    29            20
##  [485,]        29     28          17         16    33            18
##  [486,]        27     31          14         15    32            19
##  [487,]        30     29          18         14    28            20
##  [488,]        31     29          17         15    27            17
##  [489,]        34     28          18         16    28            17
##  [490,]        38     29          19         14    28            16
##  [491,]        41     28          18         14    26            16
##  [492,]        35     30          19         14    25            15
##  [493,]        35     25          19         16    25            16
##  [494,]        34     25          21         18    24            16
##  [495,]        32     29          20         18    27            16
##  [496,]        31     24          23         22    29            12
##  [497,]        31     27          21         21    34            13
##  [498,]        33     25          18         22    31            17
##  [499,]        34     24          18         21    29            16
##  [500,]        39     27          18         21    32            15
##  [501,]        38     28          19         18    33            17
##  [502,]        33     30          17         20    32            15
##  [503,]        28     30          18         23    33            15
##  [504,]        28     33          20         19    36            16
##  [505,]        30     30          21         20    33            18
##  [506,]        27     25          17         21    36            21
##  [507,]        27     24          17         24    34            22
##  [508,]        30     18          17         23    36            16
##  [509,]        30     17          14         17    33            21
##  [510,]        28     17          15         16    36            20
##  [511,]        24     18          15         16    35            24
##  [512,]        26     18          19         18    33            21
##  [513,]        28     18          15         25    33            24
##  [514,]        33     15          16         24    33            21
##  [515,]        36     17          15         18    34            20
##  [516,]        35     21          20         16    35            18
##  [517,]        39     17          21         18    33            15
##  [518,]        33     15          20         22    31            18
##  [519,]        34     13          14         18    32            21
##  [520,]        32     18          17         15    35            19
##  [521,]        27     18          17         15    30            18
##  [522,]        27     17          18         17    34            19
##  [523,]        28     14          18         18    34            19
##  [524,]        25     16          21         19    33            21
##  [525,]        27     19          20         19    33            20
##  [526,]        28     21          20         20    28            21
##  [527,]        31     18          21         22    29            18
##  [528,]        34     22          21         21    32            21
##  [529,]        31     21          22         21    31            16
##  [530,]        33     19          24         21    31            20
##  [531,]        31     23          25         23    31            22
##  [532,]        30     22          30         22    29            20
##  [533,]        28     20          30         26    28            19
##  [534,]        30     22          30         22    31            19
##  [535,]        29     30          29         22    31            15
##  [536,]        29     32          33         22    26            16
##  [537,]        32     25          36         23    25            18
##  [538,]        33     22          31         26    27            16
##  [539,]        32     25          32         30    28            21
##  [540,]        31     21          30         26    29            19
##  [541,]        32     21          27         29    29            17
##  [542,]        35     20          28         24    26            20
##  [543,]        35     22          27         19    29            20
##  [544,]        33     22          25         18    32            16
##  [545,]        29     19          24         16    31            16
##  [546,]        27     16          23         19    29            17
##  [547,]        34     16          21         24    31            15
##  [548,]        28     18          22         30    31            19
##  [549,]        28     18          23         29    28            20
##  [550,]        34     18          23         31    29            19
##  [551,]        32     19          26         29    29            15
##  [552,]        29     18          29         25    33            17
##  [553,]        28     21          22         22    30            18
##  [554,]        27     21          25         22    29            21
##  [555,]        32     25          26         25    26            19
##  [556,]        29     24          26         21    29            19
##  [557,]        26     24          31         18    29            24
##  [558,]        30     25          25         19    28            24
##  [559,]        29     20          22         20    26            25
##  [560,]        31     18          20         25    30            25
##  [561,]        33     21          20         26    26            24
##  [562,]        30     22          19         33    25            23
##  [563,]        27     22          18         27    29            27
##  [564,]        22     23          17         26    35            21
##  [565,]        22     24          17         23    37            20
##  [566,]        22     19          22         23    35            20
##  [567,]        25     21          20         21    31            21
##  [568,]        26     24          24         18    33            21
##  [569,]        29     24          22         18    36            19
##  [570,]        29     20          23         18    33            19
##  [571,]        29     17          25         20    32            20
##  [572,]        34     15          31         25    38            19
##  [573,]        34     15          29         21    38            17
##  [574,]        31     22          28         24    34            18
##  [575,]        30     23          31         25    37            17
##  [576,]        25     28          29         27    36            20
##  [577,]        25     29          25         22    30            20
##  [578,]        23     26          19         24    33            22
##  [579,]        24     21          23         25    36            25
##  [580,]        22     26          21         26    34            20
##  [581,]        27     25          20         29    33            21
##  [582,]        31     21          18         24    35            23
##  [583,]        29     22          18         23    33            18
##  [584,]        28     22          17         24    34            18
##  [585,]        30     25          17         25    30            17
##  [586,]        24     25          23         20    30            19
##  [587,]        23     23          20         25    31            17
##  [588,]        20     24          17         25    36            20
##  [589,]        17     21          17         24    36            24
##  [590,]        20     24          22         23    31            18
##  [591,]        22     22          20         19    29            18
##  [592,]        23     20          21         21    33            18
##  [593,]        26     24          24         21    30            23
##  [594,]        28     21          22         20    33            19
##  [595,]        30     23          19         17    29            25
##  [596,]        33     28          17         21    33            22
##  [597,]        28     28          16         23    33            21
##  [598,]        32     29          19         22    36            20
##  [599,]        28     28          17         23    34            21
##  [600,]        22     25          15         24    35            21
##  [601,]        23     23          15         26    40            25
##  [602,]        23     28          13         23    43            24
##  [603,]        25     28          12         28    42            20
##  [604,]        27     28          15         25    41            20
##  [605,]        27     29          15         25    40            19
##  [606,]        31     29          16         27    41            21
##  [607,]        32     36          17         26    36            25
##  [608,]        35     35          16         26    34            24
##  [609,]        32     28          15         27    34            26
##  [610,]        32     30          14         25    37            24
##  [611,]        37     25          18         28    33            25
##  [612,]        35     26          17         29    34            28
##  [613,]        33     32          21         28    28            24
##  [614,]        29     30          19         27    28            21
##  [615,]        28     31          18         22    28            17
##  [616,]        32     36          17         24    27            17
##  [617,]        31     32          17         23    24            19
##  [618,]        31     27          16         26    29            23
##  [619,]        32     27          20         20    30            22
##  [620,]        30     28          21         18    35            22
##  [621,]        27     30          23         21    33            20
##  [622,]        30     31          23         22    37            18
##  [623,]        24     32          19         21    39            21
##  [624,]        26     37          22         21    34            17
##  [625,]        26     37          23         25    34            16
##  [626,]        26     35          23         27    37            17
##  [627,]        24     32          25         26    33            13
##  [628,]        22     32          27         26    32            17
##  [629,]        21     32          26         26    32            21
##  [630,]        24     34          23         24    33            23
##  [631,]        26     35          20         22    39            21
##  [632,]        27     32          20         23    37            15
##  [633,]        27     33          22         26    34            15
##  [634,]        28     31          18         27    36            17
##  [635,]        28     35          21         24    31            19
##  [636,]        30     32          23         27    30            23
##  [637,]        30     32          21         27    34            25
##  [638,]        29     32          19         28    33            24
##  [639,]        29     27          17         32    32            21
##  [640,]        27     30          22         26    32            19
##  [641,]        26     25          24         28    37            21
##  [642,]        28     25          26         31    37            19
##  [643,]        22     25          22         29    38            21
##  [644,]        24     20          27         31    36            21
##  [645,]        24     19          26         32    33            24
##  [646,]        25     18          24         33    32            25
##  [647,]        28     20          23         33    32            23
##  [648,]        30     19          23         35    32            21
##  [649,]        31     18          21         40    37            22
##  [650,]        26     20          25         37    34            23
##  [651,]        25     19          21         33    35            18
##  [652,]        23     19          21         30    38            18
##  [653,]        27     19          24         31    35            18
##  [654,]        27     15          21         30    34            18
##  [655,]        26     17          19         28    34            20
##  [656,]        29     20          17         31    30            19
##  [657,]        26     21          23         29    28            21
##  [658,]        25     21          24         32    28            23
##  [659,]        27     19          23         29    30            20
##  [660,]        26     20          21         23    31            19
##  [661,]        25     19          25         25    32            18
##  [662,]        28     20          24         24    27            16
##  [663,]        27     20          24         26    31            19
##  [664,]        31     20          28         28    29            21
##  [665,]        33     23          25         28    31            23
##  [666,]        29     22          22         30    31            20
##  [667,]        32     22          20         25    35            14
##  [668,]        30     20          17         24    36            20
##  [669,]        27     19          19         25    36            22
##  [670,]        25     22          28         24    36            26
##  [671,]        25     23          32         25    38            22
##  [672,]        23     22          32         23    42            21
##  [673,]        24     20          33         22    42            20
##  [674,]        25     20          32         24    40            22
##  [675,]        26     23          29         21    45            23
##  [676,]        23     26          27         24    41            23
##  [677,]        24     23          25         24    46            24
##  [678,]        29     22          26         19    44            21
##  [679,]        26     24          23         20    44            21
##  [680,]        24     25          17         19    43            23
##  [681,]        23     30          20         18    39            22
##  [682,]        24     30          21         18    41            21
##  [683,]        23     24          21         22    39            18
##  [684,]        20     21          18         26    32            20
##  [685,]        25     22          22         25    28            17
##  [686,]        25     26          21         26    30            16
##  [687,]        20     29          22         26    31            16
##  [688,]        21     32          24         18    31            16
##  [689,]        24     32          28         18    32            17
##  [690,]        25     27          25         21    33            17
##  [691,]        25     26          28         19    30            20
##  [692,]        26     26          28         21    27            18
##  [693,]        23     25          28         22    33            16
##  [694,]        25     23          29         21    36            18
##  [695,]        22     21          32         21    34            21
##  [696,]        20     19          29         23    37            20
##  [697,]        24     21          26         22    35            18
##  [698,]        21     18          25         25    41            20
##  [699,]        20     23          22         24    37            20
##  [700,]        20     25          22         23    35            20
##  [701,]        18     26          23         23    33            20
##  [702,]        22     27          22         25    31            22
##  [703,]        19     29          23         22    32            18
##  [704,]        22     30          23         27    32            18
##  [705,]        27     29          25         30    31            18
##  [706,]        28     27          22         29    31            20
##  [707,]        28     23          24         22    34            22
##  [708,]        26     26          22         25    33            25
##  [709,]        25     24          23         25    33            26
##  [710,]        29     19          24         28    32            27
##  [711,]        31     16          23         27    35            27
##  [712,]        31     17          20         33    33            26
##  [713,]        32     18          19         33    32            23
##  [714,]        32     14          22         27    28            25
##  [715,]        30     16          18         28    30            27
##  [716,]        33     14          18         26    33            25
##  [717,]        31     16          23         25    32            22
##  [718,]        25     17          21         25    35            23
##  [719,]        24     14          18         30    30            25
##  [720,]        23     14          17         28    34            25
##  [721,]        23     16          24         28    36            23
##  [722,]        22     19          24         26    38            26
##  [723,]        21     20          25         28    36            23
##  [724,]        23     21          24         24    40            24
##  [725,]        30     22          18         25    39            25
##  [726,]        29     24          23         26    37            22
##  [727,]        26     25          22         29    29            25
##  [728,]        26     21          22         27    30            27
##  [729,]        26     19          20         27    29            25
##  [730,]        25     20          23         29    30            27
##  [731,]        28     18          19         29    31            27
##  [732,]        31     18          20         26    31            29
##  [733,]        27     19          20         26    31            22
##  [734,]        24     19          23         26    30            22
##  [735,]        22     24          21         25    32            19
##  [736,]        22     25          22         23    34            20
##  [737,]        26     26          18         24    27            17
##  [738,]        30     23          17         26    29            19
##  [739,]        24     24          12         23    34            21
##  [740,]        22     26          14         22    35            23
##  [741,]        19     23          16         22    34            21
##  [742,]        20     23          18         25    34            18
##  [743,]        17     21          17         22    38            16
##  [744,]        16     21          19         28    34            18
##  [745,]        18     20          20         29    35            17
##  [746,]        19     23          22         23    32            17
##  [747,]        18     24          22         26    33            17
##  [748,]        18     24          23         21    34            13
##  [749,]        16     15          28         18    29            14
##  [750,]        20     19          23         18    34            15
##  [751,]        23     19          22         15    36            21
##  [752,]        21     18          24         17    34            24
##  [753,]        24     20          26         23    39            25
##  [754,]        25     19          29         24    39            25
##  [755,]        23     21          30         25    39            19
##  [756,]        21     23          25         22    40            17
##  [757,]        23     22          22         18    39            18
##  [758,]        24     28          23         20    35            15
##  [759,]        27     26          21         21    34            20
##  [760,]        27     20          24         25    36            17
##  [761,]        34     16          28         22    31            16
##  [762,]        30     20          25         25    34            13
##  [763,]        33     18          21         21    35            14
##  [764,]        29     16          18         26    34            12
##  [765,]        29     15          22         29    29            15
##  [766,]        27     14          24         30    30            15
##  [767,]        26     16          22         33    33            11
##  [768,]        25     16          18         30    30            15
##  [769,]        20     17          21         29    27            18
##  [770,]        20     16          24         32    29            18
##  [771,]        21     18          30         25    30            19
##  [772,]        20     16          28         23    33            23
##  [773,]        20     20          27         23    32            22
##  [774,]        19     22          29         21    32            26
##  [775,]        20     24          24         25    30            26
##  [776,]        21     20          26         27    32            26
##  [777,]        24     20          24         23    31            25
##  [778,]        23     22          26         13    34            26
##  [779,]        24     18          25         20    33            27
##  [780,]        25     16          22         22    37            24
##  [781,]        26     19          21         19    35            22
##  [782,]        27     18          23         20    35            23
##  [783,]        26     15          22         24    37            24
##  [784,]        25     16          24         23    40            14
##  [785,]        23     17          20         20    38            15
##  [786,]        24     20          20         20    37            16
##  [787,]        22     23          22         20    39            16
##  [788,]        19     22          20         24    39            15
##  [789,]        17     24          25         27    37            14
##  [790,]        17     26          23         26    39            14
##  [791,]        18     27          29         25    39            14
##  [792,]        17     30          28         28    36            14
##  [793,]        22     30          27         26    34            18
##  [794,]        19     31          25         22    35            18
##  [795,]        18     25          24         23    31            17
##  [796,]        17     27          24         22    31            16
##  [797,]        20     27          25         22    27            18
##  [798,]        17     30          27         24    26            17
##  [799,]        19     32          27         22    25            18
##  [800,]        18     32          29         21    29            20
##  [801,]        24     28          29         26    27            21
##  [802,]        28     28          27         28    25            19
##  [803,]        30     29          32         24    28            19
##  [804,]        23     27          28         25    29            19
##  [805,]        27     26          31         23    28            21
##  [806,]        25     26          30         24    28            16
##  [807,]        28     31          27         20    27            23
##  [808,]        27     31          25         19    26            24
##  [809,]        25     30          23         15    30            26
##  [810,]        25     28          24         17    31            26
##  [811,]        23     27          23         16    25            27
##  [812,]        28     28          21         17    30            29
##  [813,]        28     26          19         21    31            27
##  [814,]        24     28          18         21    30            28
##  [815,]        23     30          18         21    32            23
##  [816,]        25     27          24         23    34            24
##  [817,]        32     25          21         26    38            25
##  [818,]        29     21          19         24    36            23
##  [819,]        26     21          23         23    35            21
##  [820,]        25     18          24         24    34            21
##  [821,]        25     18          24         26    34            21
##  [822,]        21     20          25         26    35            26
##  [823,]        20     19          26         29    32            25
##  [824,]        22     24          23         31    33            24
##  [825,]        25     24          19         31    32            24
##  [826,]        24     27          21         31    36            24
##  [827,]        24     27          23         23    38            23
##  [828,]        26     30          27         24    36            27
##  [829,]        29     30          24         26    35            22
##  [830,]        28     35          21         24    36            22
##  [831,]        31     30          22         25    39            21
##  [832,]        29     34          23         26    35            24
##  [833,]        27     32          22         25    36            22
##  [834,]        30     27          20         30    31            20
##  [835,]        25     26          19         31    32            21
##  [836,]        26     24          17         28    35            22
##  [837,]        26     25          21         24    33            21
##  [838,]        28     23          21         26    30            22
##  [839,]        32     30          23         24    30            21
##  [840,]        28     32          25         21    31            20
##  [841,]        28     31          27         16    29            20
##  [842,]        26     34          27         16    31            23
##  [843,]        28     29          29         14    34            19
##  [844,]        30     25          28         16    34            19
##  [845,]        25     30          32         19    30            14
##  [846,]        27     24          29         18    31            13
##  [847,]        30     23          26         19    33            14
##  [848,]        31     24          22         18    33            14
##  [849,]        30     27          21         16    36            15
##  [850,]        29     27          22         14    37            15
##  [851,]        30     29          24         15    36            17
##  [852,]        29     27          29         15    35            19
##  [853,]        31     24          31         14    34            21
##  [854,]        32     23          29         19    36            21
##  [855,]        29     25          27         19    37            22
##  [856,]        33     24          28         17    33            22
##  [857,]        33     22          29         17    31            21
##  [858,]        27     22          27         19    30            21
##  [859,]        27     19          23         20    31            20
##  [860,]        25     22          24         22    33            22
##  [861,]        28     18          28         26    30            18
##  [862,]        25     18          27         26    30            19
##  [863,]        29     18          23         23    28            17
##  [864,]        30     16          24         27    28            19
##  [865,]        29     17          25         22    30            16
##  [866,]        31     17          25         24    29            16
##  [867,]        26     17          24         20    30            19
##  [868,]        23     16          27         25    29            19
##  [869,]        27     16          31         25    28            18
##  [870,]        25     18          29         23    27            20
##  [871,]        31     16          25         22    26            20
##  [872,]        28     14          24         22    28            23
##  [873,]        30     15          22         25    28            22
##  [874,]        28     17          22         23    31            22
##  [875,]        28     19          22         25    30            19
##  [876,]        32     19          26         29    32            18
##  [877,]        31     22          25         26    32            20
##  [878,]        29     22          25         21    35            24
##  [879,]        32     27          23         21    29            21
##  [880,]        30     25          26         20    32            23
##  [881,]        28     28          24         20    33            22
##  [882,]        29     22          25         19    34            24
##  [883,]        32     19          24         18    33            23
##  [884,]        36     19          25         17    29            25
##  [885,]        34     23          21         17    32            27
##  [886,]        36     24          23         20    27            23
##  [887,]        36     19          25         22    29            20
##  [888,]        34     21          24         23    22            20
##  [889,]        34     21          23         20    31            21
##  [890,]        35     19          23         24    24            23
##  [891,]        28     13          28         25    23            26
##  [892,]        25     15          25         25    22            26
##  [893,]        27     15          21         27    24            28
##  [894,]        25     16          20         24    26            29
##  [895,]        24     18          23         27    31            25
##  [896,]        25     20          24         27    34            19
##  [897,]        23     18          24         30    37            22
##  [898,]        24     22          23         28    34            19
##  [899,]        27     23          23         27    31            17
##  [900,]        27     28          27         23    31            18
##  [901,]        33     25          27         23    32            19
##  [902,]        36     26          25         22    30            20
##  [903,]        32     27          25         20    32            23
##  [904,]        29     24          28         18    32            19
##  [905,]        29     22          29         18    38            15
##  [906,]        33     24          24         20    39            21
##  [907,]        30     26          26         21    39            20
##  [908,]        25     30          27         23    39            17
##  [909,]        25     27          27         22    35            16
##  [910,]        24     24          25         25    38            16
##  [911,]        24     24          23         28    38            15
##  [912,]        29     22          25         26    37            14
##  [913,]        27     21          26         25    35            16
##  [914,]        28     18          24         29    34            14
##  [915,]        29     21          20         27    33            14
##  [916,]        29     23          19         27    27            16
##  [917,]        31     28          21         20    31            10
##  [918,]        31     26          16         21    33             8
##  [919,]        31     24          20         19    33             9
##  [920,]        31     19          18         20    35            11
##  [921,]        34     24          21         21    34            12
##  [922,]        34     23          25         26    40            12
##  [923,]        30     20          22         26    35            12
##  [924,]        27     18          22         24    32            11
##  [925,]        27     20          18         25    30            14
##  [926,]        28     24          16         25    30            15
##  [927,]        27     26          19         25    32            17
##  [928,]        29     25          16         25    30            16
##  [929,]        26     28          19         21    27            14
##  [930,]        24     26          18         25    30            13
##  [931,]        25     25          17         24    27            19
##  [932,]        24     24          21         23    31            18
##  [933,]        24     20          18         25    33            16
##  [934,]        25     19          23         23    33            20
##  [935,]        26     25          24         21    28            17
##  [936,]        29     24          27         21    28            19
##  [937,]        26     22          23         22    24            17
##  [938,]        25     28          21         16    26            18
##  [939,]        29     26          18         20    25            16
##  [940,]        31     28          18         21    28            16
##  [941,]        29     26          20         20    31            16
##  [942,]        30     23          23         18    24            12
##  [943,]        29     27          25         16    29            17
##  [944,]        28     24          31         16    26            17
##  [945,]        29     20          29         20    29            17
##  [946,]        28     26          28         23    28            16
##  [947,]        29     24          23         24    28            21
##  [948,]        31     32          22         21    33            23
##  [949,]        26     36          21         21    33            21
##  [950,]        32     36          23         18    32            20
##  [951,]        32     36          21         19    31            24
##  [952,]        28     35          20         18    34            25
##  [953,]        26     36          17         18    36            22
##  [954,]        26     36          16         18    33            25
##  [955,]        25     36          20         19    29            25
##  [956,]        26     33          22         21    33            28
##  [957,]        26     29          21         18    36            33
##  [958,]        29     29          24         18    34            31
##  [959,]        24     31          26         20    32            31
##  [960,]        26     29          25         22    32            26
##  [961,]        26     27          27         21    30            27
##  [962,]        27     27          28         20    31            24
##  [963,]        28     27          26         19    29            28
##  [964,]        26     28          28         18    30            28
##  [965,]        23     28          28         21    24            29
##  [966,]        19     32          30         23    24            27
##  [967,]        17     28          31         26    27            21
##  [968,]        20     30          36         25    27            22
##  [969,]        19     30          34         26    25            21
##  [970,]        22     29          31         24    31            25
##  [971,]        22     27          31         25    36            22
##  [972,]        22     28          29         28    34            23
##  [973,]        22     25          25         27    34            25
##  [974,]        22     27          23         27    34            23
##  [975,]        24     27          22         25    35            23
##  [976,]        23     28          25         26    36            20
##  [977,]        19     28          26         25    42            18
##  [978,]        22     29          25         26    39            18
##  [979,]        20     28          25         29    39            20
##  [980,]        16     27          29         32    38            20
##  [981,]        22     23          28         29    36            17
##  [982,]        26     22          21         27    31            23
##  [983,]        32     21          19         27    32            23
##  [984,]        35     21          19         28    26            23
##  [985,]        35     20          20         31    26            20
##  [986,]        29     20          21         27    27            20
##  [987,]        29     18          22         27    27            20
##  [988,]        24     20          23         24    30            23
##  [989,]        26     21          23         24    33            24
##  [990,]        27     25          20         25    33            24
##  [991,]        27     25          18         25    33            24
##  [992,]        28     24          16         21    34            23
##  [993,]        30     31          16         22    31            23
##  [994,]        31     27          20         23    32            23
##  [995,]        31     26          20         23    34            23
##  [996,]        29     26          15         23    32            27
##  [997,]        30     27          20         29    34            23
##  [998,]        26     22          20         28    34            23
##  [999,]        28     23          19         27    34            22
## [1000,]        27     23          21         26    36            22
##         ShelveLoc.Good ShelveLoc.Medium Age Education Urban.Yes US.Yes
##    [1,]             17               17  22        20        22     21
##    [2,]             17               19  19        16        22     22
##    [3,]             20               16  21        14        24     19
##    [4,]             24               18  21        14        22     21
##    [5,]             20               19  20        14        24     17
##    [6,]             23               18  22        14        21     16
##    [7,]             24               19  20        13        26     17
##    [8,]             23               20  18        16        29     17
##    [9,]             25               22  20        16        27     17
##   [10,]             26               19  21        17        26     15
##   [11,]             24               19  22        18        28     18
##   [12,]             27               21  19        17        27     21
##   [13,]             23               20  16        15        26     23
##   [14,]             26               17  16        19        21     24
##   [15,]             27               23  17        18        21     24
##   [16,]             26               25  20        16        18     23
##   [17,]             22               26  16        14        21     25
##   [18,]             23               26  16        16        20     27
##   [19,]             23               24  17        17        20     22
##   [20,]             21               24  22        22        18     21
##   [21,]             20               27  20        21        19     24
##   [22,]             19               29  15        22        18     27
##   [23,]             19               31  15        23        22     28
##   [24,]             18               28  15        25        23     25
##   [25,]             22               31  15        23        19     24
##   [26,]             23               26  20        23        20     24
##   [27,]             22               28  21        23        18     23
##   [28,]             20               25  19        22        18     24
##   [29,]             21               25  18        21        20     24
##   [30,]             22               22  17        24        18     27
##   [31,]             21               20  16        23        21     26
##   [32,]             22               21  11        22        18     24
##   [33,]             20               21  13        24        15     28
##   [34,]             20               20  14        20        15     28
##   [35,]             22               18  14        19        15     26
##   [36,]             24               18  22        17        17     24
##   [37,]             26               17  17        15        18     20
##   [38,]             22               21  18        17        22     22
##   [39,]             19               28  19        16        19     21
##   [40,]             18               26  17        17        21     21
##   [41,]             19               29  16        19        21     21
##   [42,]             23               24  20        17        14     18
##   [43,]             25               24  20        20        20     15
##   [44,]             27               20  19        19        25     19
##   [45,]             26               21  21        20        23     17
##   [46,]             27               23  18        20        21     22
##   [47,]             28               23  18        21        18     23
##   [48,]             26               23  21        21        15     20
##   [49,]             24               19  23        22        17     20
##   [50,]             20               22  20        21        16     20
##   [51,]             21               20  23        25        14     22
##   [52,]             19               19  20        22        15     22
##   [53,]             21               21  27        21        16     23
##   [54,]             21               20  23        21        16     25
##   [55,]             21               21  22        23        14     25
##   [56,]             23               16  21        22        15     25
##   [57,]             26               12  19        24        14     28
##   [58,]             25               11  18        19        16     32
##   [59,]             25               12  18        20        17     29
##   [60,]             24               17  17        23        17     25
##   [61,]             29               22  14        21        21     27
##   [62,]             28               22  15        21        21     21
##   [63,]             28               20  16        23        20     21
##   [64,]             25               17  16        24        19     27
##   [65,]             23               14  22        25        20     25
##   [66,]             23               16  16        25        17     24
##   [67,]             23               18  20        25        21     24
##   [68,]             22               18  18        25        19     27
##   [69,]             23               20  18        23        19     27
##   [70,]             22               18  20        24        18     28
##   [71,]             23               16  18        22        15     29
##   [72,]             26               17  19        20        17     25
##   [73,]             20               18  20        22        19     25
##   [74,]             25               17  21        19        23     27
##   [75,]             28               18  21        20        23     25
##   [76,]             25               18  18        19        18     22
##   [77,]             24               15  17        19        15     24
##   [78,]             24               17  18        20        16     24
##   [79,]             21               24  17        23        17     25
##   [80,]             21               18  15        23        20     28
##   [81,]             22               17  20        27        20     20
##   [82,]             19               17  21        32        21     20
##   [83,]             19               18  16        31        20     21
##   [84,]             20               24  15        29        20     26
##   [85,]             20               23  17        30        22     19
##   [86,]             18               21  17        29        24     20
##   [87,]             23               22  16        26        25     23
##   [88,]             22               21  17        26        25     21
##   [89,]             22               19  18        26        25     21
##   [90,]             27               19  17        22        24     20
##   [91,]             26               22  21        24        16     21
##   [92,]             21               23  17        20        19     21
##   [93,]             22               17  14        19        16     28
##   [94,]             23               18  17        16        18     30
##   [95,]             24               20  21        20        17     25
##   [96,]             27               20  23        20        17     23
##   [97,]             25               21  24        19        14     19
##   [98,]             19               25  26        17        16     23
##   [99,]             20               22  27        18        15     21
##  [100,]             21               21  24        21        18     26
##  [101,]             20               22  23        25        17     27
##  [102,]             21               22  21        21        20     27
##  [103,]             19               20  24        21        17     24
##  [104,]             17               17  25        19        15     22
##  [105,]             18               19  23        16        19     20
##  [106,]             19               19  27        14        15     20
##  [107,]             23               19  30        14        16     21
##  [108,]             23               21  31        17        17     18
##  [109,]             22               25  29        20        16     17
##  [110,]             20               26  29        18        13     17
##  [111,]             18               25  25        19        12     21
##  [112,]             16               21  24        18        10     20
##  [113,]             16               20  24        22        13     21
##  [114,]             21               17  19        21        13     19
##  [115,]             19               19  19        20        12     18
##  [116,]             19               15  23        21        11     21
##  [117,]             16               15  22        21        15     25
##  [118,]             15               12  21        26        14     26
##  [119,]             16               12  21        28        14     24
##  [120,]             21               14  21        26        14     25
##  [121,]             16               19  26        22        12     22
##  [122,]             18               17  23        30        13     24
##  [123,]             18               15  26        26        16     23
##  [124,]             18               16  22        28        12     22
##  [125,]             20               18  21        27        14     23
##  [126,]             21               20  19        27        11     21
##  [127,]             21               20  20        24        16     20
##  [128,]             23               17  15        23        15     24
##  [129,]             24               14  18        24        16     21
##  [130,]             24               14  19        22        17     26
##  [131,]             28               12  23        18        16     27
##  [132,]             28               11  24        17        19     25
##  [133,]             23               16  21        15        24     24
##  [134,]             23               14  26        16        16     24
##  [135,]             25               16  29        16        15     27
##  [136,]             24               16  28        15        17     28
##  [137,]             27               14  24        21        16     28
##  [138,]             26               15  23        22        17     27
##  [139,]             30               21  20        22        17     29
##  [140,]             30               24  19        20        19     25
##  [141,]             30               22  21        18        18     23
##  [142,]             28               22  17        17        22     26
##  [143,]             27               20  16        19        20     26
##  [144,]             29               16  15        23        22     23
##  [145,]             25               15  14        22        24     22
##  [146,]             26               15  15        23        21     24
##  [147,]             23               18  16        26        23     22
##  [148,]             19               18  17        25        24     25
##  [149,]             19               14  13        21        24     24
##  [150,]             18               15  16        20        26     22
##  [151,]             20               19  15        19        22     17
##  [152,]             22               19  13        19        23     19
##  [153,]             24               17  16        19        21     20
##  [154,]             19               20  18        17        18     21
##  [155,]             20               19  23        15        17     21
##  [156,]             18               16  22        16        17     22
##  [157,]             21               19  20        17        17     21
##  [158,]             22               18  17        15        17     22
##  [159,]             22               18  17        19        15     22
##  [160,]             24               19  17        22        16     25
##  [161,]             26               18  16        19        13     24
##  [162,]             27               16  16        16        13     25
##  [163,]             24               13  18        18        13     27
##  [164,]             25               12  19        15        15     25
##  [165,]             27               16  21        16        17     26
##  [166,]             29               16  17        19        18     24
##  [167,]             29               18  15        19        21     26
##  [168,]             29               16  18        20        17     27
##  [169,]             23               20  18        21        16     30
##  [170,]             22               20  19        21        20     28
##  [171,]             21               20  14        20        19     31
##  [172,]             22               19  16        22        20     30
##  [173,]             22               15  19        25        19     29
##  [174,]             23               19  22        22        18     26
##  [175,]             26               20  19        23        18     27
##  [176,]             26               20  23        25        19     32
##  [177,]             29               23  23        23        17     36
##  [178,]             27               25  23        23        16     31
##  [179,]             30               20  22        16        15     32
##  [180,]             29               17  20        17        16     32
##  [181,]             30               16  27        18        20     31
##  [182,]             29               19  25        18        19     33
##  [183,]             30               22  23        18        19     30
##  [184,]             34               21  23        18        16     28
##  [185,]             26               15  18        18        20     27
##  [186,]             27               12  17        18        19     23
##  [187,]             28               14  16        19        15     24
##  [188,]             24               17  21        14        14     24
##  [189,]             23               20  23        14        14     26
##  [190,]             17               20  23        16        16     23
##  [191,]             19               19  24        15        14     23
##  [192,]             19               17  27        16        19     24
##  [193,]             21               17  25        16        16     21
##  [194,]             20               22  27        22        21     19
##  [195,]             23               19  22        25        18     21
##  [196,]             21               17  23        28        17     18
##  [197,]             19               15  26        24        20     20
##  [198,]             19               18  24        26        18     25
##  [199,]             18               16  27        23        17     25
##  [200,]             19               17  27        23        17     28
##  [201,]             19               19  26        26        18     26
##  [202,]             19               20  26        24        19     27
##  [203,]             18               17  26        26        20     29
##  [204,]             21               17  27        26        20     32
##  [205,]             13               17  25        23        20     33
##  [206,]             15               17  23        24        22     28
##  [207,]             19               17  23        25        23     26
##  [208,]             19               19  22        24        23     26
##  [209,]             15               16  21        26        22     24
##  [210,]             21               14  21        27        22     23
##  [211,]             17               14  23        23        21     23
##  [212,]             15               17  22        24        22     23
##  [213,]             15               19  22        26        21     24
##  [214,]             18               19  23        27        18     26
##  [215,]             17               15  24        27        15     24
##  [216,]             17               16  27        25        16     26
##  [217,]             18               16  29        24        16     30
##  [218,]             19               17  23        23        22     29
##  [219,]             21               18  21        25        24     28
##  [220,]             22               15  27        24        17     28
##  [221,]             22               17  27        25        18     28
##  [222,]             24               15  32        19        18     25
##  [223,]             23               22  33        18        17     26
##  [224,]             22               18  31        20        16     27
##  [225,]             21               20  31        18        16     25
##  [226,]             19               20  28        20        18     24
##  [227,]             18               19  26        18        19     28
##  [228,]             19               21  27        18        19     27
##  [229,]             18               22  28        20        18     29
##  [230,]             16               24  26        20        16     24
##  [231,]             17               22  28        23        17     23
##  [232,]             16               25  29        19        19     24
##  [233,]             18               23  27        20        21     27
##  [234,]             22               19  27        20        21     27
##  [235,]             19               22  30        19        20     28
##  [236,]             16               17  26        25        19     32
##  [237,]             23               12  25        25        23     29
##  [238,]             25               16  24        21        21     29
##  [239,]             26               16  26        21        19     28
##  [240,]             22               11  24        22        19     30
##  [241,]             23                9  25        20        23     32
##  [242,]             22                8  22        21        25     32
##  [243,]             21                8  19        18        25     28
##  [244,]             22               11  16        16        22     27
##  [245,]             23               10  20        19        23     23
##  [246,]             23               10  20        19        22     21
##  [247,]             27               12  20        22        23     24
##  [248,]             17               14  21        26        24     24
##  [249,]             17               16  22        28        25     22
##  [250,]             19               16  22        28        21     23
##  [251,]             21               15  19        28        23     20
##  [252,]             23               11  17        29        27     23
##  [253,]             22               16  18        27        26     29
##  [254,]             19               14  21        29        27     30
##  [255,]             18               16  20        27        22     28
##  [256,]             17               16  23        28        23     31
##  [257,]             17               14  24        26        20     27
##  [258,]             18               14  27        26        20     25
##  [259,]             18               14  24        27        18     27
##  [260,]             20               15  30        28        22     29
##  [261,]             15               13  27        25        24     26
##  [262,]             16               15  31        23        23     24
##  [263,]             15               14  29        21        27     19
##  [264,]             16               15  29        23        20     20
##  [265,]             21               14  29        18        22     17
##  [266,]             26               12  32        18        19     17
##  [267,]             24               13  31        17        20     15
##  [268,]             25               14  28        17        20     15
##  [269,]             20               16  29        22        18     16
##  [270,]             21               16  30        23        23     15
##  [271,]             26               20  25        23        22     16
##  [272,]             27               17  22        20        22     17
##  [273,]             27               16  19        20        22     20
##  [274,]             26               14  20        17        22     18
##  [275,]             23               16  20        18        21     18
##  [276,]             26               11  22        18        24     18
##  [277,]             29               12  19        21        24     22
##  [278,]             28               14  17        22        21     22
##  [279,]             28               13  19        21        21     20
##  [280,]             31               15  18        25        20     21
##  [281,]             29               15  18        26        22     25
##  [282,]             30               13  18        30        22     27
##  [283,]             25               15  19        28        22     27
##  [284,]             20               18  17        26        23     24
##  [285,]             21               16  21        21        22     22
##  [286,]             21               20  17        22        24     21
##  [287,]             24               16  18        21        24     20
##  [288,]             25               22  15        24        25     18
##  [289,]             18               23  16        29        28     22
##  [290,]             19               22  20        28        28     24
##  [291,]             17               17  21        24        26     23
##  [292,]             22               15  22        20        26     20
##  [293,]             24               18  17        18        26     22
##  [294,]             21               15  16        17        24     24
##  [295,]             18               15  13        19        25     24
##  [296,]             18               13  16        19        24     22
##  [297,]             19               12  17        19        22     26
##  [298,]             19               14  17        18        25     23
##  [299,]             21               13  18        18        24     26
##  [300,]             25               17  22        19        20     28
##  [301,]             25               19  23        25        20     27
##  [302,]             25               21  22        27        20     27
##  [303,]             26               22  23        28        22     32
##  [304,]             26               23  21        24        21     28
##  [305,]             23               22  21        28        23     25
##  [306,]             26               26  22        26        18     26
##  [307,]             26               27  22        25        21     27
##  [308,]             23               30  23        27        16     28
##  [309,]             21               25  22        28        17     24
##  [310,]             21               23  17        25        16     21
##  [311,]             20               22  16        25        21     23
##  [312,]             22               23  19        25        24     27
##  [313,]             23               21  18        23        25     27
##  [314,]             20               19  17        30        23     26
##  [315,]             24               17  19        30        20     26
##  [316,]             26               17  19        31        18     26
##  [317,]             26               15  18        31        17     26
##  [318,]             24               19  17        32        13     26
##  [319,]             19               19  16        29        16     25
##  [320,]             22               18  18        29        18     25
##  [321,]             18               22  22        32        16     25
##  [322,]             16               22  21        33        15     22
##  [323,]             15               21  21        32        20     23
##  [324,]             23               21  21        30        18     19
##  [325,]             25               24  20        28        18     22
##  [326,]             26               22  28        28        16     21
##  [327,]             26               20  25        31        15     21
##  [328,]             22               18  21        29        21     20
##  [329,]             21               22  17        30        22     22
##  [330,]             22               20  17        29        25     19
##  [331,]             25               20  19        27        23     20
##  [332,]             23               20  22        26        27     20
##  [333,]             21               16  20        27        27     23
##  [334,]             24               18  23        25        27     21
##  [335,]             27               21  26        26        28     21
##  [336,]             24               19  25        26        26     17
##  [337,]             23               18  25        30        20     16
##  [338,]             21               18  27        27        21     18
##  [339,]             23               18  28        30        20     16
##  [340,]             21               18  27        31        17     14
##  [341,]             22               19  27        33        17     13
##  [342,]             23               22  29        33        14     12
##  [343,]             21               20  32        30        14     14
##  [344,]             22               24  30        30        16     16
##  [345,]             18               24  29        31        15     14
##  [346,]             19               22  27        30        17     18
##  [347,]             19               24  24        30        18     17
##  [348,]             17               27  22        28        19     16
##  [349,]             19               27  23        28        16     18
##  [350,]             18               28  22        29        16     20
##  [351,]             18               27  23        29        20     20
##  [352,]             21               27  21        28        22     21
##  [353,]             21               30  21        31        19     20
##  [354,]             24               28  21        30        18     23
##  [355,]             21               28  24        28        14     23
##  [356,]             24               28  25        21        16     18
##  [357,]             25               29  23        21        12     18
##  [358,]             22               28  23        23        14     16
##  [359,]             21               25  22        21        14     18
##  [360,]             19               24  18        18        10     19
##  [361,]             14               23  20        21        15     18
##  [362,]             15               25  19        26        13     18
##  [363,]             20               24  22        29        12     16
##  [364,]             19               23  19        26        12     20
##  [365,]             16               22  21        21        15     21
##  [366,]             18               20  23        23        14     22
##  [367,]             19               19  22        21        18     28
##  [368,]             18               21  22        24        19     27
##  [369,]             21               20  20        24        17     23
##  [370,]             19               20  24        28        20     19
##  [371,]             21               19  22        26        21     20
##  [372,]             19               21  22        22        25     21
##  [373,]             17               25  20        24        23     16
##  [374,]             16               25  18        21        21     19
##  [375,]             21               22  18        25        24     15
##  [376,]             19               22  20        24        21     18
##  [377,]             19               20  20        22        21     18
##  [378,]             20               20  19        24        21     17
##  [379,]             21               20  18        26        24     14
##  [380,]             22               24  17        26        26     16
##  [381,]             23               23  20        23        27     21
##  [382,]             25               25  19        18        21     18
##  [383,]             29               26  20        17        21     18
##  [384,]             22               26  15        22        25     16
##  [385,]             22               26  16        22        22     18
##  [386,]             24               25  13        23        23     16
##  [387,]             26               21  15        25        25     20
##  [388,]             24               18  20        26        26     20
##  [389,]             20               19  25        30        25     18
##  [390,]             15               22  24        24        22     19
##  [391,]             21               22  24        23        22     25
##  [392,]             20               22  29        22        19     24
##  [393,]             13               21  25        23        22     22
##  [394,]             13               23  22        22        25     18
##  [395,]             13               20  23        20        27     20
##  [396,]             15               20  25        23        27     24
##  [397,]             17               22  23        23        26     24
##  [398,]             19               19  19        25        25     22
##  [399,]             20               12  18        24        21     26
##  [400,]             23               14  19        22        23     24
##  [401,]             23               16  18        23        18     22
##  [402,]             21               13  21        24        21     26
##  [403,]             22               13  27        21        23     24
##  [404,]             21               12  26        21        29     24
##  [405,]             20               13  27        27        29     23
##  [406,]             18               13  25        25        29     22
##  [407,]             18               13  23        22        26     29
##  [408,]             16               16  23        19        24     24
##  [409,]             13               15  20        18        25     25
##  [410,]             15               14  21        19        24     26
##  [411,]             17               18  22        17        26     27
##  [412,]             17               17  23        19        24     25
##  [413,]             18               16  24        19        24     26
##  [414,]             15               21  25        26        19     25
##  [415,]             16               27  25        18        16     27
##  [416,]             19               27  22        23        18     27
##  [417,]             20               23  23        24        21     27
##  [418,]             24               29  20        25        24     26
##  [419,]             24               28  24        24        24     31
##  [420,]             23               28  25        20        25     29
##  [421,]             21               27  27        22        28     32
##  [422,]             20               24  29        23        23     27
##  [423,]             18               21  28        22        22     27
##  [424,]             21               25  24        23        24     24
##  [425,]             17               19  21        25        24     26
##  [426,]             17               21  21        21        21     23
##  [427,]             19               23  25        20        21     25
##  [428,]             16               27  26        23        21     25
##  [429,]             18               26  25        23        20     26
##  [430,]             18               29  24        18        21     30
##  [431,]             19               32  23        18        17     25
##  [432,]             19               30  27        16        18     23
##  [433,]             20               31  26        15        17     25
##  [434,]             16               29  17        16        17     23
##  [435,]             14               33  20        17        16     21
##  [436,]             12               32  23        17        20     20
##  [437,]             19               34  21        20        13     18
##  [438,]             22               31  20        19        12     25
##  [439,]             25               29  19        17        13     23
##  [440,]             25               27  20        21        17     19
##  [441,]             27               26  19        18        15     22
##  [442,]             24               22  20        19        15     22
##  [443,]             24               23  21        19        15     22
##  [444,]             20               26  22        22        19     18
##  [445,]             20               25  19        18        22     21
##  [446,]             20               29  18        16        24     19
##  [447,]             24               26  22        17        23     23
##  [448,]             26               30  22        17        19     24
##  [449,]             25               26  22        21        21     21
##  [450,]             23               25  19        21        20     23
##  [451,]             20               26  23        22        17     21
##  [452,]             26               22  24        22        20     25
##  [453,]             26               20  19        22        17     24
##  [454,]             25               23  19        24        19     24
##  [455,]             21               20  21        21        17     25
##  [456,]             23               24  20        24        21     25
##  [457,]             21               23  17        22        22     27
##  [458,]             24               22  16        19        26     26
##  [459,]             22               19  20        19        25     27
##  [460,]             23               17  21        22        22     27
##  [461,]             25               19  23        24        21     24
##  [462,]             24               22  22        19        19     23
##  [463,]             25               24  19        19        19     25
##  [464,]             24               20  17        18        25     25
##  [465,]             27               21  20        18        24     22
##  [466,]             28               22  18        19        24     24
##  [467,]             27               20  14        19        20     26
##  [468,]             26               21  14        17        19     25
##  [469,]             28               19  13        14        20     25
##  [470,]             26               18  12        16        19     25
##  [471,]             29               20  13        15        16     26
##  [472,]             26               17  14        21        17     29
##  [473,]             25               18  12        19        16     27
##  [474,]             20               15  18        20        19     28
##  [475,]             20               14  16        17        18     25
##  [476,]             20               16  17        18        18     26
##  [477,]             26               19  13        19        17     25
##  [478,]             25               21  14        22        11     25
##  [479,]             23               22  17        17        13     28
##  [480,]             21               19  16        19        15     31
##  [481,]             25               18  18        22        14     29
##  [482,]             24               19  22        20        14     25
##  [483,]             21               21  25        18        15     28
##  [484,]             18               22  23        21        16     27
##  [485,]             15               17  22        22        17     23
##  [486,]             15               16  16        23        18     25
##  [487,]             15               17  17        25        15     30
##  [488,]             15               20  17        28        15     27
##  [489,]             16               22  18        25        16     28
##  [490,]             19               20  19        24        12     25
##  [491,]             23               18  16        21        12     25
##  [492,]             20               23  14        20        15     27
##  [493,]             18               21  21        18        16     26
##  [494,]             17               20  17        19        17     28
##  [495,]             19               18  15        19        21     31
##  [496,]             19               16  12        19        18     33
##  [497,]             23               21  14        19        18     26
##  [498,]             25               22  13        22        15     24
##  [499,]             25               22  17        22        14     22
##  [500,]             27               15  18        17        13     27
##  [501,]             27               17  17        20        10     28
##  [502,]             23               19  19        16        14     24
##  [503,]             22               17  20        16        13     25
##  [504,]             22               17  17        16        12     26
##  [505,]             20               17  17        16        12     28
##  [506,]             19               18  20        14        12     29
##  [507,]             18               18  15        18        12     30
##  [508,]             14               19  16        21        14     35
##  [509,]             17               22  18        23        15     29
##  [510,]             20               16  16        22        14     31
##  [511,]             20               18  17        19        16     26
##  [512,]             20               15  13        23        17     25
##  [513,]             24               14  15        22        17     22
##  [514,]             18               15  19        21        20     23
##  [515,]             19               16  19        19        23     19
##  [516,]             19               15  18        21        22     23
##  [517,]             21               17  20        23        21     20
##  [518,]             18               16  19        28        22     21
##  [519,]             21               14  21        30        21     23
##  [520,]             20               14  25        26        22     25
##  [521,]             21               16  22        26        18     26
##  [522,]             18               21  18        28        18     22
##  [523,]             18               20  18        26        18     24
##  [524,]             19               23  19        20        17     24
##  [525,]             20               24  24        22        14     25
##  [526,]             21               23  20        22        16     24
##  [527,]             20               21  22        22        16     25
##  [528,]             20               18  23        24        19     25
##  [529,]             22               17  22        21        20     26
##  [530,]             20               20  23        16        20     28
##  [531,]             20               17  24        18        18     27
##  [532,]             16               23  25        15        19     28
##  [533,]             22               20  28        13        23     28
##  [534,]             24               21  26        13        25     27
##  [535,]             22               18  27        19        23     27
##  [536,]             24               17  21        17        23     29
##  [537,]             24               15  22        19        25     26
##  [538,]             24               16  23        24        24     23
##  [539,]             25               18  18        19        22     25
##  [540,]             28               20  18        13        23     24
##  [541,]             24               19  17        15        22     21
##  [542,]             23               19  20        12        22     23
##  [543,]             27               19  23        13        21     22
##  [544,]             24               21  22        20        21     26
##  [545,]             26               21  26        19        19     25
##  [546,]             27               24  22        19        19     26
##  [547,]             28               24  23        21        19     25
##  [548,]             24               24  27        17        15     29
##  [549,]             24               22  27        19        16     24
##  [550,]             26               19  29        17        15     21
##  [551,]             21               18  25        22        13     22
##  [552,]             20               21  25        20        14     18
##  [553,]             24               22  29        18        14     20
##  [554,]             26               23  29        16        12     22
##  [555,]             24               20  27        15        15     21
##  [556,]             22               23  26        15        16     21
##  [557,]             20               22  23        15        20     23
##  [558,]             20               22  24        16        18     22
##  [559,]             22               23  25        17        18     22
##  [560,]             21               22  27        14        18     23
##  [561,]             22               21  29        18        16     19
##  [562,]             25               23  30        13        17     20
##  [563,]             30               24  23        17        18     21
##  [564,]             29               25  21        15        18     22
##  [565,]             28               29  22        18        17     21
##  [566,]             21               30  19        23        20     24
##  [567,]             21               29  19        19        17     24
##  [568,]             20               28  20        17        13     26
##  [569,]             24               30  25        15        13     30
##  [570,]             21               33  21        16        13     28
##  [571,]             23               32  23        18        15     30
##  [572,]             23               29  21        16        13     23
##  [573,]             22               30  20        19        15     19
##  [574,]             19               29  22        19        11     14
##  [575,]             20               29  24        18        12     14
##  [576,]             21               28  17        18        14     16
##  [577,]             24               27  20        13        16     18
##  [578,]             26               21  21        14        16     20
##  [579,]             28               26  21        10        14     21
##  [580,]             24               26  17        14        15     23
##  [581,]             15               20  19        13        16     22
##  [582,]             15               18  21        12        18     25
##  [583,]             16               19  25        14        17     22
##  [584,]             18               22  25        19        17     20
##  [585,]             21               21  27        14        20     17
##  [586,]             26               20  22        15        20     17
##  [587,]             28               20  21        15        21     17
##  [588,]             27               18  15        14        23     21
##  [589,]             20               20  17        17        19     25
##  [590,]             21               18  19        18        17     21
##  [591,]             21               16  21        15        21     25
##  [592,]             23               19  17        10        21     25
##  [593,]             20               17  17        11        23     24
##  [594,]             24               17  18         9        26     26
##  [595,]             26               14  17        14        22     23
##  [596,]             26               14  16        11        21     24
##  [597,]             24               13  21        16        22     26
##  [598,]             22               11  21        14        26     26
##  [599,]             23               12  21        13        25     30
##  [600,]             28               16  21        12        24     30
##  [601,]             27               12  21        13        25     29
##  [602,]             26               17  21        14        26     25
##  [603,]             27               18  17        15        27     25
##  [604,]             28               20  18        14        28     28
##  [605,]             28               20  15        15        27     27
##  [606,]             25               22  16        17        25     25
##  [607,]             26               19  18        16        24     25
##  [608,]             25               18  18        19        22     23
##  [609,]             26               21  20        18        20     24
##  [610,]             22               21  21        20        20     24
##  [611,]             20               23  22        16        20     26
##  [612,]             21               26  20        18        23     27
##  [613,]             23               23  22        16        25     27
##  [614,]             24               20  25        21        24     24
##  [615,]             24               20  30        20        24     23
##  [616,]             22               19  24        17        24     24
##  [617,]             25               17  20        19        23     22
##  [618,]             20               15  22        22        22     23
##  [619,]             17               16  19        17        29     27
##  [620,]             14               21  20        20        27     25
##  [621,]             16               25  20        20        29     21
##  [622,]             15               25  20        16        27     21
##  [623,]             18               23  26        19        26     21
##  [624,]             19               22  22        19        23     18
##  [625,]             18               25  22        15        23     18
##  [626,]             19               25  26        17        24     17
##  [627,]             23               31  27        18        20     19
##  [628,]             26               28  22        20        19     21
##  [629,]             21               24  22        19        17     21
##  [630,]             21               25  19        13        19     17
##  [631,]             19               22  27        10        21     22
##  [632,]             19               19  26        15        20     22
##  [633,]             18               16  22        13        23     21
##  [634,]             20               20  21        14        18     19
##  [635,]             20               18  22        15        23     21
##  [636,]             23               18  21        15        22     21
##  [637,]             21               19  22        12        23     21
##  [638,]             21               16  25        12        23     22
##  [639,]             21               16  26        16        22     23
##  [640,]             17               15  27        16        26     23
##  [641,]             18               16  24        16        22     21
##  [642,]             19               13  24        18        24     22
##  [643,]             21               13  25        19        25     25
##  [644,]             23               15  25        18        25     25
##  [645,]             23               17  30        20        22     23
##  [646,]             20               18  25        23        21     22
##  [647,]             20               17  24        19        23     25
##  [648,]             21               16  25        19        20     23
##  [649,]             21               15  26        17        23     21
##  [650,]             19               17  29        18        21     23
##  [651,]             20               22  30        19        18     22
##  [652,]             23               20  28        23        17     21
##  [653,]             21               20  29        24        22     24
##  [654,]             19               18  32        23        20     22
##  [655,]             20               17  29        21        24     25
##  [656,]             21               17  23        18        24     27
##  [657,]             19               20  21        20        24     23
##  [658,]             20               20  20        23        29     20
##  [659,]             18               21  22        27        23     21
##  [660,]             28               18  22        24        24     24
##  [661,]             28               14  20        22        25     22
##  [662,]             24               17  18        23        26     26
##  [663,]             21               14  16        22        24     25
##  [664,]             22               15  16        22        26     22
##  [665,]             26               19  19        19        23     23
##  [666,]             24               23  20        15        23     26
##  [667,]             27               20  20        15        22     27
##  [668,]             23               22  19        16        20     27
##  [669,]             26               20  24        19        19     24
##  [670,]             24               20  24        19        19     22
##  [671,]             21               20  20        20        19     22
##  [672,]             20               18  18        25        19     24
##  [673,]             22               22  19        24        19     22
##  [674,]             23               23  20        20        17     23
##  [675,]             21               24  19        21        20     24
##  [676,]             21               27  19        24        19     20
##  [677,]             22               26  17        23        20     21
##  [678,]             21               24  23        18        26     20
##  [679,]             23               22  18        18        21     19
##  [680,]             23               24  21        19        19     21
##  [681,]             23               21  22        19        21     21
##  [682,]             24               21  22        18        21     21
##  [683,]             20               21  21        23        20     20
##  [684,]             19               20  23        28        22     19
##  [685,]             20               18  20        26        23     18
##  [686,]             16               15  23        28        22     19
##  [687,]             16               14  23        25        20     17
##  [688,]             18               16  25        26        20     21
##  [689,]             18               18  24        23        22     19
##  [690,]             19               17  22        22        25     18
##  [691,]             19               17  19        24        26     16
##  [692,]             17               17  17        25        29     21
##  [693,]             18               17  19        24        30     20
##  [694,]             18               17  20        25        26     21
##  [695,]             22               19  19        23        23     19
##  [696,]             18               23  18        22        25     23
##  [697,]             19               24  18        19        26     26
##  [698,]             21               20  15        19        25     21
##  [699,]             19               22  20        19        27     18
##  [700,]             26               23  19        20        28     16
##  [701,]             28               20  19        21        29     17
##  [702,]             27               20  16        23        26     18
##  [703,]             27               19  14        23        27     19
##  [704,]             19               20  20        24        26     17
##  [705,]             22               22  16        23        23     18
##  [706,]             26               23  16        17        25     16
##  [707,]             22               26  20        19        23     18
##  [708,]             21               21  22        17        21     17
##  [709,]             23               22  17        20        20     21
##  [710,]             24               24  18        17        24     18
##  [711,]             22               22  18        18        25     18
##  [712,]             24               19  18        16        22     22
##  [713,]             23               21  17        19        20     21
##  [714,]             20               22  15        21        19     20
##  [715,]             22               20  11        19        16     25
##  [716,]             22               21  11        17        18     26
##  [717,]             17               22  12        19        18     25
##  [718,]             19               22  18        15        15     30
##  [719,]             19               21  19        16        20     30
##  [720,]             19               21  15        17        22     24
##  [721,]             22               17  14        15        25     23
##  [722,]             21               16  15        14        22     22
##  [723,]             23               15  11        15        18     27
##  [724,]             19               17  17        14        21     23
##  [725,]             16               18  20        14        20     24
##  [726,]             17               20  20        15        21     25
##  [727,]             17               21  20        11        25     26
##  [728,]             20               20  18        14        24     24
##  [729,]             21               22  15        14        30     22
##  [730,]             20               22  19        14        27     24
##  [731,]             18               20  21        14        26     25
##  [732,]             19               18  23        20        25     26
##  [733,]             22               23  21        21        21     25
##  [734,]             26               21  20        17        19     29
##  [735,]             30               20  18        17        17     30
##  [736,]             31               21  17        13        19     29
##  [737,]             30               22  21        12        21     34
##  [738,]             27               25  18        13        21     34
##  [739,]             31               18  23        13        23     35
##  [740,]             29               21  21        15        22     37
##  [741,]             24               22  18        16        28     37
##  [742,]             24               22  16        17        28     37
##  [743,]             26               28  16        15        27     36
##  [744,]             25               22  17        15        25     38
##  [745,]             25               23  16        17        24     31
##  [746,]             25               21  21        16        25     30
##  [747,]             26               23  22        19        22     28
##  [748,]             26               26  21        18        18     33
##  [749,]             25               27  23        19        19     33
##  [750,]             21               25  28        18        19     33
##  [751,]             18               24  26        17        20     31
##  [752,]             16               28  23        15        19     34
##  [753,]             13               25  18        17        18     30
##  [754,]             13               23  14        16        23     24
##  [755,]             13               21  14        14        19     24
##  [756,]             16               22  14        14        20     22
##  [757,]             17               25  18        13        20     24
##  [758,]             18               22  17        16        20     23
##  [759,]             20               21  19        16        22     20
##  [760,]             18               22  23        16        20     21
##  [761,]             17               23  22        15        19     22
##  [762,]             16               19  27        14        19     24
##  [763,]             17               19  30        15        20     26
##  [764,]             21               22  28        12        20     26
##  [765,]             21               29  26        15        14     26
##  [766,]             21               27  25        18        13     29
##  [767,]             23               27  26        16        18     29
##  [768,]             24               27  26        17        18     31
##  [769,]             24               27  26        20        21     29
##  [770,]             23               24  27        17        17     25
##  [771,]             23               24  27        18        16     25
##  [772,]             21               23  28        13        16     30
##  [773,]             20               24  33        13        15     31
##  [774,]             19               26  31        16        19     29
##  [775,]             21               18  31        19        20     29
##  [776,]             25               20  31        17        16     31
##  [777,]             26               21  28        17        18     30
##  [778,]             27               18  27        18        18     28
##  [779,]             26               21  27        19        19     27
##  [780,]             24               22  25        23        18     26
##  [781,]             25               25  23        24        19     24
##  [782,]             26               16  24        25        21     24
##  [783,]             29               13  22        23        21     23
##  [784,]             26               16  21        23        22     25
##  [785,]             25               19  22        23        25     18
##  [786,]             24               21  25        25        20     21
##  [787,]             24               24  24        25        24     17
##  [788,]             31               24  25        25        21     16
##  [789,]             25               23  23        21        25     19
##  [790,]             21               23  24        20        21     18
##  [791,]             19               22  25        16        18     20
##  [792,]             19               20  24        18        20     21
##  [793,]             16               22  24        18        21     18
##  [794,]             17               22  24        18        20     20
##  [795,]             19               23  27        20        21     18
##  [796,]             19               23  23        20        23     18
##  [797,]             18               21  24        18        23     20
##  [798,]             19               20  21        19        22     22
##  [799,]             20               24  22        21        22     22
##  [800,]             20               19  22        19        23     21
##  [801,]             20               18  19        19        22     20
##  [802,]             20               16  16        23        24     23
##  [803,]             23               19  17        23        22     23
##  [804,]             27               17  17        27        24     20
##  [805,]             27               16  15        21        25     18
##  [806,]             24               19  16        19        27     21
##  [807,]             19               19  18        21        28     18
##  [808,]             23               17  18        25        28     19
##  [809,]             20               19  17        21        25     17
##  [810,]             23               18  14        23        24     17
##  [811,]             21               21  15        24        25     18
##  [812,]             16               20  14        28        25     20
##  [813,]             16               21  15        26        18     19
##  [814,]             17               19  18        23        20     19
##  [815,]             18               21  18        23        18     19
##  [816,]             18               21  19        26        15     17
##  [817,]             18               20  22        31        18     14
##  [818,]             20               21  25        33        17     19
##  [819,]             18               18  27        35        19     21
##  [820,]             17               16  26        33        22     19
##  [821,]             18               22  24        36        23     17
##  [822,]             17               22  22        32        21     19
##  [823,]             16               16  25        34        24     16
##  [824,]             16               14  27        32        23     18
##  [825,]             18               19  26        30        25     17
##  [826,]             17               20  23        27        24     13
##  [827,]             15               21  22        29        19     17
##  [828,]             17               21  20        25        20     20
##  [829,]             17               22  23        27        18     19
##  [830,]             17               20  20        22        18     14
##  [831,]             19               20  18        19        18     14
##  [832,]             19               20  17        21        16     15
##  [833,]             24               23  18        22        13     15
##  [834,]             23               21  19        22        14     12
##  [835,]             23               14  21        22        13     15
##  [836,]             24               16  29        24        12     14
##  [837,]             24               19  30        24        13     14
##  [838,]             26               17  27        24        16     16
##  [839,]             24               17  22        27        18     14
##  [840,]             27               14  26        28        23     13
##  [841,]             27               15  30        27        24     12
##  [842,]             24               16  26        25        25     11
##  [843,]             19               20  25        23        21     11
##  [844,]             19               19  23        16        24     13
##  [845,]             21               19  27        17        27     13
##  [846,]             21               16  25        20        25     14
##  [847,]             24               16  23        22        25     16
##  [848,]             25               17  23        22        23     15
##  [849,]             23               18  23        20        25     15
##  [850,]             23               14  20        20        23     17
##  [851,]             22               17  22        20        21     19
##  [852,]             22               15  24        23        18     21
##  [853,]             21               16  28        24        14     21
##  [854,]             18               15  26        21        15     20
##  [855,]             21               16  26        15        15     22
##  [856,]             20               17  23        15        16     22
##  [857,]             21               16  21        19        15     20
##  [858,]             22               15  23        22        16     19
##  [859,]             21               18  21        17        19     24
##  [860,]             22               19  22        19        16     24
##  [861,]             19               18  23        23        17     22
##  [862,]             20               19  21        18        21     23
##  [863,]             19               21  19        20        18     27
##  [864,]             19               22  16        22        17     31
##  [865,]             22               24  18        19        13     28
##  [866,]             20               19  16        18        13     28
##  [867,]             22               22  19        17        13     28
##  [868,]             23               25  20        18        13     27
##  [869,]             23               28  20        21        10     24
##  [870,]             26               21  20        23        11     20
##  [871,]             25               19  22        23        12     18
##  [872,]             27               22  20        21        12     17
##  [873,]             30               24  21        21        14     16
##  [874,]             31               23  21        19        13     20
##  [875,]             26               27  26        20        13     16
##  [876,]             26               20  21        19        13     16
##  [877,]             23               19  22        20        13     17
##  [878,]             20               16  22        23        10     16
##  [879,]             24               18  24        22        15     17
##  [880,]             23               19  26        18        12     15
##  [881,]             20               18  27        15        13     19
##  [882,]             20               17  28        16        16     19
##  [883,]             20               19  24        17        18     21
##  [884,]             22               19  26        19        14     21
##  [885,]             22               20  24        18        19     16
##  [886,]             24               20  23        17        18     18
##  [887,]             27               20  25        14        17     18
##  [888,]             25               21  26        15        18     21
##  [889,]             20               19  23        17        18     19
##  [890,]             20               19  24        16        20     15
##  [891,]             17               17  26        17        20     15
##  [892,]             25               20  27        18        20     13
##  [893,]             25               20  26        19        17     16
##  [894,]             30               20  22        15        15     12
##  [895,]             31               19  23        16        14     13
##  [896,]             28               16  24        16        17     16
##  [897,]             33               17  23        17        17     14
##  [898,]             35               18  23        16        17     13
##  [899,]             31               16  28        17        18     15
##  [900,]             29               15  26        17        17     15
##  [901,]             28               18  22        18        16     14
##  [902,]             29               18  25        17        13     14
##  [903,]             25               20  25        17        16     13
##  [904,]             24               20  28        16        15     16
##  [905,]             26               25  25        17        15     18
##  [906,]             25               23  23        14        15     17
##  [907,]             29               22  18        16        18     17
##  [908,]             27               29  18        14        15     18
##  [909,]             29               28  16        17        17     21
##  [910,]             29               24  21        17        16     16
##  [911,]             33               20  22        19        18     14
##  [912,]             26               20  20        16        18     21
##  [913,]             25               18  18        21        19     23
##  [914,]             27               15  18        20        27     23
##  [915,]             24               15  17        19        26     28
##  [916,]             22               12  16        22        26     24
##  [917,]             21               14  13        16        22     25
##  [918,]             24               15  15        20        28     24
##  [919,]             30               13  19        22        20     23
##  [920,]             25               16  17        27        17     21
##  [921,]             24               14  18        24        22     20
##  [922,]             28               12  20        22        23     14
##  [923,]             32               14  20        18        25     18
##  [924,]             32               16  21        19        24     17
##  [925,]             30               19  21        20        24     18
##  [926,]             32               15  23        20        22     19
##  [927,]             28               19  24        20        18     17
##  [928,]             23               22  25        20        18     19
##  [929,]             19               21  22        24        20     16
##  [930,]             18               22  27        26        19     15
##  [931,]             21               24  29        23        20     15
##  [932,]             20               24  22        23        20     13
##  [933,]             20               20  20        24        22     13
##  [934,]             23               19  20        27        21     15
##  [935,]             23               21  20        23        22     16
##  [936,]             23               21  19        25        21     15
##  [937,]             27               24  18        22        18     15
##  [938,]             25               27  18        24        20     20
##  [939,]             21               29  22        24        22     17
##  [940,]             23               30  19        22        24     17
##  [941,]             24               26  18        25        20     16
##  [942,]             22               23  17        25        24     15
##  [943,]             18               18  16        27        16     17
##  [944,]             17               20  17        24        18     19
##  [945,]             16               29  16        26        15     16
##  [946,]             16               26  17        27        17     14
##  [947,]             18               20  13        27        18     14
##  [948,]             18               20  17        29        15     15
##  [949,]             22               21  15        30        15     19
##  [950,]             22               18  17        29        14     20
##  [951,]             22               17  19        27        13     21
##  [952,]             22               15  24        27        12     21
##  [953,]             24               16  24        29        15     22
##  [954,]             23               18  20        26        14     21
##  [955,]             29               18  19        30        15     15
##  [956,]             24               17  21        26        18     10
##  [957,]             21               24  16        23        17     13
##  [958,]             22               20  18        23        15     14
##  [959,]             22               17  20        24        16     12
##  [960,]             24               16  20        24        15     11
##  [961,]             24               19  20        24        16     12
##  [962,]             24               18  23        24        18     10
##  [963,]             21               20  22        27        16     13
##  [964,]             22               18  25        26        15     17
##  [965,]             20               20  27        24        17     16
##  [966,]             20               19  18        25        19     17
##  [967,]             23               23  19        23        12     14
##  [968,]             20               22  23        28        13     13
##  [969,]             23               20  21        33        13     11
##  [970,]             22               19  20        35        16      9
##  [971,]             23               19  20        29        17     13
##  [972,]             21               19  20        26        16      7
##  [973,]             20               22  20        27        18      8
##  [974,]             21               21  23        29        16      9
##  [975,]             22               19  24        25        13     10
##  [976,]             21               19  25        25        14     13
##  [977,]             21               17  24        24        16     13
##  [978,]             19               17  23        19        17     14
##  [979,]             21               19  22        19        16     13
##  [980,]             21               15  21        24        13     13
##  [981,]             19               13  22        28        17      9
##  [982,]             19               12  25        25        22     11
##  [983,]             21               12  24        23        18     10
##  [984,]             16               12  25        23        19     10
##  [985,]             15               19  30        23        17     14
##  [986,]             14               22  26        24        19     13
##  [987,]             17               18  28        25        19     13
##  [988,]             15               22  22        22        18     15
##  [989,]             21               20  18        20        25     15
##  [990,]             22               21  13        26        25     12
##  [991,]             20               20  15        27        23     15
##  [992,]             19               22  16        26        28     14
##  [993,]             20               22  15        24        22     13
##  [994,]             13               24  15        19        21     18
##  [995,]             16               24  14        18        16     15
##  [996,]             18               23  18        13        21     14
##  [997,]             18               22  17        14        18     16
##  [998,]             22               20  22        19        19     18
##  [999,]             20               18  22        19        21     18
## [1000,]             19               21  23        18        19     15
# Plot importance
barplot(sort(colMeans(bart_model$varcount), decreasing = TRUE),
        main = "Variable Importance in BART",
        xlab = "Predictors", ylab = "Splits")

Problem 9.

# View the dataset structure
data("OJ")
dim(OJ)  # Check total number of observations
## [1] 1070   18
set.seed(123)  # Ensuring reproducibility

# Randomly select 800 observations for training
train_indices <- sample(1:nrow(OJ), size = 800)

# Create training and test sets
train_set <- OJ[train_indices, ]
test_set <- OJ[-train_indices, ]

# Check dimensions
dim(train_set)  # Should be 800 observations
## [1] 800  18
dim(test_set)   # Remaining observations
## [1] 270  18
# Fit a classification tree model
set.seed(123)
tree_model <- rpart(Purchase ~ ., data = train_set, method = "class")
summary(tree_model)
## Call:
## rpart(formula = Purchase ~ ., data = train_set, method = "class")
##   n= 800 
## 
##           CP nsplit rel error    xerror       xstd
## 1 0.49201278      0 1.0000000 1.0000000 0.04410089
## 2 0.03514377      1 0.5079872 0.5335463 0.03672576
## 3 0.02555911      2 0.4728435 0.5335463 0.03672576
## 4 0.01277955      4 0.4217252 0.4472843 0.03433576
## 5 0.01000000      7 0.3833866 0.4472843 0.03433576
## 
## Variable importance
##        LoyalCH        StoreID      PriceDiff    SalePriceMM WeekofPurchase 
##             45              9              9              6              6 
##        PriceMM         DiscMM      PctDiscMM        PriceCH  ListPriceDiff 
##              5              5              4              4              3 
##    SalePriceCH          STORE      SpecialCH 
##              2              1              1 
## 
## Node number 1: 800 observations,    complexity param=0.4920128
##   predicted class=CH  expected loss=0.39125  P(node) =1
##     class counts:   487   313
##    probabilities: 0.609 0.391 
##   left son=2 (450 obs) right son=3 (350 obs)
##   Primary splits:
##       LoyalCH   < 0.5036    to the right, improve=134.49530, (0 missing)
##       StoreID   < 3.5       to the right, improve= 40.88655, (0 missing)
##       STORE     < 0.5       to the left,  improve= 20.84871, (0 missing)
##       Store7    splits as  RL, improve= 20.84871, (0 missing)
##       PriceDiff < 0.015     to the right, improve= 19.14298, (0 missing)
##   Surrogate splits:
##       StoreID        < 3.5       to the right, agree=0.660, adj=0.223, (0 split)
##       WeekofPurchase < 246.5     to the right, agree=0.625, adj=0.143, (0 split)
##       PriceCH        < 1.825     to the right, agree=0.600, adj=0.086, (0 split)
##       PriceMM        < 1.89      to the right, agree=0.596, adj=0.077, (0 split)
##       ListPriceDiff  < 0.035     to the right, agree=0.581, adj=0.043, (0 split)
## 
## Node number 2: 450 observations,    complexity param=0.03514377
##   predicted class=CH  expected loss=0.1355556  P(node) =0.5625
##     class counts:   389    61
##    probabilities: 0.864 0.136 
##   left son=4 (423 obs) right son=5 (27 obs)
##   Primary splits:
##       PriceDiff   < -0.39     to the right, improve=18.543390, (0 missing)
##       DiscMM      < 0.72      to the left,  improve= 9.309254, (0 missing)
##       SalePriceMM < 1.435     to the right, improve= 9.309254, (0 missing)
##       PctDiscMM   < 0.3342595 to the left,  improve= 9.309254, (0 missing)
##       LoyalCH     < 0.7645725 to the right, improve= 8.822549, (0 missing)
##   Surrogate splits:
##       DiscMM      < 0.72      to the left,  agree=0.967, adj=0.444, (0 split)
##       SalePriceMM < 1.435     to the right, agree=0.967, adj=0.444, (0 split)
##       PctDiscMM   < 0.3342595 to the left,  agree=0.967, adj=0.444, (0 split)
##       SalePriceCH < 2.075     to the left,  agree=0.949, adj=0.148, (0 split)
## 
## Node number 3: 350 observations,    complexity param=0.02555911
##   predicted class=MM  expected loss=0.28  P(node) =0.4375
##     class counts:    98   252
##    probabilities: 0.280 0.720 
##   left son=6 (180 obs) right son=7 (170 obs)
##   Primary splits:
##       LoyalCH   < 0.2761415 to the right, improve=14.991900, (0 missing)
##       StoreID   < 3.5       to the right, improve= 6.562913, (0 missing)
##       Store7    splits as  RL, improve= 4.617311, (0 missing)
##       STORE     < 0.5       to the left,  improve= 4.617311, (0 missing)
##       SpecialCH < 0.5       to the right, improve= 4.512108, (0 missing)
##   Surrogate splits:
##       STORE       < 1.5       to the left,  agree=0.629, adj=0.235, (0 split)
##       StoreID     < 1.5       to the left,  agree=0.589, adj=0.153, (0 split)
##       PriceCH     < 1.875     to the left,  agree=0.589, adj=0.153, (0 split)
##       SalePriceCH < 1.875     to the left,  agree=0.586, adj=0.147, (0 split)
##       SalePriceMM < 1.84      to the left,  agree=0.571, adj=0.118, (0 split)
## 
## Node number 4: 423 observations
##   predicted class=CH  expected loss=0.09929078  P(node) =0.52875
##     class counts:   381    42
##    probabilities: 0.901 0.099 
## 
## Node number 5: 27 observations
##   predicted class=MM  expected loss=0.2962963  P(node) =0.03375
##     class counts:     8    19
##    probabilities: 0.296 0.704 
## 
## Node number 6: 180 observations,    complexity param=0.02555911
##   predicted class=MM  expected loss=0.4222222  P(node) =0.225
##     class counts:    76   104
##    probabilities: 0.422 0.578 
##   left son=12 (106 obs) right son=13 (74 obs)
##   Primary splits:
##       PriceDiff     < 0.05      to the right, improve=12.110850, (0 missing)
##       SalePriceMM   < 2.04      to the right, improve=11.572070, (0 missing)
##       DiscMM        < 0.25      to the left,  improve= 5.760121, (0 missing)
##       PctDiscMM     < 0.1345485 to the left,  improve= 5.760121, (0 missing)
##       ListPriceDiff < 0.18      to the right, improve= 5.597236, (0 missing)
##   Surrogate splits:
##       SalePriceMM   < 1.94      to the right, agree=0.933, adj=0.838, (0 split)
##       DiscMM        < 0.08      to the left,  agree=0.822, adj=0.568, (0 split)
##       PctDiscMM     < 0.038887  to the left,  agree=0.822, adj=0.568, (0 split)
##       ListPriceDiff < 0.135     to the right, agree=0.800, adj=0.514, (0 split)
##       PriceMM       < 2.04      to the right, agree=0.783, adj=0.473, (0 split)
## 
## Node number 7: 170 observations
##   predicted class=MM  expected loss=0.1294118  P(node) =0.2125
##     class counts:    22   148
##    probabilities: 0.129 0.871 
## 
## Node number 12: 106 observations,    complexity param=0.01277955
##   predicted class=CH  expected loss=0.4245283  P(node) =0.1325
##     class counts:    61    45
##    probabilities: 0.575 0.425 
##   left son=24 (8 obs) right son=25 (98 obs)
##   Primary splits:
##       LoyalCH        < 0.3084325 to the left,  improve=3.118983, (0 missing)
##       WeekofPurchase < 247.5     to the right, improve=2.489639, (0 missing)
##       SpecialMM      < 0.5       to the left,  improve=2.454538, (0 missing)
##       PriceCH        < 1.755     to the right, improve=2.048863, (0 missing)
##       PriceMM        < 2.04      to the right, improve=1.514675, (0 missing)
## 
## Node number 13: 74 observations
##   predicted class=MM  expected loss=0.2027027  P(node) =0.0925
##     class counts:    15    59
##    probabilities: 0.203 0.797 
## 
## Node number 24: 8 observations
##   predicted class=CH  expected loss=0  P(node) =0.01
##     class counts:     8     0
##    probabilities: 1.000 0.000 
## 
## Node number 25: 98 observations,    complexity param=0.01277955
##   predicted class=CH  expected loss=0.4591837  P(node) =0.1225
##     class counts:    53    45
##    probabilities: 0.541 0.459 
##   left son=50 (46 obs) right son=51 (52 obs)
##   Primary splits:
##       LoyalCH        < 0.442144  to the right, improve=3.071463, (0 missing)
##       WeekofPurchase < 248.5     to the right, improve=2.208454, (0 missing)
##       SpecialMM      < 0.5       to the left,  improve=2.011796, (0 missing)
##       STORE          < 0.5       to the left,  improve=1.624324, (0 missing)
##       StoreID        < 5.5       to the right, improve=1.624324, (0 missing)
##   Surrogate splits:
##       WeekofPurchase < 255       to the left,  agree=0.622, adj=0.196, (0 split)
##       SalePriceCH    < 1.755     to the right, agree=0.571, adj=0.087, (0 split)
##       STORE          < 2.5       to the right, agree=0.571, adj=0.087, (0 split)
##       PriceMM        < 2.205     to the right, agree=0.561, adj=0.065, (0 split)
##       DiscCH         < 0.115     to the left,  agree=0.561, adj=0.065, (0 split)
## 
## Node number 50: 46 observations
##   predicted class=CH  expected loss=0.326087  P(node) =0.0575
##     class counts:    31    15
##    probabilities: 0.674 0.326 
## 
## Node number 51: 52 observations,    complexity param=0.01277955
##   predicted class=MM  expected loss=0.4230769  P(node) =0.065
##     class counts:    22    30
##    probabilities: 0.423 0.577 
##   left son=102 (8 obs) right son=103 (44 obs)
##   Primary splits:
##       SpecialCH      < 0.5       to the right, improve=2.020979, (0 missing)
##       STORE          < 1.5       to the left,  improve=1.724009, (0 missing)
##       SpecialMM      < 0.5       to the left,  improve=1.680070, (0 missing)
##       WeekofPurchase < 245       to the right, improve=1.384615, (0 missing)
##       StoreID        < 5.5       to the right, improve=1.319751, (0 missing)
##   Surrogate splits:
##       DiscCH      < 0.27      to the right, agree=0.942, adj=0.625, (0 split)
##       SalePriceCH < 1.54      to the left,  agree=0.942, adj=0.625, (0 split)
##       PctDiscCH   < 0.149059  to the right, agree=0.942, adj=0.625, (0 split)
##       SalePriceMM < 1.64      to the left,  agree=0.923, adj=0.500, (0 split)
##       DiscMM      < 0.42      to the right, agree=0.904, adj=0.375, (0 split)
## 
## Node number 102: 8 observations
##   predicted class=CH  expected loss=0.25  P(node) =0.01
##     class counts:     6     2
##    probabilities: 0.750 0.250 
## 
## Node number 103: 44 observations
##   predicted class=MM  expected loss=0.3636364  P(node) =0.055
##     class counts:    16    28
##    probabilities: 0.364 0.636

Training Error Rate:

The training error rate is given by the expected loss at the root node:

Expected loss = 0.39125, which represents the misclassification rate in the training set.

Training accuracy = 1 - 0.39125 = 0.60875 (≈ 60.88%).

the following nodes are terminal:

Nodes: 4, 5, 7, 24, 25, 50, 51, 102, 103 (total: 9 terminal nodes)

tree_model
## n= 800 
## 
## node), split, n, loss, yval, (yprob)
##       * denotes terminal node
## 
##   1) root 800 313 CH (0.60875000 0.39125000)  
##     2) LoyalCH>=0.5036 450  61 CH (0.86444444 0.13555556)  
##       4) PriceDiff>=-0.39 423  42 CH (0.90070922 0.09929078) *
##       5) PriceDiff< -0.39 27   8 MM (0.29629630 0.70370370) *
##     3) LoyalCH< 0.5036 350  98 MM (0.28000000 0.72000000)  
##       6) LoyalCH>=0.2761415 180  76 MM (0.42222222 0.57777778)  
##        12) PriceDiff>=0.05 106  45 CH (0.57547170 0.42452830)  
##          24) LoyalCH< 0.3084325 8   0 CH (1.00000000 0.00000000) *
##          25) LoyalCH>=0.3084325 98  45 CH (0.54081633 0.45918367)  
##            50) LoyalCH>=0.442144 46  15 CH (0.67391304 0.32608696) *
##            51) LoyalCH< 0.442144 52  22 MM (0.42307692 0.57692308)  
##             102) SpecialCH>=0.5 8   2 CH (0.75000000 0.25000000) *
##             103) SpecialCH< 0.5 44  16 MM (0.36363636 0.63636364) *
##        13) PriceDiff< 0.05 74  15 MM (0.20270270 0.79729730) *
##       7) LoyalCH< 0.2761415 170  22 MM (0.12941176 0.87058824) *

Terminal node 7:

Node Number: 7

Observations: 170

Predicted Class: MM (Minute Maid)

Expected Loss: 0.129 (≈ 12.9% misclassification rate)

Class Counts: 22 customers bought CH (Tropicana), while 148 chose MM

Probability Distribution: 12.9% CH, 87.1% MM

Interpretation:

This node represents a segment of consumers who overwhelmingly purchase Minute Maid over Tropicana.

The factors leading to this group could be low loyalty to CH, StoreID, special discounts, or pricing differences.

The expected loss (misclassification rate) suggests that most instances here are confidently classified as MM, with low uncertainty.

# Generate the tree plot
rpart.plot(tree_model, type = 3, extra = 104, box.palette = "auto", main = "Classification Tree for OJ Purchase")

Interpret the results:

Primary Predictor - Customer Loyalty (LoyalCH)

The first split happens at LoyalCH >= 0.5.

Customers loyal to CH are more likely to purchase Tropicana.

Those less loyal undergo further splits based on price and promotions.

Price Difference (PriceDiff) Impact

When PriceDiff >= -0.39, CH purchase likelihood increases to 90%.

If PriceDiff < -0.39, MM is preferred (70% probability).

Effect of Special Offers (SpecialCH)

If SpecialCH = 1 in certain segments, CH purchase probability increases.

Without a promotion, the likelihood shifts toward MM.

Terminal Nodes & Decision Paths

Each leaf node represents a final prediction based on conditions.

Some nodes predict 100% CH purchases, meaning those customers show absolute preference.

Others indicate 80%+ MM purchases, suggesting stronger Minute Maid loyalty.

# Predict class labels for the test set
pred_test <- predict(tree_model, newdata = test_set, type = "class")
# Load required package for confusion matrix
library(caret)
## Warning: package 'caret' was built under R version 4.4.2
## Loading required package: lattice
## 
## Attaching package: 'caret'
## The following object is masked from 'package:purrr':
## 
##     lift
# Generate confusion matrix
conf_matrix <- confusionMatrix(pred_test, test_set$Purchase)
print(conf_matrix)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  CH  MM
##         CH 141  24
##         MM  25  80
##                                           
##                Accuracy : 0.8185          
##                  95% CI : (0.7673, 0.8626)
##     No Information Rate : 0.6148          
##     P-Value [Acc > NIR] : 3.407e-13       
##                                           
##                   Kappa : 0.6175          
##                                           
##  Mcnemar's Test P-Value : 1               
##                                           
##             Sensitivity : 0.8494          
##             Specificity : 0.7692          
##          Pos Pred Value : 0.8545          
##          Neg Pred Value : 0.7619          
##              Prevalence : 0.6148          
##          Detection Rate : 0.5222          
##    Detection Prevalence : 0.6111          
##       Balanced Accuracy : 0.8093          
##                                           
##        'Positive' Class : CH              
## 
# Extract misclassification rate
test_error <- 1 - conf_matrix$overall["Accuracy"]

print(paste("Test Error Rate:", round(test_error, 3)))
## [1] "Test Error Rate: 0.181"
library(tree)
## Warning: package 'tree' was built under R version 4.4.3
set.seed(123)  # Ensures reproducibility
tree_model <- tree(Purchase ~ ., data = train_set)

# Summary of the tree
summary(tree_model)
## 
## Classification tree:
## tree(formula = Purchase ~ ., data = train_set)
## Variables actually used in tree construction:
## [1] "LoyalCH"   "PriceDiff"
## Number of terminal nodes:  8 
## Residual mean deviance:  0.7625 = 603.9 / 792 
## Misclassification error rate: 0.165 = 132 / 800
cv_results <- cv.tree(tree_model, FUN = prune.misclass)

# Print cross-validation results
print(cv_results)
## $size
## [1] 8 5 3 2 1
## 
## $dev
## [1] 139 139 157 167 313
## 
## $k
## [1] -Inf    0    8   11  154
## 
## $method
## [1] "misclass"
## 
## attr(,"class")
## [1] "prune"         "tree.sequence"
cv_df <- data.frame(TreeSize = cv_results$size, CV_Error = cv_results$dev)

# Print dataframe to verify
print(cv_df)
##   TreeSize CV_Error
## 1        8      139
## 2        5      139
## 3        3      157
## 4        2      167
## 5        1      313
library(ggplot2)

ggplot(cv_df, aes(x = TreeSize, y = CV_Error)) +
  geom_line(color = "blue", size = 1) +
  geom_point(color = "red", size = 2) +
  labs(title = "Tree Size vs. Cross-Validated Classification Error",
       x = "Tree Size (Number of Terminal Nodes)",
       y = "Cross-Validation Error") +
  theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

The tree size corresponding to the lowest cross-validated classification error rate is 8 terminal nodes.

From the plot, the error rate decreases steadily as the tree size increases, reaching its minimum at tree size 8. This suggests that the optimal complexity for the model balances accuracy without overfitting.

cv_results <- cv.tree(tree_model, FUN = prune.misclass)

# Extract tree size with the lowest cross-validation error
optimal_size <- cv_results$size[which.min(cv_results$dev)]
print(paste("Optimal Tree Size:", optimal_size))
## [1] "Optimal Tree Size: 8"
pruned_tree <- prune.misclass(tree_model, best = optimal_size)

# Plot pruned tree
library(tree)
plot(pruned_tree)
text(pruned_tree, pretty = 0)
title("Pruned Tree - Optimal Size")

# Predict on training set using the full (unpruned) tree
pred_train_unpruned <- predict(tree_model, newdata = train_set, type = "class")

# Compute confusion matrix for unpruned tree
conf_matrix_unpruned <- table(Predicted = pred_train_unpruned, Actual = train_set$Purchase)

# Compute training error rate
train_error_unpruned <- 1 - sum(diag(conf_matrix_unpruned)) / sum(conf_matrix_unpruned)
print(paste("Training Error Rate (Unpruned Tree):", round(train_error_unpruned, 3)))
## [1] "Training Error Rate (Unpruned Tree): 0.165"
# Predict on training set using the pruned tree
pred_train_pruned <- predict(pruned_tree, newdata = train_set, type = "class")

# Compute confusion matrix for pruned tree
conf_matrix_pruned <- table(Predicted = pred_train_pruned, Actual = train_set$Purchase)

# Compute training error rate
train_error_pruned <- 1 - sum(diag(conf_matrix_pruned)) / sum(conf_matrix_pruned)
print(paste("Training Error Rate (Pruned Tree):", round(train_error_pruned, 3)))
## [1] "Training Error Rate (Pruned Tree): 0.165"
# Predict on test set using pruned tree
pred_pruned <- predict(pruned_tree, newdata = test_set, type = "class")

# Generate confusion matrix
conf_matrix_pruned <- confusionMatrix(pred_pruned, test_set$Purchase)

# Compute test error rate
test_error_pruned <- 1 - conf_matrix_pruned$overall["Accuracy"]
print(paste("Test Error Rate after Pruning:", round(test_error_pruned, 3)))
## [1] "Test Error Rate after Pruning: 0.185"

Unpruned tree test error = 0.181, therefore the pruned tree has a slightly higher test error rate (0.185 vs. 0.181).