Artificial Intelligence Applications in Engineering (MUH-920), week 7 of 14: interactive lab

Regression studio: Complexity, validation and leakage

Prof. Dr. Utku Kose, Süleyman Demirel University

Part A generates strength data from a known law, shaped after Abrams' water-cement rule [1], adds noise, and lets polynomial, nearest-neighbour and tree regressors fit it; training error, error on new data and a five-fold validation curve show where overfitting starts [2]. Part B estimates bias and variance by repeated sampling [2]. Part C fits a least-squares line by hand and shows how ridge and the lasso shrink it [3]. Part D compares nearest neighbours with and without standardised inputs, and Part E searches tree splits and adds gradient-boosting stumps [4, 5]. Part F computes MAE, RMSE and R² term by term with a parity plot. Part G is a leakage detective with six candidate features from engineering projects [6].

Part A: Fit, validate, compare

Five-fold validation curve over the complexity setting of the chosen model. The dashed line marks the current setting.

Part B: Bias and variance by repeated sampling

Two hundred training sets are drawn from the same law with noise, and a polynomial is fitted to each. At the point x0, the mean of the predictions gives the bias and their spread the variance; the second chart shows how the two terms trade off over the degree, as in the decomposition of the lecture [2].

Part C: Least squares, ridge and lasso by hand

The table computes every deviation, product and square of the least-squares formulas for the pairs entered above, and the chart draws the line with its residuals. The two sliders shrink the slope with the ridge and lasso formulas of the lecture; the lasso slope becomes exactly zero once λ reaches twice the magnitude of S_xy. The defaults are the five mixes of the worked example [7, 8].

Part D: Nearest neighbours with and without scaling

Six mixes with a water-cement ratio, an age and a strength form the training data of the worked example. Moving the query shows the raw and the standardised distances side by side; in raw units the age decides alone, and after standardisation both inputs count [9].

Part E: Tree splits and gradient-boosting stumps

The table evaluates every candidate threshold of a regression tree with the summed squared error of its two children and marks the best one. Each press of the button fits a one-split tree to the current residuals and adds it, scaled by the learning rate, so that the boosted model approaches the data step by step [4, 5].

Part F: Error metrics and the parity plot

Measured and predicted values give MAE, RMSE and R² with every term shown. Adding one large error raises RMSE much more than MAE and lowers R², and the parity plot shows the point far from the diagonal [3].

Part G: Leakage detective

References

[1] Abrams, D. A. (1918). Design of Concrete Mixtures (Bulletin 1). Structural Materials Research Laboratory, Lewis Institute, Chicago.

[2] Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction (2nd ed.). Springer. https://doi.org/10.1007/978-0-387-84858-7

[3] James, G., Witten, D., Hastie, T., & Tibshirani, R. (2021). An Introduction to Statistical Learning (2nd ed.). Springer. https://doi.org/10.1007/978-1-0716-1418-1

[4] Breiman, L., Friedman, J. H., Olshen, R. A., & Stone, C. J. (1984). Classification and Regression Trees. Wadsworth.

[5] Chen, T., & Guestrin, C. (2016). XGBoost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 785-794). https://doi.org/10.1145/2939672.2939785

[6] Kaufman, S., Rosset, S., Perlich, C., & Stitelman, O. (2012). Leakage in data mining: Formulation, detection, and avoidance. ACM Transactions on Knowledge Discovery from Data, 6(4), 15. https://doi.org/10.1145/2382577.2382579

[7] Hoerl, A. E., & Kennard, R. W. (1970). Ridge regression: Biased estimation for nonorthogonal problems. Technometrics, 12(1), 55-67. https://doi.org/10.1080/00401706.1970.10488634

[8] Tibshirani, R. (1996). Regression shrinkage and selection via the lasso. Journal of the Royal Statistical Society: Series B (Methodological), 58(1), 267-288. https://doi.org/10.1111/j.2517-6161.1996.tb02080.x

[9] Cover, T., & Hart, P. (1967). Nearest neighbor pattern classification. IEEE Transactions on Information Theory, 13(1), 21-27. https://doi.org/10.1109/TIT.1967.1053964

[10] Breiman, L. (2001). Random forests. Machine Learning, 45(1), 5-32. https://doi.org/10.1023/A:1010933404324