May 2019
Intermediate to advanced
162 pages
4h 24m
English
We finally converge our gradient, which is no longer updating our coefficients, and we are left with a bunch of class probabilities. So, how do we produce the predictions? All we have to do is get above a given threshold and we can get classes. So, in this section, we will be using a binary problem. But, for multi-class, we could just use the argmax functions for each class. Now, we will produce discrete predictions, as shown in the following code:
sigmoid = (lambda x: 1. / (1 + np.exp(-x)))log_odds = np.array([-5.6, 8.9, 3.7, 0.6, 0.])probas = sigmoid(log_odds)classes = np.round(probas).astype(int)print("Log odds: %r\nProbas: %r\nClasses: %r" % (log_odds, probas, classes))
The output of the preceding code is as follows: ...
Read now
Unlock full access