Wednesday, 30 October 2019

PyLadies Night with Achere

Achere is a Software Engineer who doubles as a Big Data Engineer. She had her undergraduate studies in Computer Science at the Kwame Nkrumah University of Science and Technology (KNUST) and a Masters in Data Science at the University of Dundee, Scotland. She volunteers with Tech Needs Girls GH and Stemettes in her spare time. She loves to work with Java and Python. Her hobbies are playing basketball and reading mostly African Fiction. She watches anything made by Marvel or DC.
Fun Fact? She has walked from College of Physicians and Surgeons to the Accra Mall just to beat time and avoid traffic

Tell us briefly about yourself. How would you describe Achere?
I'm a software engineer and data scientist, went to KNUST for my BSc in Computer Science and University of Dundee for my masters. I code in Java and python.

We want to know how it all begun for you. How did you get into the field of Computer Science, did you always want to be in it?
I wanted to be an engineer since I was young, I chose to do computer science because I was very comfortable with computers.

What triggered this interest/passion?
I've always liked gadgets and playing video games. I wanted to be a game developer when I started, but I changed my mind along the way. Writing C didn't look like a career path. Most games are written in C.

Can you tell us more about the beginning for you after the change from game development?
After game development failed, I went into mobile developement because I liked gadgets and I liked the idea of being able to create your own apps. This was while I was in KNUST, my final year project was an android game. I learnt Java in the process. Android was mostly Java. Then I sort of picked up python along the way because of django, for web services. Then after school I went to work at a Mest company called nandimobile
After nandi I went to work at vodafone as an apps developer after which I decided to go and do a masters program because I developed an interest in data science. I had been reading about it for a while because of a project i was working on. So I left and went to school for a year, after school I joined a bank where I work as a software engineer and big data engineer depending on what project i'm working on.

So you had your Masters in an internationally recognized institution in Scotland. That's like academia goals for some of us.Any applications tips for  aspiring applicants?
The first one should be you should know what you want to do when applying for school. It may sound very obvious but a lot of people don't know what they want to do exactly for a course. It helps when you're writing your application letters to the school. Also volunteer to things that interest you, it
could be mentoring, coaching, taking part in open source contributions.

What was your experience studying Data Science and what should we look out for when applying to schools to offer Data Science?
It was a very nice experience, very different from the Bsc one.
You get to be a lot more independent. Individual and critical thinking is encouraged a lot. You should check the modules of the data science course the school is offering and its quite useful if the school encourages internships with companies as part of the course. Its always good to get some industry experience while still a student.

How's a typical day at work as a Data Engineer?
A typical day is mostly sitting behind the computer and coding coding coding lol
There's a lot of meetings, figuring out what the clients want and whether you understand what the client wants. Even before you start writing code. We use Agile software methodology at work, meaning we can't go into production unless the product owner gives it a green light. We have a big jira board that has all the tasks we have to work on and we have daily stand up meetings where we talk about what we're working on and what we have achieved so far

So is it safe to say your day begins at 8 and ends at 5?
My day starts at 9 and ends at 5:30

What are some of the things you do as a Big Data Engineer, what tools do you mostly use and why?
I'm currently working on a project that uses NLP(Natural language processing), we have some emails we get from our regulators and because of the tight turn around time, we want to skip the part where users read the email themselves. They usually have to go through the email and get some details from them and enter them into some form online. We're trying to use NLP to extract that information and send them to the form automatically so the user just has to go straight to the form. Whenever we miss a deadline, we get fined a lot of money. So that looked like a good use case for NLP and data extraction. 
For tools, we use the Stanford NLP library because its quite good when trained well, we need an accuracy of 80% and we're getting about 95%. We use pandas as well to create an accuracy matrix report for the users to see how good the software is doing.

