Coding.Mnemonics(beginner)

If there is something I have noticed for a couple of years now, is the increase in demands of IT skills in any kind of industry. I am part of these professionals who did not study Computer Science; and yet I have been climbing the difficult mountain of Data Science for a while.

I recently had a chat with a teammate about this struggle we both share. There is a lot to learn, so it is hard to choose what to focus on. We must also keep in mind between strategic skills for us as Data Scientists, and those that are valuable for our employer right now.

As you may know, Data Science is both a professional field and a buzzword. Whatever you have heard about it, many suggest starting with data analysis using Python.

Unfortunately, I think they fail to explain the real purpose of it.

Python is renowned for its simple syntax, hence it’s easier to learn if you haven’t an IT background. And when it comes to Data Science, it is with R one of the most demanded skills. Besides Data Analytics, Python can also be used to build some cool automation that would simplify your life and the one of your team.

The more you build knowledge and expertise, the less you might need to rely on your small overloaded Kaizen Development team. That is, with the caveat that either you use your cool, newly acquired skills for side quests, or you land a better job with them. The latter was my case.

In this article I want to cover some of the difficulties I met while learning to code for data science, and how I am overcoming them.

Bursting few bubbles

Assuming you are new to coding, probably you already experienced one or more of these three big obstacles that online courses fail to address:

  • The perfect way to code
  • The importance of mathematics
  • Code evolves constantly
1. The perfect way to code

There isn’t one. While courses and books usually cover foundational logic the same, people use different styles to code. Python in particular is very versatile and there is no perfect way to do things for a beginner. You will learn to refactor (= to polish your code) in time.

What really matters is that you understand what you are doing. When writing a function or a sequence of operations, you need to know the basic function logic AND what you want your code to do at the same time.

2. The importance of Mathematics

The word “science” in Data Science is not just a fancy. I would like you to keep in mind this personal consideration of mine: learning a programming language is the equivalent of learning a new language that is more logical than conceptual. As if you were learning Italian, but with a syntax that is more mathematical than linguistic.

That is what beginners may need to focus on, and there is much more than that. For example, if you are interested in doing data analysis, you need to know well statistics. Libraries can do the heavy lifting, but again, you need to know what you are doing, and what is what.

That becomes even more clear if you start to work on machine learning or decision optimization.

3. Code evolves constantly

While spoken languages transform over decades, code changes overnight. That is something you find out when you begin your Python course on Udemy, copy-paste the script given by the instructor and it does not work. Everything you did is the same, except it’s 2022 and the course was uploaded in 2015.

I refer specifically to Python in this regard because I see how fastly libraries evolve and the same thing that worked well today will be deprecated tomorrow. It can be frustrating for newcomers, however, it is a symptom of an open-source community actively improving the tool you are using, making it more efficient.

Mnemonics for coding

I am far from being a memory expert, but I use mnemonic devices daily and I actively promote their use for study. We cannot leverage learning without memory.

Memory is stored knowledge that we can use to better understand what we know. I used the Magnetic Memory Method of Anthony Metivier to learn Slovak and memorize body language patterns. So I thought: why not apply the same to Data Science?

Truth to be told, the part I struggled with the most is coding. Right now, I can’t afford Anthony’s Masterclass, which sounds promising. So I came up with some devices that actually work for me. The ones I am about to share regard the coding.

Spatial Repetition
Image Credits: easygenerator.com

This exercise is based on Hermann Ebbinghaus‘s findings on the forgetting curve. In my own words, if we learn some code and it does not make much sense right now, we are going to forget it soon.

The way to overcome this issue is to repeat the code over time. We want to make sure that the information moves from the short to the long-term memory. This is what you want to do especially with basic code like the following:

> import pandas as pd
> df = pd.DataFrame({'a': pd.Series(a), 'b': pd.Series(b)})
> print(df.head()) #show the first 5 rows

This short code can be leveraged for many use cases in my job. It shows more complexity than just df = pd.DataFrame(list_values, ‘columnname’) but it is still simple.

If you have a smartphone or a computer around, you can perform spatial repetition by rewriting the code. The trick is to avoid checking the answer. You want your brain to be challenged, to think that this information must be very important. The more we repeat, the better.

KAVE COGS

If you have no access to a terminal you can still practice spatial repetition. All you need to do is to switch to a different aspect of your memory. The concept of KAVE COGS is amazing and consists of using multiple sensorial skills to remember the same information.

Let’s break down KAVE COGS into its elements: Kinesthetic, Auditory, Visual, Emotional, Conceptual, Olfactory, Gustatory, Spatial.

In our heads we can use sounds, colors, and even feelings to strengthen retention.

In our previous exercise, we used “kinesthetic” to remember the code (writing and executing the code over and over again). If we got no place to write the code, we can use the other dimensions of memory. We can try to visualize it in our mind or even associate mental imagery to its component, as we do when learning languages. In this way, we will put together the “visual” and the “conceptual” aspect of it. If we know how to use memory palaces, we can stick the information to a “spatial” dimension too.

It is easier to do than to explain it. Notably, these exercises require practice, too. Therefore, the more you use them, the easier they will become to use; and in turn, you will remember better and learn quickly and with effectiveness.

(Hint: you can still write the code on paper and try it later at home if you want)

Learning by comparison

As we progress in our learning we may need to learn some new programming language. I find it interestin to use what I know from previous learning to discern what I do not know yet. It boils down to learning just the differences.

As I need to learn some Linux script right now, I use my prebuilt Python knowledge whenever I can to help myself. Like in the example below.

Logic of IF Statement: Bash vs Python

I think of this as the same job of a foreign language interpreter, except that in this case, we don’t know both languages very well. Wherever the logic appears similar, the differences are what make these scripts unique. The fact that they are similar but different make it easier to remember them.

Conclusion

“Neurons that fire together, wire together.”

Donald Hebb, Neuropsychologist

For a total neophyte, doing is more important than knowing. That helps overcome the first barrier, which is getting started. We can learn by doing, and spatial repetition is a great help there.

That, however, does not replace the pure abstract knowledge and the logic behind it, as I stated from the beginning. It is important you know that to do not find ugly surprises on your journey, later on.

When doing is not possible, you can use other mnemonics to help yourself. KAVE COGS is one of the best meta-learning techniques I met on my way, bringing you beyond the traditional learning systems we use.

Finally, more advanced learners can even use comparison to learn what matters only, based on what we already know.

Even better, we can combine all these techniques.

If coding rules change over time, compare before vs after and use KAVE COGS to reinforce your newly acquired notion. Then practice, practice, practice.

“What is different when we call a variable in Bash compared to Python?”

Every time we will see $ followed by something, that must be a variable in Bash. Furthermore, “$” is a big difference with Python, where it is an illegal character.

Look into your mind. Put a cartoonish $ beyond the bars of a prison, guarded by a blue-yellow snake. Moments after, the $ escapes and bashes the snake on the head with a stick, quite the Looney-Tunes kind of scene.

You aren’t going to forget that piece of info, do you?

Published by Andrea Paviglianiti

I practice coaching, I love reading, and I work as a data scientist. I also recharge my batteries with meditation, martial arts, and video games. I perform career and skills coaching – thus I define myself as a “cognitive” coach: I help people improve their learning experience to succeed where they want. My method is based on behavioral analysis, psychology of learning, philosophy of dialogue, and classic literature. I write about how to get better at learning, the best books I read, and my personal philosophy of coaching. And I will not lie to you – I can get verbose at times! I’d be happy if you stick around and read more of what I have to share!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: