How to Enter Your First Zindi Competition

Predict who is most likely to have a bank account

--

Zindi Africa Logo

This article was updated on 23 Dec 2020.

Zindi Africa is Africa’s largest data science competition platform, solving complex challenges using artificial intelligence (AI) and machine learning (ML). The platform allows data scientists across the African continent to compete to solve challenges that focus on transport, health, social impacts, agriculture, African languages, electricity, or economics, to name a few.

The word Zindi comes from two Swahili words “zidisha”, meaning multiply and “shinda” means to win. Currently, Zindi Africa has more than 20,000 registered Data scientists and they have successfully launched 55 competitions and 40 hackathons. Zindi has 50 awesome Ambassadors in different 25 countries.

Big Data Jobs

Zindi Africa provides different categories of competition:

  • Prize competition: you win prize money if you are among the top 3 winners of a particular competition.
  • You win points: Points increase your ranking among other data scientists on the platform.
  • You gain knowledge: Knowledge competitions are where you can learn and increase your skill set.

As a data scientist or ML engineer in Africa, Zindi Africa is the best platform for you to learn and take your skills to the next level. The following are some of the benefits you can gain by being part of the Zindian family:

  • Test your skills against top talent across Africa and beyond
  • Learn by doing and gain practical exposure to real data science problems
  • Earn income by doing what you enjoy
  • Build your profile and attract potential employers
  • Learn from others through collaboration and discussion with other data scientists and ML engineers.

In this article, I am going to provide a walkthrough of how to enter a Zindi competition for the first time. In this article we will:

  • Join a specific competition called Financial Inclusion in Africa
  • Understand the competition description and problem statement
  • Download and analyze the dataset provided
  • Process the dataset provided
  • Develop a model to predict who is most likely to have a bank account
  • Evaluate the model performance
  • Use the model to make predictions for the test dataset provided in the competition
  • Make the first submission and get placed on the Zindi leaderboard

Financial Inclusions in Africa

Before we go deep into the competition, let’s understand the competition page first by clicking here. If you don’t already have a Zindi account you can create one for free here.

Zindi competition page

The competition page provides some information to help you understand the problem you are going to solve, by reading the problem statement, how you can participate and how to submit your solution on the platform.

I will go through each tab and explain its functionality.

1. Info

The info tab contains the problem statements of the competition and list of organizations that have either provided the dataset or funded the competition.

On the left side, you can see a list of vertical tabs that provide more information about the competition.

Trending AI Articles:

1. Why Corporate AI projects fail?

2. How AI Will Power the Next Wave of Healthcare Innovation?

3. Machine Learning by Using Regression Model

4. Top Data Science Platforms in 2021 Other than Kaggle

(a) Description
It provides the problem statement of the competition and a list of organisations or companies that supported the competition, either by providing the datasets or funding the competition.

I suggest you read the description of this competition in order to understand the problem and machine learning approach you can choose to solve it. If you read the description, you will understand that the objective of this competition is to create a machine learning model to predict which individuals are most likely to have or use a bank account.

(b) Rules

rules

Each competition has its own rules. Breaking the rules can lead to disqualification, so make sure to carefully read and understand all the rules of the competition.

(c) Prizes

Now, this is the best part: the prize section provides details about the prize money that will be provided for the first, second and third place winners of the competition. But remember not all competition provides prize money for its winners; in other competitions, you can get Zindi points or gain knowledge.

(d) Evaluation

Evaluation

Each competition has its own evaluation metric that will be used to evaluate your results and rank you on the leaderboard. It also shows how you should prepare your submission file before uploading your file on the platform.

For this competition, the evaluation metric will be the percentage of survey respondents for whom you predict the binary ‘bank account’ classification incorrectly.

(e) Timeline

Timeline

This section provides information about the start date of the competition and the end date and time of the competition. If you submit your solution after the deadline you will receive a score but it will not reflect on the leaderboard. Make sure to submit before the deadline if you want to be considered for a prize.

This competition has been reopened as a knowledge challenge, this means it will not close.

2. Data

data page

The data tab contains a description of the dataset you are going to use for this competition. On the right side of the page, you can see a list of links to download the dataset and other important files. You will download:

  • VariableDefinition.csv — This file contains a definition of each variable in the train and test data.
  • SubmissionFile.csv — The file contains a sample of how the submission file should look like.
  • Test_v2.csv — This is a test data file you will use for prediction and save your results in the submission file.
  • Train._v2.csv- This is a train data file that contains both the independent variable and the target one. You will use this dataset to train your model.

These files may differ between competitions. Also, keep in mind that you must join the competition in order to have access to the data files.

3. Discussion

Discussion page

I’m not a Liverpool FC fan but I like their slogan: “You will never walk alone”. That is the purpose of the discussion page, you don’t need to walk alone throughout the competition. If you face any challenge or uncertainty during the competition or you want to ask a question to understand more about the dataset provided, you can post on the discussion page and other data scientists enrolled in the competition can help you to solve the problem.

The discussion board is very active and full of knowledgeable and helpful African data scientists willing to assist you.

4. Leaderboard

leaderboard

After you have uploaded your submission file, you will appear on the leaderboard. The leaderboard shows your position among all enrolled data scientists in the competition. Your position will depend on your performance after your solution has been evaluated. For this competition, you can submit ten times a day.

5. Team

You don’t want to do the competition on your own? That’s OK! You can create a team with fellow data scientists enrolled in the competition and work together. The maximum number for a team is 4 members. Remember that sharing code between individuals is not allowed, so if you want to share code with someone else, they must be on the same team as you.

6. Submission

Submission file

The submission page is where you will upload your submission file, by clicking the orange button at the top right side of the page. After you have uploaded your solution, it will be evaluated according to the evaluation metric specified in the competition. Then you will see the score that will define your position on the leaderboard.

Solve The Problem

After understanding the Financial Inclusion in Africa competition page and different sections in it, let’s solve the problem provided.

1.Load The Dataset

Make sure you have downloaded the dataset provided in the competition. You can download the dataset here.

Import important python packages.

Load the train and test dataset.

Let’s observe the shape of our datasets.

train data shape : (23524, 13)
test data shape : (10086, 12)

The above output shows the number of rows and columns for train and test dataset. We have 13 variables in the train dataset, 12 independent variables and 1 dependent variable. In the test dataset, we have 12 independent variables.

We can observe the first five rows from our data set by using the head() method from the pandas library.

First five rows

It is important to understand the meaning of each feature so you can really understand the dataset. You can read the VariableDefinition.csv file to understand the meaning of each variable presented in the dataset.

The SubmissionFile.csv gives us an example of how our submission file should look. This file will contain the uniqueid column combined with the country name from the Test_v2.csv file and the target we predict with our model. Once we have created this file, we will submit it to the competition page and obtain a position on the leaderboard.

Sample Submission

2.Understand The Dataset

We can get more information about the features presented by using the info() method from pandas.

variables information

The output shows the list of variables/features, sizes, if it contains missing values and data type for each variable. From the dataset, we don’t have any missing values and we have 3 features of integer data type and 10 features of the object data type.

If you want to learn how to handle missing data in your dataset, I recommend you read How to handle missing data with python’ by Jason Brownlee.

I won’t go further on understanding the dataset because I have already published an article about exploratory data analysis (EDA) with the financial Inclusion in Africa dataset. You can read and download the notebook for EDA in the link below.

3.Data Preparation for Machine Learning

Before you train the model for prediction, you need to perform data cleaning and preprocessing. This is a very important step; your model will not perform well without these steps.

Time spend on a Data Science Project

The first step is to separate the independent variables and target(bank_account) from the train data. Then transform the target values from the object data type into numerical by using LabelEncoder.

bank_acount output

The target values have been transformed into numerical datatypes, 1 represents ‘Yes’ and 0 represents ‘No’.

I have created a simple preprocessing function to handle

The processing function will be used for both train and test independent variables.

Preprocess both train and test dataset.

Observe the first row in the train data.

First row from Train set

Observe the shape of the train data.

(23524, 37)

Now we have more independent variables than before (37 variables). This doesn’t mean all these variables are important to train our model. You need to select only important features that can increase the performance of the model. But I will not apply any feature selection technique in this article; if you want to learn and know more about feature selection techniques, I recommend you read the following articles:

4. Model Building and Experiments

A portion of the train data set will be used to evaluate our models and find the best one that performs well before using it in the test dataset.

Only 10% of the train dataset will be used for evaluating the models. The parameter stratify = y_train will ensure an equal balance of values from both classes (‘yes’ and ‘no’) for both train and validation set.

I have selected five algorithms for this classification problem to train and predict who is most likely to have a bank account.

From these algorithms, we can find the one that performs better than the others. We will start by training these models using the train set after splitting our train dataset.

After training five models, let’s use the trained models to predict our evaluation set and see how these models perform. We will use the evaluation metric provided on the competition page. The statement from the competition page stated that:

The evaluation metric for this challenge will be the percentage of survey respondents for whom you predict the binary ‘bank account’ classification incorrectly.

This means the lower the incorrect percentage we get, the better the model performance.

results

XGBoost classifier performs better than other models with 0.110 incorrect.

Let’s check the confusion matrix for XGB model.

xg_model confusion matrix

Our XGBoost model performs well on predicting class 0 and performs poorly on predicting class 1, it may be caused by the imbalance of data provided(the target variable has more ‘No’ values than ‘Yes’ values). You can learn the best way to deal with imbalanced data here.

One way to increase the model performance is by applying the Grid search method as an approach to parameter tuning that will methodically build and evaluate a model for each combination of algorithm parameters specified in a grid.

The above source code will evaluate which parameter values for min_child_weight, gamma, subsample and max_depth will give us better performance.

best parameters

Let’s use these parameter values and see if the XGB model performance will increase.

Error rate of the  XGB model:  0.10837229069273269

Our XGB model has improved from the previous performance of 0.110 to 0.108.

5.Making the first submission

After improving the XGBoost model performance, let’s now see how the model performs on the competition test data set provided and how we rank on the competition leaderboard.

First, we make predictions on the competition test data set.

Then we create a submission file according to the instruction provided in the SubmissionFile.csv.

Let’s observe the sample results from our submission dataFrame.

submission samples

Save results in the CSV file.

We named our submission file a first_submission.csv. Now we can upload it to the Zindi competition page by clicking the submit button and selecting the file to upload., You also have an option to add comments for each submission.

upload submission file

Then click the submit button to upload your submission file. Congratulations, you just made your first Zindi submission! The system will evaluate your results according to the evaluation methods for this competition.

test scores

Now you can see the performance of our XGB model is 0.109 on the test dataset provided.

You can also see your position on the Leaderboard.

Wrap Up

In this article, I have given an overview of how to make your first submission to a Zindi competition. I suggest you take further steps to handle the imbalance of data and find alternative feature engineering and selection techniques you can apply to increase your model performance, or trying other machine learning algorithms. If you get stuck, don’t forget to ask for help on the discussion boards!

You can access the notebook for this article in the link below.

You can watch an interview with the CEO of Zindi Africa, Celina Lee on AI Kenya Podcast.

If you learned something new or enjoyed reading this article, please share it so that others can see it. Feel free to leave a comment too. Till then, see you in the next post! I can also be reached on Twitter @Davis_McDavid

One last thing: Read more articles like this in the following links.

Don’t forget to give us your 👏 !

--

--

Data Scientist 📊 | Software Developer | Technical Writer 📝 | ML Course Author 👨🏽‍💻 | Giving talks. Contact me to collaborate https://davisdavid.com/