RSSAmplifier

Blog

Anna-Lena Popkes

Recent content on Anna-Lena Popkes

alpopkes.comRSS feed ↗43 posts

Latest posts

When and how to start coding with kids

Introduction Coding with children is a topic close to my heart. This has four main reasons: I did not have any coding opportunities growing up. My family had nothing to do with coding, neither did my friends. Also, we did not have computer science or coding classes at school. I would very much like this to be different for other children, including my own. I love learning and teaching! You might…

An unbiased evaluation of environment management and packaging tools

Last update This post was last updated on August 29th, 2024. Motivation When I started with Python and created my first package I was confused. Creating and managing a package seemed much harder than I expected. In addition, multiple tools existed and I wasn’t sure which one to use. I’m sure most of you had the very same problem in the past. Python has a zillion tools to manage virtual…

Principal component analysis (PCA)

After a longer break I continued working on my machine learning basics repository which implements fundamental machine learning algorithms in plain Python. This time, I took a detailed look at principal component analysis (PCA). The blog post below contains the same content as the original notebook. You can run the notebook directly in your Browser using Binder. 1. What is PCA? In simple terms,…

Support vector machines

I posted another notebook in my machine learning basics repository. This time, I took a detailed look at support vector machines. The blog post below contains the same content as the original notebook. You can run the notebook directly in your Browser using Binder. 1. What are support vector machines? Support vector machines (short: SVMs) are supervised machine learning models. They are the most…

Personal reading list of non-fiction books

Books I am currently reading Mindset by Carol Dweck (Link to book) Books I have read Atomic Habits by James Clear (Link to book) A Promised Land by Barack Obama (Link to book) The Alchemy of Air by Thomas Hager (Link to book) Superintelligence: Paths, Dangers, Strategies by Nick Bostrom (Link to book) Beethoven, A Life by Jan Caeyers (Link to book) Deep Work: Rules for Focused Success in a…

Bayesian linear regression

I finally found time to continue working on my machine learning basics repository which implements fundamental machine learning algorithms in plain Python. Especially, I took a detailed look at Bayesian linear regression. The blog post below contains the same content as the original notebook. You can run the notebook directly in your Browser using Binder. 1. What is Bayesian linear regression…

Deep Work

I recently finished reading the book Deep Work by Cal Newport. For years, I have been interested in the question of how we can improve our learning and work habits. There is a ton of research on this topic and many great resources (like, for example, the podcast The Learning Scientists). I don’t want to use this blog post to talk about all the different things I have learned and tried in the…

Mocking in Python

Topics: Mocking in Python Today, I want to talk about mocking. I became interested in this topic a few months back when I started to work in a data engineering project at work. In this project we have a lot of tests that relies on mocking to test code with external dependencies. If you don’t like reading long blog posts, consider listening to one of the podcast episodes I did on this topic:…

Variational Inference

Introduction Variational inference is an important topic that is widely used in machine learning. For example, it’s the basis for variational autoencoders. Also Bayesian learning often makes use variational of inference. To understand what variational inference is, how it works and why it’s useful we will go through each point step by step. What are latent variables? A latent variable…

Kullback-Leibler Divergence

One of the points on my long ‘stuff-you-have-to-look-at’ list is the Kullback-Leibler divergence. I finally took the time to take a detailed look at this topic. Definition The KL-divergence is a measure of how similar (or different) two probablity distributions are. When having a discrete probability distribution $P$ and another probability distribution $Q$ the KL-divergence for a set…

An introduction to Docker

Topics: Docker I have been wanting to learn more about Docker for months. However, when starting to read Dockers get started page I quickly had to find out that I’m lacking knowledge in too many other concepts. Since my background isn’t computer science I often run across this problem. Luckily, this allows me to constantly learn new things! After writing a post on virtual machines and…

An introduction to containers

Topics: Containers I have been wanting to learn more about Docker for months. However, when starting to read Dockers get started page I quickly had to find out that I’m lacking knowledge in too many other concepts. Since my background isn’t computer science I often run across this problem. Luckily, this allows me to constantly learn new things! With the goal of eventually reaching the…

An introduction to virtual machines

Topics: Virtual machines I have been wanting to learn more about Docker for months. However, when starting to read Dockers get started page I quickly had to find out that I’m lacking knowledge in too many other concepts. Since my background isn’t computer science I often run across this problem. Luckily, this allows me to constantly learn new things! With the goal of eventually…

Wrap up

Topics: Wrap up During the past 50 days we studied several highly useful Python concepts using a Magical Universe. Overall, we looked at the following concepts: General Python concepts: Object oriented programming, how to use classes, how inheritance works, etc. The differences between class, instance and static methods How to convert objects to strings How to properly name variables and functions…

Config files

