#!/usr/bin/env python # coding: utf-8 # In[1]: #Visualize Log Loss when True value = 1 #y-axis is log loss, x-axis is probabilty that label = 1 #As you can see Log Loss increases rapidly as we approach 0 #But increases slowly as our predicted probability gets closer to 1 import matplotlib.pyplot as plt import numpy as np from sklearn.metrics import log_loss x = [i*.0001 for i in range(1,10000)] # 10000 y = [log_loss([0,1 if i > 0 else 0],[[0.0001, 0.9999],[1-(i*.0001), i*.0001]],eps=1e-15) for i in range(1,10000,1)] plt.plot(x, y) plt.axis([-.05, 1.1, -.8, 10]) plt.title("Log Loss when true label = 1") plt.xlabel("predicted probability") plt.ylabel("log loss") plt.show() # In[2]: x = [i*.0001 for i in range(1,10000)] y = [log_loss([1],[[i*.0001,1-(i*.0001)]],eps=1e-15) for i in range(1,10000,1)] plt.plot(x, y) plt.axis([-.05, 1.1, -.8, 10]) plt.title("Log Loss when true label = 1") plt.xlabel("predicted probability") plt.ylabel("log loss") plt.show() # In[ ]: