From b42050dd19a2eee1a4c0148884344e361ca30c5e Mon Sep 17 00:00:00 2001 From: awdeleeuw Date: Tue, 5 May 2026 13:12:56 +0200 Subject: [PATCH] Minor changes --- .github/scripts/clean_kernelspecs.py | 4 ++-- practicals_jn_book/week_1/finalbook_part1.ipynb | 2 +- practicals_jn_book/week_3/finalbook.ipynb | 6 +++--- practicals_jn_book/week_4/finalbook.ipynb | 9 +++++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/scripts/clean_kernelspecs.py b/.github/scripts/clean_kernelspecs.py index c6e5e85..18c0565 100644 --- a/.github/scripts/clean_kernelspecs.py +++ b/.github/scripts/clean_kernelspecs.py @@ -2,13 +2,13 @@ import glob for nb_path in glob.glob("**/*.ipynb", recursive=True): - with open(nb_path) as f: + with open(nb_path, encoding = "utf-8") as f: nb = nbformat.read(f, as_version=4) nb['metadata']['kernelspec'] = { "name": "python3", "display_name": "Python 3", "language": "python" } - with open(nb_path, 'w') as f: + with open(nb_path, 'w', encoding = "utf-8") as f: nbformat.write(nb, f) diff --git a/practicals_jn_book/week_1/finalbook_part1.ipynb b/practicals_jn_book/week_1/finalbook_part1.ipynb index 54bda40..5e7d9d6 100644 --- a/practicals_jn_book/week_1/finalbook_part1.ipynb +++ b/practicals_jn_book/week_1/finalbook_part1.ipynb @@ -631,7 +631,7 @@ "\n", "### Assignment 5\n", "\n", - "- **First sort all the data by Totalkg score, make sure the Totalkg is on top of your DataFrame. Print out the DataFrame. What do you notice?**\n", + "- **First sort all the data by Totalkg score, make sure the lowest Totalkg is on top of your DataFrame. Print out the DataFrame. What do you notice?**\n", "\n", "- **Remove all rows that contain missing values. Print out the DataFrame. What happened to the index?**\n", "\n", diff --git a/practicals_jn_book/week_3/finalbook.ipynb b/practicals_jn_book/week_3/finalbook.ipynb index 8fb64a1..5785314 100644 --- a/practicals_jn_book/week_3/finalbook.ipynb +++ b/practicals_jn_book/week_3/finalbook.ipynb @@ -80,7 +80,7 @@ "source": [ "### Assignment 0: load and inspect data\n", "\n", - "The breast cancer dataset is available on the [GitHub](https://github.com/Alek050/big_data_practicals/tree/main/data/week_3). It's a binary DataFrame. Pandas also provides the convenient ``read_parquet()`` function. Parquet files are binary representations of tabular data, making it extremely fast with human readable formats such as csv and excel files. \n", + "The breast cancer dataset is available on the [GitHub](https://github.com/Alek050/big_data_practicals/tree/main/data/week_3). It's a binary DataFrame. Pandas also provides the convenient ``read_parquet()`` function. Parquet files are binary representations of tabular data, making it extremely fast compared with human readable formats such as csv and excel files. \n", "\n", "- **Read the data with the ``read_parquet()`` function and check what type it returns by using ``type()``.**\n", "- **Print the head of the DataFrame.**\n", @@ -534,7 +534,7 @@ "source": [ "Take a look at the distribution of mean_radius for the benign and malignant cases. To do so you have to plot a histogram for both in the same figure. Do this using the ``matplotlib.pyplot`` sublibrary (import on top). Remember to first define a figure and then plot a hist?\n", "\n", - "- **Create a histogram for mean_radius for the malignant and benign cases. Add a legend, xlabel and ylabel. Choose wheter you use interactive plotting or object-oriented plotting**\n", + "- **Create a histogram for mean_radius for the malignant and benign cases. Add a legend, xlabel and ylabel. Choose whether you use interactive plotting or object-oriented plotting**\n", "\n", "You can spice up your vanilla matplotlib with the built-in [stylesheets](https://matplotlib.org/gallery/style_sheets/style_sheets_reference.html).\n", "\n", @@ -543,7 +543,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "metadata": { "tags": [ "hide-input" diff --git a/practicals_jn_book/week_4/finalbook.ipynb b/practicals_jn_book/week_4/finalbook.ipynb index 3c6ce4a..597e1e4 100644 --- a/practicals_jn_book/week_4/finalbook.ipynb +++ b/practicals_jn_book/week_4/finalbook.ipynb @@ -1691,6 +1691,11 @@ "\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)\n", "\n", + "scaler = StandardScaler()\n", + "scaler.fit(X_train)\n", + "X_train_scaled = scaler.transform(X_train)\n", + "X_test_scaled = scaler.transform(X_test)\n", + "\n", "def train_evaluate_model(model, X_train, X_test, y_train, y_test):\n", " \"\"\" A function that calculates the R^2 and the RMSE based on a model and dataset\n", "\n", @@ -1715,8 +1720,8 @@ " \n", " return R2, RMSE\n", "\n", - "lasso_R2, lasso_RMSE = train_evaluate_model(lasso_model, X_train, X_test, y_train, y_test)\n", - "ridge_R2, ridge_RMSE = train_evaluate_model(ridge_model, X_train, X_test, y_train, y_test)" + "lasso_R2, lasso_RMSE = train_evaluate_model(lasso_model, X_train_scaled, X_test_scaled, y_train, y_test)\n", + "ridge_R2, ridge_RMSE = train_evaluate_model(ridge_model, X_train_scaled, X_test_scaled, y_train, y_test)" ] }, {