Graphing Programming Assignment
1. Find a dataset as you did in the previous assignment (can be the same dataset but
doesn't have to be). Divide it into test and training sets, and then create an Rpart model
on the training set to predict a dependent variable. For this part include just one column
to make the prediction from. (you are using one column to predict another). Include a
picture of the tree, along with 2 measures of error (root mean squared error and
absolute error) on the training and test set.
To check how well the regression tree worked, I used RMSE along with MAE across training
and test data. Training RMSE came out to 122.06 whereas test RMSE reached 123.26 - so
predictions miss actual values by roughly 122 to 123 calories per case. Looking at MAE, it's
96.41 on training but climbs slightly to 98.74 during testing, meaning most mistakes sit near 96–
99 calories. Because gap between training and test scores stays small, no signs point toward
overfitting right now.
, 2. Adjust the complexity parameter (make it lower) of the Rpart model until the training
accuracy stops going up. What is the test accuracy? If done correctly it should now be
lower since your model is overfit. Include the complexity parameter along with pictures
of the tree.
To check overfitting, I reduced the cp value in the rpart model. With cp = 0.001, the tree got
bigger, picking up more splits. Training RMSE dropped - from 122.06 in part 1 before to 113.22
while MAE went from 96.41 down to 88.35, meaning it matched training data closer. Test RMSE
decreased a bit too, falling from 123.26 to 116.27; MAE followed suit, sliding from 98.74 to
91.88. This shows the model is starting to overfit, and lowering cp further would eventually
cause the test error to increase while the training error continues to decrease.
1. Find a dataset as you did in the previous assignment (can be the same dataset but
doesn't have to be). Divide it into test and training sets, and then create an Rpart model
on the training set to predict a dependent variable. For this part include just one column
to make the prediction from. (you are using one column to predict another). Include a
picture of the tree, along with 2 measures of error (root mean squared error and
absolute error) on the training and test set.
To check how well the regression tree worked, I used RMSE along with MAE across training
and test data. Training RMSE came out to 122.06 whereas test RMSE reached 123.26 - so
predictions miss actual values by roughly 122 to 123 calories per case. Looking at MAE, it's
96.41 on training but climbs slightly to 98.74 during testing, meaning most mistakes sit near 96–
99 calories. Because gap between training and test scores stays small, no signs point toward
overfitting right now.
, 2. Adjust the complexity parameter (make it lower) of the Rpart model until the training
accuracy stops going up. What is the test accuracy? If done correctly it should now be
lower since your model is overfit. Include the complexity parameter along with pictures
of the tree.
To check overfitting, I reduced the cp value in the rpart model. With cp = 0.001, the tree got
bigger, picking up more splits. Training RMSE dropped - from 122.06 in part 1 before to 113.22
while MAE went from 96.41 down to 88.35, meaning it matched training data closer. Test RMSE
decreased a bit too, falling from 123.26 to 116.27; MAE followed suit, sliding from 98.74 to
91.88. This shows the model is starting to overfit, and lowering cp further would eventually
cause the test error to increase while the training error continues to decrease.