Male and Female Weight
Let's suppose we collected some data from some University students. We asked every student their gender (Male = M, Female = F) and their weight. We will build a model that can predict if you are a male or a female based only on your weight. I know this is not the ideal case for this, but this example will help to demonstrate a statistical trick to discriminate between two populations that show different behaviors in the same dataset.
Let's check the data
let's add some libraries we will use in our example:
from matplotlib import pyplot as plt
import numpy as np
import scipy.stats as stats
We will use some fake data to test this out and we will use sklearn to train-test split the data in a 70/30 proportion.
weight = [52, 46, 52, 47, 47, 49, 50, 47, 53, 55, 44, 52, 47, 48, 51, 54, 51, 51, 53, 52, 47, 52, 47, 50, 47, 53, 52, 44, 54, 52, 55, 55, 53, 42, 53, 50, 49, 49, 46, 52, 56, 48, 50, 56, 49, 44, 53, 46, 50, 51, 42, 37, 43, 53, 57, 50, 51, 51, 46, 48, 50, 47, 51, 47, 49, 49, 47, 44, 53, 51, 56, 58, 47, 44, 55, 53, 46, 53, 52, 47, 49, 52, 36, 49, 55, 49, 55, 55, 42, 50, 49, 37, 53, 45, 52, 56, 51, 55, 48, 58, 49, 56, 54, 48, 56, 49, 48, 57, 55, 58, 52, 51, 39, 43, 47, 45, 50, 54, 50, 49, 56, 43, 44, 50, 47, 36, 53, 47, 43, 51, 50, 50, 52, 54, 46, 49, 52, 52, 56, 52, 54, 43, 51, 52, 56, 48, 49, 55, 51, 64, 55, 46, 45, 52, 54, 46, 47, 56, 58, 50, 48, 46, 42, 54, 50, 53, 42, 55, 45, 54, 50, 51, 56, 48, 49, 47, 47, 52, 43, 47, 48, 47, 46, 53, 53, 51, 49, 47, 50, 57, 55, 51, 48, 55, 45, 49, 47, 47, 49, 54, 46, 49, 48, 50, 47, 48, 50, 52, 53, 51, 54, 34, 49, 53, 63, 49, 47, 50, 56, 51, 54, 46, 45, 50, 58, 43, 52, 49, 53, 50, 56, 48, 54, 45, 54, 46, 43, 51, 40, 57, 51, 45, 53, 50, 53, 52, 48, 56, 60, 48, 50, 51, 46, 47, 53, 52, 45, 47, 54, 49, 52, 53, 60, 58, 56, 53, 54, 44, 51, 54, 53, 51, 45, 53, 52, 52, 51, 42, 55, 54, 53, 45, 52, 49, 53, 58, 44, 47, 47, 45, 55, 53, 45, 53, 48, 50, 58, 52, 50, 45, 49, 55, 55, 54, 42, 47, 41, 46, 50, 55, 52, 47, 49, 48, 52, 51, 53, 50, 48, 45, 51, 53, 51, 61, 51, 41, 55, 43, 56, 53, 47, 53, 51, 51, 52, 56, 42, 42, 47, 48, 56, 46, 43, 43, 48, 50, 50, 50, 49, 51, 51, 47, 41, 49, 47, 44, 50, 52, 49, 49, 49, 45, 54, 54, 54, 45, 47, 49, 52, 51, 45, 49, 47, 54, 53, 55, 46, 53, 50, 51, 51, 53, 49, 52, 55, 47, 53, 51, 53, 49, 58, 53, 58, 53, 51, 49, 51, 42, 51, 46, 45, 61, 50, 40, 44, 40, 58, 46, 47, 50, 51, 45, 54, 45, 58, 43, 51, 48, 48, 57, 48, 50, 61, 47, 53, 56, 49, 40, 46, 53, 49, 50, 51, 58, 56, 61, 46, 55, 58, 49, 49, 49, 45, 50, 47, 53, 46, 53, 45, 52, 53, 47, 54, 54, 52, 55, 50, 45, 53, 42, 52, 52, 52, 52, 51, 49, 44, 61, 49, 47, 56, 48, 56, 41, 47, 50, 57, 57, 47, 53, 47, 51, 50, 49, 50, 47, 55, 50, 54, 60, 42, 53, 46, 58, 52, 54, 53, 46, 46, 55, 52, 50, 43, 48, 54, 44, 43, 45, 53, 58, 49, 48, 51, 48, 48, 39, 55, 56, 58, 52, 50, 49, 49, 54, 49, 49, 48, 55, 52, 47, 54, 48, 53, 50, 51, 49, 59, 47, 64, 51, 53, 54, 52, 48, 54, 56, 46, 52, 48, 41, 51, 55, 56, 49, 52, 48, 45, 50, 56, 49, 46, 51, 55, 43, 53, 47, 56, 64, 49, 46, 56, 45, 53, 50, 53, 50, 51, 48, 49, 53, 41, 44, 50, 50, 50, 49, 51, 53, 48, 51, 50, 50, 46, 59, 50, 46, 47, 44, 45, 48, 44, 49, 52, 52, 50, 51, 51, 49, 52, 49, 56, 51, 56, 50, 46, 43, 53, 61, 53, 44, 52, 57, 51, 56, 50, 53, 54, 46, 57, 52, 64, 52, 55, 54, 52, 52, 49, 53, 51, 57, 48, 50, 50, 52, 41, 51, 52, 50, 54, 51, 47, 51, 40, 54, 54, 52, 51, 54, 51, 46, 48, 53, 48, 49, 46, 47, 61, 49, 46, 39, 51, 48, 49, 53, 42, 52, 50, 55, 49, 46, 46, 51, 51, 56, 51, 52, 52, 54, 44, 46, 42, 36, 48, 50, 50, 50, 43, 50, 47, 55, 49, 50, 47, 55, 49, 53, 37, 50, 46, 53, 47, 52, 56, 46, 58, 52, 51, 51, 55, 51, 46, 50, 54, 53, 53, 46, 48, 49, 53, 51, 38, 48, 51, 49, 47, 54, 49, 52, 51, 43, 47, 48, 48, 48, 43, 53, 64, 56, 46, 55, 55, 47, 47, 58, 52, 51, 44, 47, 52, 61, 51, 54, 61, 50, 45, 43, 51, 50, 48, 52, 53, 51, 48, 50, 48, 47, 52, 51, 50, 47, 51, 58, 58, 62, 53, 46, 51, 56, 44, 49, 54, 55, 47, 54, 44, 54, 51, 46, 48, 53, 54, 50, 55, 48, 50, 53, 50, 54, 47, 46, 44, 52, 50, 53, 43, 46, 51, 48, 49, 48, 45, 47, 41, 55, 52, 48, 53, 45, 62, 45, 47, 48, 52, 53, 53, 56, 38, 44, 48, 49, 47, 46, 52, 50, 49, 50, 47, 49, 55, 53, 46, 48, 47, 55, 52, 48, 47, 53, 53, 43, 46, 56, 48, 51, 40, 51, 57, 50, 57, 51, 53, 42, 45, 52, 51, 44, 50, 50, 53, 46, 47, 54, 50, 50, 56, 56, 53, 51, 49, 52, 46, 49, 47, 47, 50, 50, 41, 49, 52, 42, 47, 54, 47, 47, 51, 56, 47, 49, 51, 47, 48, 56, 44, 60, 41, 50, 52, 44, 48, 53, 48, 54, 54, 52, 44, 50, 46, 55, 52, 50, 51, 44, 56, 49, 50, 53, 52, 54, 52, 51, 54, 45, 48, 47, 45, 53, 45, 52, 52, 49, 52, 49, 45, 51, 44, 51, 49, 54, 47, 49, 53, 49, 46, 45, 52, 47, 47, 47, 43, 48, 51, 53, 54, 56, 46, 50, 55, 59, 54, 44, 48, 59, 47, 41, 48, 50, 45, 53, 53, 48, 49, 50, 53, 43, 59, 47, 44, 47, 51, 50, 56, 57, 55, 49, 56, 56, 54, 42, 49, 56, 51, 58, 44, 47, 56, 45, 53, 54, 47, 45, 50, 48, 47, 57, 53, 55, 47, 53, 49, 50, 46, 50, 48, 51, 46, 44, 51, 56, 55, 51, 47, 50, 49, 49, 47, 46, 51, 47, 51, 50, 48, 43, 49, 46, 46, 56, 49, 51, 51, 54, 50, 52, 59, 53, 46, 47, 50, 46, 47, 46, 49, 48, 49, 42, 47, 52, 48, 61, 49, 50, 54, 49, 49, 55, 52, 47, 51, 42, 55, 41, 54, 55, 50, 51, 51, 50, 53, 52, 46, 54, 52, 51, 56, 51, 53, 53, 44, 44, 53, 56, 54, 50, 46, 49, 50, 59, 48, 50, 54, 48, 46, 51, 44, 47, 54, 51, 55, 54, 51, 39, 52, 52, 49, 44, 47, 60, 51, 34, 46, 45, 52, 55, 57, 55, 42, 50, 57, 52, 53, 52, 45, 44, 42, 47, 46, 55, 47, 51, 54, 51, 47, 50, 57, 46, 49, 47, 47, 44, 44, 55, 52, 47, 48, 41, 48, 53, 43, 51, 45, 51, 55, 49, 54, 48, 52, 47, 47, 55, 43, 54, 48, 52, 51, 49, 48, 46, 49, 50, 47, 50, 49, 60, 51, 52, 53, 48, 51, 50, 42, 51, 52, 50, 52, 47, 51, 54, 47, 44, 53, 48, 45, 54, 49, 47, 46, 51, 52, 49, 47, 50, 48, 59, 54, 45, 61, 53, 43, 52, 54, 53, 61, 54, 49, 51, 50, 57, 43, 44, 51, 52, 47, 46, 48, 48, 51, 56, 43, 56, 46, 50, 53, 48, 45, 43, 50, 56, 48, 52, 48, 46, 48, 47, 42, 52, 49, 51, 49, 54, 48, 47, 54, 53, 42, 45, 46, 52, 55, 50, 42, 52, 45, 44, 44, 54, 48, 46, 48, 51, 55, 52, 50, 50, 48, 56, 52, 41, 56, 55, 50, 42, 53, 46, 47, 50, 46, 53, 56, 48, 50, 52, 53, 46, 57, 49, 51, 52, 50, 53, 53, 47, 47, 46, 55, 54, 48, 49, 49, 49, 51, 45, 45, 50, 48, 55, 52, 48, 48, 41, 50, 50, 50, 50, 61, 43, 52, 48, 53, 54, 49, 44, 47, 55, 58, 48, 58, 46, 44, 54, 55, 47, 47, 45, 47, 52, 50, 46, 52, 49, 48, 47, 50, 56, 50, 56, 54, 49, 54, 50, 50, 45, 56, 48, 56, 60, 50, 47, 54, 51, 53, 50, 50, 57, 56, 41, 53, 49, 54, 51, 57, 49, 50, 52, 47, 49, 53, 55, 49, 53, 47, 51, 50, 37, 61, 56, 50, 49, 67, 49, 52, 57, 55, 46, 53, 51, 57, 50, 50, 49, 49, 48, 56, 60, 42, 48, 49, 52, 56, 47, 57, 40, 60, 50, 52, 51, 54, 51, 47, 48, 59, 47, 53, 52, 49, 49, 49, 50, 39, 52, 48, 42, 50, 49, 50, 46, 52, 48, 51, 51, 51, 46, 49, 46, 48, 45, 55, 47, 47, 60, 57, 50, 51, 46, 49, 48, 47, 38, 52, 55, 51, 44, 48, 54, 51, 59, 51, 56, 46, 48, 51, 45, 56, 47, 51, 53, 50, 45, 53, 59, 50, 56, 53, 48, 42, 50, 54, 49, 50, 60, 50, 65, 58, 54, 47, 45, 55, 44, 51, 48, 49, 45, 46, 51, 48, 55, 53, 50, 46, 58, 59, 50, 49, 51, 54, 53, 61, 55, 52, 51, 45, 41, 52, 48, 50, 51, 52, 49, 51, 50, 50, 55, 44, 50, 47, 49, 55, 52, 58, 51, 50, 48, 45, 46, 55, 56, 43, 49, 50, 59, 53, 45, 47, 49, 40, 45, 55, 46, 50, 53, 50, 45, 52, 48, 53, 53, 51, 49, 52, 49, 52, 56, 36, 50, 45, 45, 49, 49, 56, 51, 50, 50, 48, 46, 50, 48, 48, 47, 52, 39, 44, 51, 55, 48, 55, 46, 53, 45, 54, 55, 57, 53, 49, 46, 53, 49, 49, 53, 52, 52, 51, 52, 51, 48, 53, 44, 39, 46, 48, 51, 52, 44, 54, 44, 49, 54, 55, 48, 51, 50, 54, 43, 53, 47, 47, 45, 54, 46, 52, 51, 55, 59, 48, 49, 55, 54, 51, 51, 44, 56, 50, 54, 47, 53, 58, 51, 54, 47, 43, 47, 55, 49, 75, 72, 59, 73, 74, 54, 62, 64, 68, 66, 82, 77, 79, 76, 63, 83, 76, 72, 75, 71, 66, 69, 67, 65, 67, 67, 69, 57, 52, 61, 72, 64, 74, 59, 72, 70, 68, 80, 70, 70, 72, 74, 78, 73, 76, 65, 68, 70, 75, 73, 68, 81, 76, 93, 73, 69, 66, 65, 61, 74, 74, 69, 76, 79, 73, 73, 82, 61, 62, 71, 83, 76, 61, 66, 77, 64, 72, 67, 68, 66, 67, 53, 79, 75, 61, 66, 71, 67, 71, 60, 72, 72, 72, 71, 69, 71, 78, 61, 71, 80, 69, 59, 64, 72, 75, 74, 69, 69, 70, 62, 61, 66, 77, 66, 67, 62, 64, 77, 69, 73, 78, 79, 63, 70, 72, 70, 70, 68, 70, 77, 88, 69, 62, 71, 74, 71, 58, 78, 68, 70, 74, 81, 68, 64, 67, 74, 64, 66, 65, 67, 65, 78, 78, 70, 64, 68, 72, 81, 68, 68, 64, 69, 64, 66, 65, 70, 80, 71, 59, 70, 69, 64, 78, 68, 71, 69, 69, 75, 62, 65, 59, 77, 62, 70, 72, 76, 84, 78, 60, 69, 74, 76, 76, 73, 73, 86, 65, 72, 72, 64, 82, 81, 73, 62, 65, 68, 74, 65, 73, 66, 80, 64, 65, 69, 65, 74, 74, 71, 65, 63, 66, 72, 72, 77, 77, 68, 75, 68, 72, 62, 68, 59, 68, 59, 73, 71, 82, 73, 71, 74, 73, 73, 71, 71, 75, 81, 72, 76, 75, 75, 84, 68, 65, 76, 71, 64, 67, 65, 65, 76, 80, 66, 80, 63, 72, 61, 76, 73, 61, 70, 72, 75, 71, 53, 73, 84, 74, 67, 68, 64, 70, 74, 68, 75, 63, 71, 73, 63, 72, 61, 68, 67, 62, 79, 65, 72, 72, 66, 69, 71, 68, 65, 81, 69, 70, 70, 61, 77, 73, 80, 73, 74, 60, 68, 71, 69, 81, 87, 66, 66, 71, 67, 65, 77, 67, 75, 66, 74, 77, 62, 72, 71, 80, 73, 64, 75, 69, 62, 67, 71, 70, 68, 64, 61, 80, 68, 83, 62, 70, 66, 75, 70, 61, 71, 64, 56, 55, 75, 78, 73, 62, 71, 67, 73, 65, 71, 67, 69, 66, 71, 69, 72, 77, 70, 68, 74, 70, 69, 68, 71, 80, 63, 70, 64, 70, 70, 68, 71, 65, 67, 63, 64, 73, 71, 62, 85, 73, 75, 73, 78, 69, 69, 77, 69, 70, 66, 61, 70, 71, 72, 68, 64, 60, 58, 68, 67, 71, 82, 60, 65, 73, 70, 74, 71, 69, 81, 60, 76, 70, 62, 67, 66, 67, 63, 72, 71, 62, 63, 65, 70, 66, 68, 79, 76, 79, 70, 68, 62, 66, 66, 75, 77, 68, 67, 73, 80, 58, 64, 78, 69, 65, 70, 70, 70, 75, 64, 59, 66, 74, 66, 84, 57, 79, 80, 63, 83, 84, 77, 74, 64, 67, 79, 64, 73, 70, 74, 75, 63, 68, 63, 70, 70, 66, 77, 70, 71, 79, 68, 70, 69, 66, 69, 69, 59, 73, 63, 73, 70, 63, 80, 78, 70, 77, 71, 68, 66, 78, 72, 71, 63, 77, 68, 71, 66, 73, 80, 77, 73, 70, 63, 61, 71, 67, 62, 80, 79, 62, 72, 61, 66, 69, 72, 75, 69, 76, 80, 76, 80, 76, 66, 77, 62, 72, 75, 62, 62, 61, 74, 72, 64, 70, 63, 69, 72, 73, 78, 63, 73, 63, 65, 69, 66, 72, 70, 85, 67, 63, 69, 72, 70, 70, 75, 76, 63, 66, 70, 67, 76, 74, 70, 70, 75, 67, 61, 61, 74, 77, 61, 68, 69, 78, 73, 76, 70, 63, 76, 62, 79, 73, 66, 79, 71, 64, 61, 69, 72, 72, 71, 75, 66, 77, 62, 63, 63, 64, 60, 69, 67, 72, 82, 75, 81, 76, 65, 66, 71, 82, 78, 59, 70, 72, 74, 73, 80, 75, 70, 78, 86, 77, 66, 68, 71, 68, 67, 78, 64, 71, 65, 64, 73, 73, 60, 72, 70, 76, 75, 68, 70, 60, 71, 57, 78, 74, 71, 70, 71, 59, 73, 76, 64, 76, 76, 70, 75, 65, 62, 70, 62, 64, 69, 68, 78, 81, 72, 67, 84, 67, 79, 65, 72, 62, 65, 71, 69, 61, 65, 58, 68, 68, 75, 60, 73, 63, 68, 87, 71, 69, 70, 61, 77, 75, 75, 72, 66, 75, 82, 71, 73, 61, 66, 81, 79, 71, 67, 66, 77, 64, 70, 70, 76, 69, 76, 74, 77, 71, 78, 70, 67, 64, 75, 69, 84, 64, 74, 65, 69, 73, 66, 77, 63, 74, 67, 61, 68, 59, 64, 59, 66, 65, 55, 66, 71, 75, 65, 58, 68, 75, 79, 69, 69, 67, 75, 71, 78, 75, 68, 54, 72, 75, 75, 62, 81, 67, 66, 78, 75, 59, 64, 74, 65, 67, 72, 67, 79, 66, 51, 72, 65, 64, 66, 61, 71, 67, 67, 65, 63, 68, 82, 62, 69, 87, 66, 72, 65, 58, 70, 83, 76, 70, 69, 75, 72, 63, 65, 66, 80, 72, 76, 68, 66, 78, 64, 73, 68, 69, 66, 80, 80, 68, 56, 67, 78, 59, 71, 70, 64, 81, 77, 78, 74, 61, 69, 70, 79, 61, 63, 71, 66, 74, 70, 69, 77, 76, 77, 75, 69, 77, 69, 68, 71, 77, 64, 65, 72, 69, 79, 68, 79, 68, 78, 73, 62, 58, 55, 76, 85, 75, 72, 77, 67, 68, 66, 83, 63, 88, 67, 77, 75, 80, 66, 86, 65, 77, 67, 63, 72, 75, 66, 68, 65, 71, 73, 72, 68, 80, 68, 81, 74, 73, 73, 77, 74, 68, 77, 70, 66, 72, 71, 77, 62, 65, 72, 78, 77, 69, 67, 78, 72, 66, 70, 64, 74, 75, 69, 66, 67, 72, 78, 65, 57, 74, 67, 61, 72, 66, 63, 66, 67, 72, 75, 65, 66, 75, 69, 62, 68, 61, 67, 67, 77, 70, 71, 65, 66, 66, 77, 68, 67, 74, 68, 70, 78, 60, 78, 69, 75, 73, 66, 76, 69, 66, 67, 65, 72, 74, 61, 65, 73, 77, 80, 75, 72, 66, 66, 70, 73, 77, 72, 67, 75, 71, 75, 68, 70, 77, 72, 64, 69, 66, 71, 61, 81, 74, 63, 65, 71, 77, 56, 81, 66, 64, 79, 72, 74, 64, 66, 74, 75, 71, 77, 74, 63, 86, 78, 85, 74, 68, 85, 63, 73, 61, 66, 68, 80, 69, 74, 65, 67, 57, 71, 70, 71, 68, 61, 62, 58, 65, 79, 77, 68, 64, 66, 72, 67, 74, 59, 73, 76, 69, 65, 74, 72, 66, 79, 79, 67, 72, 67, 68, 70, 60, 78, 78, 73, 74, 70, 50, 75, 68, 83, 71, 77, 66, 77, 80, 81, 69, 65, 70, 65, 63, 67, 65, 83, 69, 54, 74, 73, 71, 66, 70, 82, 54, 66, 69, 66, 62, 69, 67, 71, 61, 73, 72, 71, 65, 78, 70, 77, 70, 68, 66, 69, 71, 60, 68, 73, 69, 74, 67, 69, 73, 72, 73, 69, 65, 55, 74, 71, 67, 73, 62, 74, 75, 65, 70, 72, 69, 64, 70, 72, 73, 75, 70, 68, 66, 71, 81, 68, 80, 78, 72, 66, 65, 66, 64, 63, 74, 72, 67, 76, 76, 69, 61, 66, 75, 69, 66, 75, 58, 78, 67, 68, 73, 70, 77, 70, 80, 80, 73, 70, 66, 71, 72, 73, 63, 75, 66, 65, 87, 82, 75, 60, 65, 71, 67, 78, 77, 74, 65, 74, 68, 74, 76, 72, 70, 73, 62, 63, 71, 70, 70, 68, 73, 80, 78, 59, 69, 73, 63, 73, 61, 67, 81, 76, 69, 68, 58, 66, 63, 68, 59, 68, 65, 79, 72, 64, 68, 75, 67, 68, 67, 71, 70, 73, 72, 74, 67, 66, 74, 59, 72, 60, 72, 74, 81, 64, 72, 79, 67, 78]
sex = ['F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M']
Let's split the data into 70/30 sets.
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(weight, sex, test_size=0.3, random_state=0)
Now let's plot the data for X_train and X_test colored by gender:
plt.hist([x for (x,y) in list(zip(X_train,y_train)) if y=='M'], color='blue', alpha=0.5, bins=15)
plt.hist([x for (x,y) in list(zip(X_train,y_train)) if y=='F'], color='red', alpha=0.5, bins=15)
plt.show()
Now its time for the histogram for the test set:
plt.hist([x for (x,y) in list(zip(X_test,y_test)) if y=='M'], color='blue', alpha=0.5, bins=15)
plt.hist([x for (x,y) in list(zip(X_test,y_test)) if y=='F'], color='red', alpha=0.5, bins=15)
plt.show()
As you can observe, it's a multimodal distribution. This is something very typical in many scenarios, such as when there are patients with certain diseases (cancer/no cancer) or maybe in the banking industry, to label if a customer will be labeled as declined for a loan (declined/approved).
We can use a Gaussian Mixture, a probabilistic model that assumes all the data points are generated from a mixture of a finite number of Gaussian distributions with unknown parameters. SKlearn already has this implemented, and we only need to tell the Gaussian mixture class how many labels or classes exist in the dataset. In this case, we know there are only two genders (male and female), so we will set the parameter n_components=2. Sklearn will automatically identify both distributions and estimate each distribution's means. The trick is simple: if new data comes for a prediction, the Gaussian Mixture Model will predict with a value Xi is close to one mean or two the other and will assign the label accordingly:
import numpy as np
from sklearn.mixture import GaussianMixture
X = np.array(X_train).reshape(np.array(X_train).shape[0], 1)
gm = GaussianMixture(n_components=2, random_state=0).fit(X)
print(gm.means_)
This will print gm.means_[0] = 70.18 and gm.means_[1] = 50.12. We can plot the X_train and y_train distribution again with some vertical lines to check if this works correctly.
plt.hist([x for (x,y) in list(zip(X_train,y_train)) if y=='M'], color='blue', alpha=0.5, bins=15)
plt.hist([x for (x,y) in list(zip(X_train,y_train)) if y=='F'], color='red', alpha=0.5, bins=15)
plt.axvline(gm.means_[0], color='k', linestyle='dashed', linewidth=1)
plt.axvline(gm.means_[1], color='k', linestyle='dashed', linewidth=1)
plt.show()
The gm model was trained on the train set data, and the two means were added to the histogram. All looks good. Now, the only thing left is to predict the test set and get the accuracy. The following snippet will do the trick:
y_pred = gm.predict(np.array(X_test).reshape(np.array(X_test).shape[0], 1))
y_pred = ['M' if x == 0 else 'F' for x in y_pred]
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)
Accuracy: 0.97
Summary
The Gaussian Mixture is a tool for segregating data with multiple distributions. In this case, two normal distributions represented males and females, which SKlearn effortlessly separated. In some cases, the data might be a little more complex with more dimensions; this might require another type of Mixture Model, such as a Variational Bayesian Mixture Model that can help cluster across multiple classes. You can check an example of such a scenario with sklearn mixtures.
Acknowledgments
This code was inspired by an old post from Luis Perez, PhD, about when we worked at the university building AI content for students.