Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 08 - ex06 : Loss function example error #229

Open
2 tasks
cnstll opened this issue Aug 9, 2022 · 1 comment
Open
2 tasks

Day 08 - ex06 : Loss function example error #229

cnstll opened this issue Aug 9, 2022 · 1 comment
Labels

Comments

@cnstll
Copy link

cnstll commented Aug 9, 2022

  • Day: 08 (ml_03)
  • Exercise: 06 (Logistic Regression)

The examples provided for the loss function pass X and Y as parameters
while the loss function should really be applied to Y and Y_hat

Examples
Examples with loss corrected:

    X = np.array([[1., 1., 2., 3.], [5., 8., 13., 21.], [3., 5., 9., 14.]])
    Y = np.array([[1], [0], [1]])
    mylr = MyLogisticRegression([2, 0.5, 7.1, -4.3, 2.09])
    # Example 0:
    Y_hat = mylr.predict_(X)
    print(Y_hat)
    # Output:
    array([[0.99930437],
            [1.        ],
            [1. ]])
    # Example 1:
    print(mylr.loss_(Y, Y_hat)) # HERE
    # Output:
    11.513157421577004
    # Example 2:
    mylr.fit_(X, Y)
    print(mylr.thetas)
    # Output:
    # array([[ 1.04565272],
    #        [ 0.62555148],
    #        [ 0.38387466],
    #        [ 0.15622435],
    #        [-0.45990099]])
    # Example 3:
    Y_hat = mylr.predict_(X)
    print(Y_hat)
    # Output:
    array([[0.72865802],
           [0.40550072],
           [0.45241588]])
    # Example 4:
    print(mylr.loss_(Y, Y_hat))  # HERE
    # Output:
    0.5432466580663214

Screenshots
Screenshot of current examples section
image

Fixed on:

  • Github
  • Gitlab
@cnstll cnstll added the fixme label Aug 9, 2022
@cnstll
Copy link
Author

cnstll commented Aug 9, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant