Enhance your technical and communication abilities, study to put in writing readable code and begin writing about something
After I first began writing, I may hardly code. My little Python expertise got here from college tasks. On the identical time, I assumed I used to be an important author! Now wanting again, I cringe at a few of my earlier articles.
This reveals me that writing tutorials has improved each my technical and communication abilities. In the end, it has made me a greater information scientist. I need to share my expertise and talk about some particular advantages. This consists of writing readable code and offering step one to writing about troublesome subjects.
Technical abilities are clearly vital to builders and information scientists. On the identical time, we work in fields which are continually altering. This implies we have to sustain with the most recent instruments. This may be troublesome and time-consuming so it takes an actual dedication to study repeatedly.
Writing has motivated me to constantly study new technical abilities and to develope a deep data on these subjects.
Writing has been an important motivator. Not solely can I study new issues however I can share these classes with the world. It’s addictive — having individuals learn and work together along with your work. The will to constantly submit new articles has pushed me to constantly study new issues.
Not solely that however I discover writing is the greatest method to study. Usually it’s solely after I’ve tried to elucidate one thing that I’ve realised I don’t truly perceive it. On high of this, I all the time intention so as to add worth to a subject. Introducing novelty requires a great understanding. On this means, writing has been a verify on my data. It has pushed me to actually perceive the technical ideas I write about.
Writing readable code
A associated ability is writing readable code. Good code ought to clarify itself. Equally, a tutorial primarily based on readable code is simpler to put in writing. I spend much less time explaining what the code does and sometimes you do not have to elucidate it in any respect. I’ve discovered this profit extends to collaborating in trade.
Any idiot can write code that a pc can perceive. Good programmers write code that people can perceive.
— Martin Fowler
An instance comes from a latest article of mine — Using SHAP to Debug a PyTorch Image Regression Model. Within the tutorial, I labored with SHAP values given in a 5-dimensional array. I needed to visualise this array utilizing one of many bundle’s capabilities. To do that, the array first wanted to be reordered. Initially, the code regarded like this:
# Reshape shap values for plotting
shap_numpy = [np.swapaxes(np.swapaxes(s, 1, -1), 1, 2) for s in shap_values]
The nested swapaxes capabilities weren’t enjoyable to elucidate. The TLDR is that the code transposed the array’s third dimension with the fifth dimension. I discovered myself writing a prolonged paragraph about how the code was doing this. So, as a substitute, I rewrote the code:
# Reshape shap values for plotting
shap_numpy = checklist(np.array(shap_values).transpose(0,1,3,4,2))
The transpose perform is extra intuitive and the code was simpler to elucidate. When writing code for tutorials, I’m all the time searching for examples like these. Readable code makes the writing course of smoother and the tutorial extra digestible.