Tell us about a fun but challenging project you had to handle as a Big Data Engineer and how you solved it.
Actually this same project. It has about 3 different parts written in 4 languages - Java being the main one then we have python and angular 6 for the front end. The challenging part was training the model, I had to train about 200 emails per user and kept tuning the model till we got our current accuracy. Also, there was this time we received a letter our model didn't recognize, so we had to retrain again

What do you love doing with Python? What would you have not been able to do in Data Science if Python was not in existence?
Mostly data analysis. Have you tried parsing a string or doing calculations with Java before? Its a huge headache! I used to use R for data analysis till I switched to python, there are more libraries in python now and it has a great community support. Pandas on its own as a tool is one of the best things to ever happen. I learn something new every time I try to use pandas to do something. Apache Spark also uses python a lot.

How do you juggle being a Software Engineer and a Data Engineer? There must be some serious time and project management skills there. Can you fill us in on any tips/hacks?
For me its more time management than project management, I mostly use my software eng skills in data eng so I kind of see them as doing the same thing, just that the end products are different. With one you're trying to build something, with the other you're trying to find out something.

What advice will you give to aspiring data scientists? Can you point us to any materials we can use in our quest to study data science right from the beginning?
I would say improve your coding skills, learn a lot of python. Try to understand statistics because it would help you understand how the libraries that alogs are using work. Always be curious, it helps a lot. If you like video tutorials, edx and cousera have some very good courses on beginning data science. If you like books like me, I would recommend Introduction to Data science,
Real world machine learning - and Naked Statistics by Charles Wheelan.

How can we keep in touch? Any contacts you'll like to share?
Yeah, you can follow me on twitter @Afrohacker (I tweet football some times but if you mention me I'll definately reply)

Questions from Participants

Please did you have challenges along the way that made you want to quit?
Yeah, like every time a project isn't going the way you want it to go or you're about to meet your deadline and you're nowhere near complete, but after a while you realise its really a part of the process, and work to complete what you can.

Also, what's your take about women not being able to pursue tech related courses. What challenge do you think women in the tech industry face?
There's a lot of challenges if you as a woman decide to go into a tech career. It has a lot of men, from the class room to the work environment. Its always good to have a community of women in tech who can help you out and who you can talk to.
You should also learn to be assertive and speak up for yourself, it's hard some times but if not you'll get walked over a lot of times. Also when you feel uncomfortable about some thing, you should speak to your boss about it. Its hard to be taken seriously some times, but you have to know that you're good at your job that's why you were hired.

You mentioned you were once interested in Gaming. Any advise for someone who really wants to pursue it to the max?
You should definitely go for it, there are a lot more tools now that make it easier

I really admire your journey through tech, but did you have mentors throughout this journey?
I had quite a few my boss at Nandimobile (Anne Amuzu) was very helpful, Regina Agyare as well and a few other women in tech in Accra.

This session was facilitated by Dorothy Ewua.

Wednesday, 16 October 2019

PyLadies Cape Coast First Meetup

On Saturday, 28th September, 2019, PyLadies Cape Coast had it's first meetup at the G-block,G-16, University of Cape Coast. The program recorded 31 ladies and 5 coaches. The program commenced at 9:00am and closed at 1:45pm.

After a 15 minutes informal and introductory session by the M.C, the program started with a long interaction lead by the Ms. Monica Koki, the local NUGS Womens Commissioner, UCC. The topic for discussion was “Women Empowerment”. The ladies shared their views on the need for women to take up roles, develop themselves to fit into the society and reach higher heights. There were several deliberations on bridging the gender gap in the tech ecosystem by inviting more ladies and exposing them too latest technological tools. The session lasting for an hour ended with few questions and answers.

The next session saw the Lead for PyLadies Cape Coast, Ms. Kausara Kpabia introducing Python to the ladies and talking briefly about the PyLadies Ghana community, its stakeholders, missions, achievement and visions in the long term. She also introduced the coaches to the participants and motivated the house to be a vibrant part of the PyLadies Cape Coast to help achieve the set goals for the chapter and the mother association, as a whole.

Thereafter, installations and preparations for the tutorial session began. The tutorial session lasted for two hours and thirty minutes where the ladies were taken through the basics of Python. From “Hello World”, to functions, the ladies gained mastery in Python basics from the tutor, Mr. Joshua Lartey.The event came to a close quickly after refreshment and socialization, at 1:45pm.The event saw very few challenges from start to finish. The major problem of the day was access to internet connection. The venue chosen was a poor hub for the chosen network service provider hence the challenge.

The session was very successful and we look forward to our next tutorial session. Big thanks to The PSF, Python Ghana and PyLadies Ghana.

Wednesday, 2 October 2019

How to prevent “RecursionError: maximum recursion depth exceeded” when using Django Signals.

As we grow in web application development, it comes to a point when we want to be able to carry out some tasks just before saving an object to the database or right after saving an object to the database.
In Django, this can be done using a feature called Signals. According to the documentation, Signals allow certain senders to notify a set of receivers that some action has taken place and that they’re especially useful when many pieces of code may be interested in the same events.
An example of an instance when using signals can be helpful is when you are trying to create an object after saving another one. Like when you try to create a Profile object immediately after creating a User object. Following the steps in the documentation would work smoothly.
However, in a case whereby you need to make changes to an object/objects of the same model, then you could have a challenge. In our example, we have a Favorites model and a Category model. A Favorite object is an item that has a name, category and rank in numbers. A Category object is just a category a Favorite object can belong to.
class Category(models.Model):
name = models.CharField('Name', max_length=30)
description = models.TextField('Description', blank=True)

class Favourite(models.Model):
title = models.CharField('Title', max_length=20)
description = models.TextField('Description', blank=True)
rank = models.SmallIntegerField('Ranking',)
category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='categories')
Above, we have the 2 models, Category and Favorites. In this little project, we want to adjust the ranks of our Favorites if there is a new Favorite with the same category and rank that already exists. For example, if we have a Favorite with name ‘Jordans’ in the ‘Shoes’ category with a rank of 1 and we want to add another Favorite with the name ‘Air Force One’ in the ‘Shoes’ category and rank of 1. We would want to update the rank of the ‘Jordans’ to 2 so that we can have the ‘Air Force One’ in rank 1. This way we would always have a unique Favorite every time.
One way to do this would be to add ‘unique-together’ as a meta property in the Favorite model and set it to rank and category. However, what this would do is to raise an error when we have a new Favorite with the same category and rank but would not make any changes. To resolve this, we can use a pre-save signal that would check the Favorite, before its saved if there already exists a Favorite with the same category and rank. If this is true, we then update the all existing Favorites with same category and rank that is equal or greater than that of the incoming Favorite to have 1 added to their rank.
def save_favorite(sender, instance, **kwargs):
   fav = instance
       favs = Favourite.objects.filter(rank__lte=fav.rank, category=fav.category)
       for f in favs:
           f.rank += 1
   except Favourite.DoesNotExist:
       passpre_save.connect(save_favorite, sender=Favourite)

But then, when you do this, you get this error:
RecursionError: maximum recursion depth exceeded while calling a Python object

This error occurs because we have modified the process of saving a Favorite object — the method will always call the save_favorite() and will result in an unending recursion which raises the above error.
To resolve this error, we will follow a different approach to saving our Favorite objects.
def save_favorite(sender, instance, **kwargs):
   fav = instance
   Favourite.objects.filter(rank__lte=fav.rank, category=fav.category).update(rank=F('rank') + 1)pre_save.connect(save_favorite, sender=Favourite)
Now, we see that we are no longer using the save() method which will result in the recursion. The update() works very well when you want to make updates to an object or objects of a model as we have done for the Favorite model.
I hope this article was helpful. Please comment below if you have any questions and I will reach out as soon as I can.