While I had gotten the hang of the LaberEncoder() command in the sklearn library, the documentation states that Labelencoder should only be used to convert the target or label to a numeric value. In order to convert the independent variables of a dataframe to a numeric value, OrdinalEncoder() needs to be used. In order to practice machine learning within the sklearn user documentation I therefore decided to try my hand at the OrdinalEncoder() command.

OrdinalEncoder() takes an array-lie of integers or strings and converts these values to ordinal integers, resulting in a column of integers one less than the total number of features (the reason being that the numbering system of python starts at 0.

In order to develop my skill at ordinal encoding, I decided to use a dataset that has a lot of features. The DrivenData website has a competition question about water pumps and the datasets used can be found in the below web address:- https://www.drivendata.org/competitions/7/pump-it-up-data-mining-the-water-table/data/

The problem statement for the competition question entitled. “Pump It Up: Data Mining the Water Table”, is stated below:-

“Using data from Taarifa and the Tanzanian Ministry of Water, can you predict which pumps are functional, which need some repairs, and which don’t work at all? Predict one of these three classes based on a number of variables about what kind of pump is operating, when it was installed, and how it is managed. A smart understanding of which waterpoints will fail can improve maintenance operations and ensure that clean, potable water is available to communities across Tanzania.”

The first thing that I did was to load the Python libraries that would be used to solve this problem. I also loaded and read the files that would be necessary to complete the question. The files are too large to put on my github repository, so I had to save them into my Google drive where I am given 16 gigabyte free storage:-

#ordinalencoder #machine-learning #data-science #python #data-driven

How I Used OrdinalEncoder() to Solve a Water Pump Problem
1.90 GEEK