Topics: Using config files What are config files As a last topic I would like to take a look at the usage of config files. First of all we have to establish what a config file is. The Wikipedia definition definition is precise and easy to understand: configuration files (or config files) are files used to configure the parameters and initial settings for some computer programs. In our case we can…

collections.defaultdict

Topics: collections.defaultdict Updated 2020-10-06 The collections module The collections module in Python contains several useful classes. One of them is especially helpful for our Magical Universe: collections.defaultdict. When defining our CastleKilmereMember class we specified self.traits to be an empty dictionary. New positive and negative traits can be added to a person using the add_trait()…

functools.wraps - avoiding losing metdata when applying decorators

Topics: functools.wraps We have discussed decorators on day 5, day 6 and day 20 already. Therefore, we know that decorators allow us to extend or modify the behavior of a function without permanently modifying the function itself. In our example we modified the says() function of our CastleKilmereMember class to be whispering instead of talking normally: class CastleKilmereMember: ''' Creates a…

Custom exception classes

Topics: Custom exception classes Errors and Exceptions First of all, what is an exception? As outlined in the Python docs there are two big kinds of errors: syntax errors and exceptions. Syntax Error: A syntax error is an error that makes it impossible to parse a program. That’s why it’s also called a parsing error. Whenever we made a mistake in the syntax of our code (for example, we…

Extending the Magical Universe

Topics: Extending the Magical Universe with classmethods for Charm, Hex, Curse, etc. Today I added classmethods to the different Spell subclasses. Speficially, I added one classmethod for each spell type: Charm, Transfiguration, Jinx, Hex, Curse, CounterSpell, HealingSpell such that at least one charm, hex, jinx, … exists in our universe. Tomorrow I will write test code for the entire…

Multisets, `collections.Counter`

Topics: Multisets, collections.Counter Counting objects Today I want to present a very useful class in Python: collections.Counter. You might wonder what is so great about this class: it allows us to count all kinds of objects! And who doesn’t love counting? For example, consider all the potion ingredients Cleon, Flynn and Cassidy need to buy for a school year. We can easily create a…

Iterators

Topics: Iterators, iterables and iteration Iterators Although we need to create more test functions for the other Magical Universe classes, I want to spend a few days on iterators. First of all, what is meant by the term iteration? Iteration describes the process of taking an item and looking at each of its components one by one. Any time we use a loop like for component in item: print(component)…

Testing code with pytest

Topics: Testing code with pytest Updated 2020-10-05 Writing test functions for our code is extremely important. Since I have been lazy writing test code myself, I want to spend a little more time on this topic. My favorite testing framework is pytest. I’m not an expert on testing, so please consider this post an introduction to testing rather than a thorough guide. Why pytest? Using pytest…

Context managers and the `with` statement

Topics: with statement and context managers Updated 2020-10-05 Context managers and the with statement Similar to decorators, context managers are a concept many people use but only few understand. If you haven’t heard of the term ‘context manager’ before: you probably encountered them already while reading or writing from/to a file using the with statement. The most common use…

The mysterious `if __name__ == "__main__"`

Topics: What is if __name__ == "__main__" doing? I always wanted to dig into the statement if __name__ == "__main__" that is used in so many programs. I have used it for a long time already but until recently I had no idea what exactly it is doing. To make the topic as understandable as possible, I will divide the explanation into three steps. Step 1: Two ways of running code We saved our Magical…

Decorators within classes

Topics: Decorators within a class Updated 2020-10-05 After having talked about decorators already on day 5 and day 6 I would like to revisit the topic to discuss how decorators can be used within classes. Let’s put ourselves in the position of a Castle Kilmere member during the time the school is in war with Master Odon and his Dark Army. So these are dark, scary times. People at Castle…

Immutable data classes

Topics: Immutable data classes Updated 2020-10-05 We have talked a lot about data classes in the last post. There is one further characteristic of data classes that I would like to study - immutability. We can make a dataclass immutable such that it fulfills the same purpose as typing.NamedTuple. To make a dataclass immutable we have to set frozen=True when creating the class. Let’s see how…

Data classes

Topics: Data classes Updated 2020-10-05 Data classes are a feature that is new in Python 3.7. And taking a look at them is definitely worth it! Data classes According to the PEP on data classes, they are basically “mutable namedtuples with defaults”. We already looked at namedtuples on day 10 and 11. Namedtuples allow us to create an immutable class that primarily stores values (i.e.…

Abstract Base Classes

Topics: Abstract Base Classes, ABC’s Updated 2020-10-05 The last days I have been working on a lot of new classes and methods. Since they all belong to the same big concept, I decided to create one big post on the whole topic instead of several small ones. So let’s get right into it! Abtract Base Classes Up to now, our Magical Universe has a parent class (CastleKilmereMember) and…

Namedtuples

Topics: Immutable classes, namedtuples Updated 2020-10-04 Tuples Before looking at namedtuples, we should review what a tuple is. In Python, a tuple is a simple data structure that can be used for grouping arbitrary objects. Important to know is that tuples are immutable. That means that once a tuple has been created, it can not be changed anymore. We already used tuples in our Magical Universe.…

Duck typing, EAFP principle

Topics: Duck typing, EAFP principle Updated 2020-10-04 Duck typing Today we are going to look at some fundamental philosophies of programming: duck typing, EAFP and its opposite LBYL. Some of you may have heard of these principles already. However, because they are so fundamental we want to make sure that we apply them to our magical universe correctly. So what is duck typing? The most common…

Extending the Magical Universe

Topics: Adding new classes and methods to the Magical Universe Today I used some of the concepts introduced during the last days to extend my Magical Universe. Specifically: I added a classmethod for creating the ghost ’the mocking knight' I added a ‘friends’ attribute to the Pupil class I added methods for adding and listing all current friends of a Pupil I implemented a new…

Underscore patterns for variable naming

Topics: underscore patterns for variable naming, _variable, __variable, __variable__, _ Updated 2020-10-04 Underscore patterns for variable naming Today we are going to look at a very important concept in Python: the usage of underscores when naming variables! In Python we have five different naming conventions that involve underscores. A variable with a single leading underscore like _elms This…

Properties, setter and getter methods

Topics: properties, @property and property(), setters, getters Updated 2020-10-04 Today, I digged a little deeper into the @property decorator, how it is related to the property() function and how its getter and setter methods work. These two links (link1, link2) were really helpful. Of course, there is also the official Python docs on the property() function. The @property decorator Yesterday we…

Decorators

Topics: decorators Updated 2020-10-04 Today, we are going to look at decorators. Python’s decorators are an advanced concept so don’t worry if you don’t immediately understand how they work. The more you will use and read about them, the clearer the concept will become. I won’t go into too much detail here, so if you want to know more about decorators, take a look at Dan…

To-string conversion

Topics: to-string conversion, __repr__, __str__ Updated: 2020-10-04 To-string conversion Today we are going to look at the two methods that control how an object is converted into a string object. When we just print an object, we won’t get a useful representation. For example, when trying to print the bromley instance: bromley = CastleKilmereMember(name='Bromley Huckabee', birthyear=1959,…

Type annotations

Topics: Type annotations Updated 2020-10-04 Type annotations Type annotations are a very cool feature that came out with Python 3.5. They allow us to add arbitrary metadata to function arguments and the return value of a function. Why this is useful? First of all, it allows us to document of what type our function parameters are. Furthermore, they can be used for things like type checking. For…

Types of class methods

Topics: class methods, instance methods, static methods, using class methods as alternative constructors Updated 2020-10-03 Types of methods A class can have three types of methods: instance methods, class methods and static methods. Instance methods are the most common type of method. They take at least the parameter self as an input. This parameter points towards an instance of the class when…

Object-oriented programming

Topics: object oriented programming, classes, inheritance I want to start with using some of the things I learned from the “Python Tricks” book (see my reading list for more details on the book). Therefore, I will start creating a little Magical Universe with classes and methods related to the Tales of Castle Kilmere. So let’s start with the most important basics. What is Object…

100 Days of code - Creating my personal Magical Universe

I have decided to take on a new habit using a technique I found on the ‘get discplined’ subreddit. The technique works as follows: Take a piece of paper or card Draw 6 vertical lines intersecting 6 horizontal lines. This creates a 7x7 grid of 49 squares Choose a daily habit you want to work on and write it down on the back of the card Also put down WHY you want to work on the habit…

The Tales of Castle Kilmere

My magical universe: “The Tales of Castle Kilmere” The main character of our magical universe is named Lissy Spinster. Lissy is a quiet, clumsy girl of age twelve. Although she is sticking her nose into books most of the time, she is always watching her surroundings very closely. Lissy and her older brother Gary don’t get along very well. Gary considers his sister a little weird…

(untitled)

Mindset - changing the way you think to fulfil your potential 1. The mindsets Some people love challenges and thrive on them Experiments with kids that had to solve hard puzzles. Some quickly gave up, other got excited: “I love a challenge!” What do these kids have what some of us lack? Fixed mindset: Belief that qualities like intelligence, creativity, etc. are carved in stone…

My path to machine learning

My enthusiasm for machine learning arose from my fascination for the human brain. I have been fascinated by the complexity of the human brain for most of my life. Consequently, I decided to study cognitive science in Osnabrück, Germany. After attending a machine learning class in my fourth semester I discovered my true passion: The study and delevopment of algorithms that can learn on their own,…

Personal news

2023 2023-11-01 I was invited to the podcast “Talk Python to Me” to talk about environment management and packaging. Check out the episode here. 2023-10-06 I was invited to the German “Python Podcast” to talk about environment management and packaging. Check out the episode here. 2023-07-19 I presented an updated version of the talk “An unbiased evaluation of…