{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Setting up your Python environment\n", "\n", "[![View notebooks on Github](https://img.shields.io/static/v1.svg?logo=github&label=Repo&message=View%20On%20Github&color=lightgrey)](https://github.com/amonroym99/uva-applied-ml/blob/main/docs/notebooks/setup.ipynb)\n", "\n", "**Author:** Alejandro Monroy\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To be able to run the notebooks, you need to install Python 3.13 and the libraries in the following [requirements](https://github.com/amonroym99/uva-applied-ml/blob/main/docs/notebooks/requirements.txt) file. It is a good practice to create a virtual environment using [venv](https://docs.python.org/3/library/venv.html) or [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html), preventing version conflicts with other projects or system-wide installations.\n", "\n", "You can verify that your have the correct version of the libraries (or newer) by running the following cell:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "import ipykernel\n", "import matplotlib\n", "import numpy\n", "import pandas\n", "import sklearn\n", "import seaborn\n", "\n", "required_python_version = \"3.13\"\n", "installed_python_version = f\"{sys.version_info.major}.{sys.version_info.minor}\"\n", "assert installed_python_version.startswith(required_python_version), (\n", " f\"Python version mismatch: installed {installed_python_version}, required {required_python_version}.x\"\n", ")\n", "\n", "versions = {\n", " \"ipykernel\": {\"required\": \"6.31.0\", \"installed\": ipykernel.__version__},\n", " \"matplotlib\": {\"required\": \"3.10.6\", \"installed\": matplotlib.__version__},\n", " \"numpy\": {\"required\": \"2.3.5\", \"installed\": numpy.__version__},\n", " \"pandas\": {\"required\": \"2.3.3\", \"installed\": pandas.__version__},\n", " \"scikit-learn\": {\"required\": \"1.7.2\", \"installed\": sklearn.__version__},\n", " \"seaborn\": {\"required\": \"0.13.2\", \"installed\": seaborn.__version__}\n", "}\n", "\n", "for library, version_info in versions.items():\n", " required_version = version_info[\"required\"]\n", " installed_version = version_info[\"installed\"]\n", " assert installed_version >= required_version, f\"{library} version mismatch: installed {installed_version}, required {required_version}\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In case you do encounter an error due to an older or newer version of these packages, you can use the following prompt in the command line to install the specific versions of each package. If you use a seperate environment for this course, be sure to run this code in said environment. You can use the _activate_ command to switch environments in the command line. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pip install ipykernel==6.31.0 && pip install matplotlib==3.10.6 && pip install numpy==2.3.5 && pip install pandas==2.3.3 && pip install scikit-learn==1.7.2 && pip install seaborn==0.13.2" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.5" } }, "nbformat": 4, "nbformat_minor": 4 }