Member-only story

Use Jax and Flax to create a MLPClassifier using one hot encoding and softmax activation

Crystal X
6 min readJan 18, 2024

--

In an earlier blog post, I discussed how to use softmax activation to predict the classes of the well known iris dataset. The iris dataset has a multiclass target with the unique values of 0, 1 and 2. Because the numbering system of the Python programming language begin with 0, it is relatively easy to make predictions on the iris dataset.

But what if the numbering of the target begins with another number, such as 1? In such a case not only will the target need to be one hot encoded, the one hot encoding will need to be manipulated to take account of the change of the numbering of the target. In this blog post, I intend to demonstrate how to manipulate the numbering in the one hot encoding to fall in line with the numbering of the target.

I have chosen the seed dataset that I found on Jason Brownlee’s website to demonstrate how to code one hot encoding to take account of target numbering that does not start with zero.

I have written the Python program using Google Colab, a free online Jupyter Notebook hosted by Google.

Once the notebook was created, I imported the libraries that I would need to facilitate execution of the program, being:-

  1. Pandas to create dataframes and process the data,

--

--

Crystal X
Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet