
上QQ阅读APP看书,第一时间看更新
How it works...
This section explains how new inputs for height and weight are used to generate a prediction score for gender.
- A function is created to input new height and weight values and convert the actual values to normalized height and weight values called inputHeight and inputWeight
- A variable, score, is used to store the normalized values and another function, predictGender, is created to input the score values and output a gender score and description based on the values of w1, w2, and b that were created in the previous section. These values have already been pre-adjusted using gradient descent to tweak the values and minimize the cost function.
- Applying the score value to the predict_gender function should reveal the gender description and score, as seen in the following screenshot:

- It appears that the specifications of 70 inches in height and 180 lbs in weight is a high predictor (99.999%) for Male.
- Another test for 50 inches in height and 150 lbs in weight will likely reveal a different gender, as seen in the following screenshot:

- Similarly, this input produces a very low score from the sigmoid function (0.00000000839) indicating that these features are closely associated with the Female gender.