import numpy as np

import matplotlib.pyplot as plt

from utils import sigmoid


def cost_1(z):
    return -np.log(sigmoid(z))


def cost_0(z):
    return -np.log(1 - sigmoid(z))


def cost_function_visualize():
    z = np.arange(-10, 10, 0.1)
    phi_z = sigmoid(z)
    c1 = [cost_1(x) for x in z]
    plt.plot(phi_z, c1, label='J(w) if y=1')
    c0 = [cost_0(x) for x in z]
    plt.plot(phi_z, c0, linestyle='--', label='J(w) if y=0')
    plt.ylim(0.0, 5.1)
    plt.xlim([0, 1])
    plt.xlabel('$\phi$(z)')
    plt.ylabel('J(w)')
    plt.legend(loc='upper left')
    plt.tight_layout()
    plt.show()
