Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/scripts/clean_kernelspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

2 changes: 1 addition & 1 deletion practicals_jn_book/week_1/finalbook_part1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions practicals_jn_book/week_3/finalbook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -543,7 +543,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": null,
"metadata": {
"tags": [
"hide-input"
Expand Down
9 changes: 7 additions & 2 deletions practicals_jn_book/week_4/finalbook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)"
]
},
{
Expand Down
Loading