Creating Heat Maps to Visualize Epidemiological Data
Heat maps (or heatmaps) are wonderful visual representations of how points cluster on a map. This is ideal for plotting epidemiological data based on the longitude and latitude of events.
Epidemiologist can quickly identify where more cases exist and where more resources may be required.
I have created a short video tutorial about how to create a heat map using the folium package in Python. Folium generates interactive plots that can be exported for use in other media.
In the tutorial I generate some synthetics data for cases in Brooklyn, New York. I show how to change the parameters of the plot to change the plot for better visualization of the data.
I also create a time-series plot. These can be used to visualize how the data changes over time.
The link below shows the video tutorial. The Jupyter notebook (that contains the code) can be found HERE.
Creating virtual environments for coding in Python
Installing Python on your computer is a simple task. Go to python.org and install the version of Python that you require.
It is not the best practice to use these installation of Python, though. One of the reasons for the great success of Python, is its package ecosystem. There are thousands of packages that extend the capabilities of the Python language.
Packages have dependencies. Dependencies exists for the version of Python, and in many cases, on specific versions of other packages. Installing multiple packages can cause issues. If the installed versions of packages are incompatible, you can end up in what is referred to as dependency hell. In the worst case, you can end up with unusable installations of Python.
To avoid this, it is recommended to use virtual environments. These are copies of Python, created for specific tasks. These copies mean that the base installation(s) of Python are never altered.
There are two approaches to creating these environments. Miniconda (that runs in the Terminal), or the full Anaconda (graphical user interface), can be used to create system-wide virtual environments. Specific packages can then be installed in each environment. I have three such envirnoments on my main computer. One for data science, one for geospatial data science, and one for mathematics.
The alternative is to create a virtual environment for each project, which in my case, lives in a folder (for each project). The built-in virtual environment manager venv and the newer, and much faster, environment and package manager is uv. It may be effective to use these per-project environments, but it does mean that your system can end up with many, many virtual environments. that can take up a lot of space. It may also be required not to install these in folders that are available in the cloud, such as OneDrive folders.
I have made a video tutorial about setting up all three of these environments.
I use Visual Studio Code with Jupyter notebooks and Quarto documents for both research and creating educational content. GitHub Copilot Pro is available for free as faculty or students, giving access to the best models for code and content.
Visual Studio Code together with Python, R, and Julia (the languages that I use in Visual Studio Code) takes time and effort to install, especially when using virtual environments. For students just starting out, this might just be too much. Google Colab is a version of Jupyter notebooks that is available right inside of your Google Drive, and you create a notebook the same as creating a Google Doc or a Google Sheet.
I have created a YouTube Playlist with some videos of how to analyze data using Google Colab. In this video series I keep coding to a minimum, instead using the built-in Google Gemini AI to write the code for me.
Watch the video I made of my first short look HERE
Mistral has updated their LLM chat interface called Le Chat, which I understand is French for The Cat.
Anyway, it is a chat interface to their generative artificial intelligence model, much like OpenAI's ChatGPT, and Anthropic's Claude. You can read more about the new capabilities of Le Chat HERE.
All you need is a free account (for now). I do a quick first test of Le Chat to look at how it produces simple Python code. Le Chat does not allow for the upload of a spreadsheet file, so instead, I tried to use it to solve a simple system of two linear equations in two unknown.
I do stress test the chat interface a bit by using LaTeX in my prompts and I also get it to use the symbolic Python package, sympy. A package that I absolutely love, but is not that commonly used in the broader context of Python use-cases.
I copy and paste the code into Visual Studio Code (after having set up a virtual Python environment in which I installed numpy, matplotlib, and sympy beforehand).
Le Chat did a good job in this small first test. It generated the two lines in the plane using matplotlib to show the unique solution (at the intersection of the lines). It generated the augmented matrix as I instructed, but then solved the system of linear equations using the solve method in sympy. After instructing Le Chat to rather calculate the reduced row-echelon form of the matrix using the sympy rref method, it did indeed that.
Check out the new Le Chat for yourself HERE or watch the short video I made of my first test below.
The Python computer language is great at so many things. Many indices rank Python as the most popular computer language. It is great for data science, machine learning, and so many things.
Python is also great at mathematics. Not only the mathematics of numerical computation, but also the kind of symbolic mathematics that you find in your algebra and calculus textbooks.
Packages extend the Python language. The symbolic Python package sympy does just this. It extends Python with the capability to do symbolic mathematics.
While you can install Python on your local computer, you can also use it in your Google Drive without installing anything. Just as we have Google Docs and Google Sheets in our Google Drive, we also have Google Colaboratory. With a Google Colab document, we can write and typeset normal titles, paragraphs, and images, just like Google Docs. We also write Python code in these documents.
I have made a video about how to set up your Google Drive to use Python. More specifically, how to set up your Google Drive to use Python for mathematics.
The course material on An Introduction to Algebra for Health Data Science that I host on this blog uses Python for Mathematics. The course teaches algebra, but also adds Python code that gives you a deeper understanding of the material by allowing you to experiment with your algebra knowledge without having to do the tedious calculations.